Skip to content

Commit

Permalink
Fixing lint and format
Browse files Browse the repository at this point in the history
Signed-off-by: Rehan Pasha <[email protected]>
Signed-off-by: Brian Warner <[email protected]>
  • Loading branch information
rehanpfmr authored and brianwarner committed Jul 23, 2024
1 parent 0bec819 commit 9b1bef0
Showing 1 changed file with 24 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}

0 comments on commit 9b1bef0

Please sign in to comment.