Skip to content

Commit

Permalink
contrib/envoyproxy: fix resource name (#3047)
Browse files Browse the repository at this point in the history
  • Loading branch information
e-n-0 authored and hannahkm committed Jan 6, 2025
1 parent 2031791 commit 89bfc59
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"

"github.com/DataDog/dd-trace-go/v2/ddtrace/ext"
Expand Down Expand Up @@ -203,6 +204,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: []tracer.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 @@ -252,7 +252,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 @@ -264,10 +264,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 89bfc59

Please sign in to comment.