From 92f5e33876303b7443deb9878e140875c4e931b6 Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Tue, 26 Nov 2024 17:01:59 -0500 Subject: [PATCH] fix(contrib/go-chi): remove checks for ext.Error, stop setting isServerError --- contrib/go-chi/chi.v5/chi_test.go | 3 --- contrib/go-chi/chi.v5/option.go | 5 ----- contrib/go-chi/chi/chi_test.go | 3 --- contrib/go-chi/chi/option.go | 5 ----- 4 files changed, 16 deletions(-) diff --git a/contrib/go-chi/chi.v5/chi_test.go b/contrib/go-chi/chi.v5/chi_test.go index 15eff5b82b..6a7081d1f6 100644 --- a/contrib/go-chi/chi.v5/chi_test.go +++ b/contrib/go-chi/chi.v5/chi_test.go @@ -233,9 +233,6 @@ func TestError(t *testing.T) { spans := mt.FinishedSpans() assert.Len(spans, 1) span := spans[0] - if span.Tag(ext.Error) == nil { - t.Fatal("Span missing error tags") - } assertSpan(assert, *span, code) wantErr := fmt.Sprintf("%d: %s", code, http.StatusText(code)) assert.Equal(wantErr, span.Tag(ext.ErrorMsg)) diff --git a/contrib/go-chi/chi.v5/option.go b/contrib/go-chi/chi.v5/option.go index 9f8c5d4dde..f26ab80489 100644 --- a/contrib/go-chi/chi.v5/option.go +++ b/contrib/go-chi/chi.v5/option.go @@ -43,7 +43,6 @@ func defaults(cfg *config) { cfg.serviceName = instr.ServiceName(instrumentation.ComponentServer, nil) cfg.analyticsRate = instr.AnalyticsRate(true) cfg.headerTags = instr.HTTPHeadersAsTags() - cfg.isStatusError = isServerError cfg.ignoreRequest = func(_ *http.Request) bool { return false } cfg.modifyResourceName = func(s string) string { return s } // for backward compatibility with modifyResourceName, initialize resourceName as nil. @@ -97,10 +96,6 @@ func WithStatusCheck(fn func(statusCode int) bool) OptionFn { } } -func isServerError(statusCode int) bool { - return statusCode >= 500 && statusCode < 600 -} - // WithIgnoreRequest specifies a function to use for determining if the // incoming HTTP request tracing should be skipped. func WithIgnoreRequest(fn func(r *http.Request) bool) OptionFn { diff --git a/contrib/go-chi/chi/chi_test.go b/contrib/go-chi/chi/chi_test.go index 85f40943b5..4f682b3c5e 100644 --- a/contrib/go-chi/chi/chi_test.go +++ b/contrib/go-chi/chi/chi_test.go @@ -205,9 +205,6 @@ func TestError(t *testing.T) { spans := mt.FinishedSpans() assert.Len(spans, 1) span := spans[0] - if span.Tag(ext.Error) == nil { - t.Fatal("Span missing error tags") - } assertSpan(assert, *span, code) wantErr := fmt.Sprintf("%d: %s", code, http.StatusText(code)) assert.Equal(wantErr, span.Tag(ext.ErrorMsg)) diff --git a/contrib/go-chi/chi/option.go b/contrib/go-chi/chi/option.go index 0c470fa4ff..1b4450a327 100644 --- a/contrib/go-chi/chi/option.go +++ b/contrib/go-chi/chi/option.go @@ -41,7 +41,6 @@ func defaults(cfg *config) { cfg.serviceName = instr.ServiceName(instrumentation.ComponentServer, nil) cfg.analyticsRate = instr.AnalyticsRate(true) cfg.headerTags = instr.HTTPHeadersAsTags() - cfg.isStatusError = isServerError cfg.ignoreRequest = func(_ *http.Request) bool { return false } cfg.resourceNamer = func(r *http.Request) string { resourceName := chi.RouteContext(r.Context()).RoutePattern() @@ -99,10 +98,6 @@ func WithStatusCheck(fn func(statusCode int) bool) OptionFn { } } -func isServerError(statusCode int) bool { - return statusCode >= 500 && statusCode < 600 -} - // WithHeaderTags enables the integration to attach HTTP request headers as span tags. // Warning: // Using this feature can risk exposing sensitive data such as authorization tokens to Datadog.