From 9b1bef02607d82c48f89a90c617a677381c18fcd Mon Sep 17 00:00:00 2001 From: Rehan Pasha Date: Tue, 23 Jul 2024 11:41:30 -0400 Subject: [PATCH] Fixing lint and format Signed-off-by: Rehan Pasha Signed-off-by: Brian Warner --- .../gin/otelgin/test/gintrace_test.go | 49 +++++++++---------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/instrumentation/github.com/gin-gonic/gin/otelgin/test/gintrace_test.go b/instrumentation/github.com/gin-gonic/gin/otelgin/test/gintrace_test.go index 04a3d4bc9bb..967bd8fc626 100644 --- a/instrumentation/github.com/gin-gonic/gin/otelgin/test/gintrace_test.go +++ b/instrumentation/github.com/gin-gonic/gin/otelgin/test/gintrace_test.go @@ -289,36 +289,35 @@ func TestWithFilter(t *testing.T) { } func TestWithGinFilter(t *testing.T) { - t.Run("custom filter filtering route", func(t *testing.T) { - sr := tracetest.NewSpanRecorder() - otel.SetTracerProvider(sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(sr))) + t.Run("custom filter filtering route", func(t *testing.T) { + sr := tracetest.NewSpanRecorder() + otel.SetTracerProvider(sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(sr))) - router := gin.New() - f := func(c *gin.Context) bool { return c.Request.URL.Path != "/healthcheck" } - router.Use(otelgin.Middleware("foobar", otelgin.WithGinFilter(f))) - router.GET("/healthcheck", func(c *gin.Context) {}) + router := gin.New() + f := func(c *gin.Context) bool { return c.Request.URL.Path != "/healthcheck" } + router.Use(otelgin.Middleware("foobar", otelgin.WithGinFilter(f))) + router.GET("/healthcheck", func(c *gin.Context) {}) - r := httptest.NewRequest("GET", "/healthcheck", nil) - w := httptest.NewRecorder() + r := httptest.NewRequest("GET", "/healthcheck", nil) + w := httptest.NewRecorder() - router.ServeHTTP(w, r) - assert.Len(t, sr.Ended(), 0) - }) + router.ServeHTTP(w, r) + assert.Len(t, sr.Ended(), 0) + }) - t.Run("custom filter not filtering route", func(t *testing.T) { - sr := tracetest.NewSpanRecorder() - otel.SetTracerProvider(sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(sr))) + t.Run("custom filter not filtering route", func(t *testing.T) { + sr := tracetest.NewSpanRecorder() + otel.SetTracerProvider(sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(sr))) - router := gin.New() - f := func(c *gin.Context) bool { return c.Request.URL.Path != "/user/:id" } - router.Use(otelgin.Middleware("foobar", otelgin.WithGinFilter(f))) - router.GET("/user/:id", func(c *gin.Context) {}) + router := gin.New() + f := func(c *gin.Context) bool { return c.Request.URL.Path != "/user/:id" } + router.Use(otelgin.Middleware("foobar", otelgin.WithGinFilter(f))) + router.GET("/user/:id", func(c *gin.Context) {}) - r := httptest.NewRequest("GET", "/user/123", nil) - w := httptest.NewRecorder() + r := httptest.NewRequest("GET", "/user/123", nil) + w := httptest.NewRecorder() - router.ServeHTTP(w, r) - assert.Len(t, sr.Ended(), 1) - }) + router.ServeHTTP(w, r) + assert.Len(t, sr.Ended(), 1) + }) } -