Skip to content

Commit

Permalink
remove server setup from deep dependency test
Browse files Browse the repository at this point in the history
Signed-off-by: adityachopra29 <[email protected]>
  • Loading branch information
adityachopra29 committed Feb 14, 2025
1 parent 0370b33 commit bec377e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,13 @@ import (
"net/http"

"github.com/gorilla/mux"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
"go.opentelemetry.io/otel/trace"
)

const (
routeGetDeepDependencies = "/api/deep-dependencies"
)

// HTTPGateway exposes analytics HTTP endpoints.
type HTTPGateway struct{}

func RegisterRoutes(router *mux.Router) {
addRoute(router, getDeepDependencies, routeGetDeepDependencies).Methods(http.MethodGet)
}
Expand All @@ -32,7 +28,6 @@ func addRoute(
_ ...any, /* args */
) *mux.Route {
var handler http.Handler = http.HandlerFunc(f)
handler = otelhttp.WithRouteTag(route, handler)
handler = spanNameHandler(route, handler)
return router.HandleFunc(route, handler.ServeHTTP)
}
Expand All @@ -59,7 +54,6 @@ func getDeepDependencies(w http.ResponseWriter, _ *http.Request) {
},
},
}

res, err := json.Marshal(dependencies)
if err != nil {
http.Error(w, "Failed to encode response", http.StatusNotImplemented)
Expand Down
45 changes: 45 additions & 0 deletions cmd/query/app/analytics/deep_dependencies_handler_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) 2025 The Jaeger Authors.
// SPDX-License-Identifier: Apache-2.0

package analytics

import (
"encoding/json"
"net/http"
"net/http/httptest"
"testing"

"github.com/gorilla/mux"
"github.com/stretchr/testify/require"

_ "github.com/jaegertracing/jaeger/pkg/gogocodec" // force gogo codec registration
)

func TestGetDeepDependencies(t *testing.T) {
router := mux.NewRouter()
RegisterRoutes(router)

req, err := http.NewRequest(http.MethodGet, routeGetDeepDependencies, nil)
require.NoError(t, err)

rw := httptest.NewRecorder()
router.ServeHTTP(rw, req)

require.Equal(t, http.StatusOK, rw.Code)

var response TDdgPayload
err = json.Unmarshal(rw.Body.Bytes(), &response)
require.NoError(t, err)

expectedPath := []TDdgPayloadEntry{
{Service: "sample-serviceA", Operation: "sample-opA"},
{Service: "sample-serviceB", Operation: "sample-opB"},
}
expectedAttributes := []Attribute{
{Key: "exemplar_trace_id", Value: "abc123"},
}

require.Len(t, response.Dependencies, 1)
require.Equal(t, expectedPath, response.Dependencies[0].Path)
require.Equal(t, expectedAttributes, response.Dependencies[0].Attributes)
}
97 changes: 0 additions & 97 deletions cmd/query/app/analytics/http_gateway_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion cmd/query/app/analytics/package_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 The Jaeger Authors.
// Copyright (c) 2025 The Jaeger Authors.
// SPDX-License-Identifier: Apache-2.0

package analytics
Expand Down

0 comments on commit bec377e

Please sign in to comment.