From 3c7a657d2b5ceb91bc44e0a785b6ce9a8754169b Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Tue, 4 Jun 2024 15:49:19 -0400 Subject: [PATCH] adds remapping for http status tag to meet DD standard for trace metrics for otel --- ddtrace/opentelemetry/span.go | 2 ++ ddtrace/opentelemetry/span_test.go | 3 +++ 2 files changed, 5 insertions(+) diff --git a/ddtrace/opentelemetry/span.go b/ddtrace/opentelemetry/span.go index 61c197434a..40b8f7064b 100644 --- a/ddtrace/opentelemetry/span.go +++ b/ddtrace/opentelemetry/span.go @@ -212,6 +212,8 @@ func toReservedAttributes(k string, v attribute.Value) (string, interface{}) { rate = 0 } return ext.EventSampleRate, rate + case "http.response.status_code": + return "http.status_code", v.AsString() default: return k, v.AsInterface() } diff --git a/ddtrace/opentelemetry/span_test.go b/ddtrace/opentelemetry/span_test.go index 66fbb63e5e..e9c85c26c3 100644 --- a/ddtrace/opentelemetry/span_test.go +++ b/ddtrace/opentelemetry/span_test.go @@ -725,6 +725,7 @@ func TestRemapWithMultipleSetAttributes(t *testing.T) { sp.SetAttributes(attribute.String("service.name", "new.service.name")) sp.SetAttributes(attribute.String("span.type", "new.span.type")) sp.SetAttributes(attribute.String("analytics.event", "true")) + sp.SetAttributes(attribute.String("http.response.status_code", "200")) sp.End() tracer.Flush() @@ -739,4 +740,6 @@ func TestRemapWithMultipleSetAttributes(t *testing.T) { assert.Equal("new.span.type", p[0]["type"]) metrics := fmt.Sprintf("%v", p[0]["metrics"]) assert.Contains(metrics, fmt.Sprintf("%s:%s", "_dd1.sr.eausr", "1")) + meta := fmt.Sprintf("%v", p[0]["meta"]) + assert.Contains(meta, fmt.Sprintf("%s:%s", "http.status_code", "200")) }