From 931d9a02006a8fe6a82eb2075349dfbb79763092 Mon Sep 17 00:00:00 2001 From: Flavien Darche Date: Mon, 16 Dec 2024 16:17:04 +0000 Subject: [PATCH] Set resource name --- contrib/envoyproxy/go-control-plane/envoy.go | 2 ++ contrib/envoyproxy/go-control-plane/envoy_test.go | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/contrib/envoyproxy/go-control-plane/envoy.go b/contrib/envoyproxy/go-control-plane/envoy.go index 52279e0138..a38b5a5e3c 100644 --- a/contrib/envoyproxy/go-control-plane/envoy.go +++ b/contrib/envoyproxy/go-control-plane/envoy.go @@ -11,6 +11,7 @@ import ( "io" "math" "net/http" + "path" "strings" "gopkg.in/DataDog/dd-trace-go.v1/contrib/internal/httptrace" @@ -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), diff --git a/contrib/envoyproxy/go-control-plane/envoy_test.go b/contrib/envoyproxy/go-control-plane/envoy_test.go index 8af05eaab3..257cf83538 100644 --- a/contrib/envoyproxy/go-control-plane/envoy_test.go +++ b/contrib/envoyproxy/go-control-plane/envoy_test.go @@ -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) @@ -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")) })