Skip to content

Commit

Permalink
Set resource name
Browse files Browse the repository at this point in the history
  • Loading branch information
e-n-0 committed Dec 17, 2024
1 parent cd21985 commit 2a5755a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions contrib/envoyproxy/go-control-plane/envoy.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"io"
"math"
"net/http"
"path"
"strings"

"gopkg.in/DataDog/dd-trace-go.v1/contrib/internal/httptrace"
Expand Down Expand Up @@ -204,6 +205,7 @@ func processRequestHeaders(ctx context.Context, req *envoyextproc.ProcessingRequ
var blocked bool
fakeResponseWriter := newFakeResponseWriter()
wrappedResponseWriter, request, afterHandle, blocked := httptrace.BeforeHandle(&httptrace.ServeConfig{
Resource: request.Method + " " + path.Clean(request.URL.Path),
SpanOpts: []ddtrace.StartSpanOption{
tracer.Tag(ext.SpanKind, ext.SpanKindServer),
tracer.Tag(ext.Component, componentName),
Expand Down
6 changes: 3 additions & 3 deletions contrib/envoyproxy/go-control-plane/envoy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func TestGeneratedSpan(t *testing.T) {
stream, err := client.Process(ctx)
require.NoError(t, err)

end2EndStreamRequest(t, stream, "/resource-span", "GET", map[string]string{"user-agent": "Mistake Not...", "test-key": "test-value"}, map[string]string{"response-test-key": "response-test-value"}, false)
end2EndStreamRequest(t, stream, "/../../../resource-span/.?id=test", "GET", map[string]string{"user-agent": "Mistake Not...", "test-key": "test-value"}, map[string]string{"response-test-key": "response-test-value"}, false)

err = stream.CloseSend()
require.NoError(t, err)
Expand All @@ -266,10 +266,10 @@ func TestGeneratedSpan(t *testing.T) {
// Check for tags
span := finished[0]
require.Equal(t, "http.request", span.OperationName())
require.Equal(t, "https://datadoghq.com/resource-span", span.Tag("http.url"))
require.Equal(t, "https://datadoghq.com/../../../resource-span/.?id=test", span.Tag("http.url"))
require.Equal(t, "GET", span.Tag("http.method"))
require.Equal(t, "datadoghq.com", span.Tag("http.host"))
// require.Equal(t, "GET /resource-span", span.Tag("resource.name"))
require.Equal(t, "GET /resource-span", span.Tag("resource.name"))
require.Equal(t, "server", span.Tag("span.kind"))
require.Equal(t, "Mistake Not...", span.Tag("http.useragent"))
})
Expand Down

0 comments on commit 2a5755a

Please sign in to comment.