diff --git a/jaegertracing/jaegertracing.go b/jaegertracing/jaegertracing.go index 3adf550..123d635 100644 --- a/jaegertracing/jaegertracing.go +++ b/jaegertracing/jaegertracing.go @@ -64,7 +64,7 @@ type ( LimitSize int // OperationNameFunc composes operation name based on context. Can be used to override default naming - OperationNameFunc func(ctx echo.Context) string + OperationNameFunc func(c echo.Context) string } ) @@ -255,9 +255,9 @@ func generateToken() string { return fmt.Sprintf("%x", b) } -func defaultOperationName(ctx echo.Context) string { - req := ctx.Request() - return "HTTP " + req.Method + " URL: " + ctx.Path() +func defaultOperationName(c echo.Context) string { + req := c.Request() + return "HTTP " + req.Method + " URL: " + c.Path() } // TraceFunction wraps funtion with opentracing span adding tags for the function name and caller details diff --git a/jaegertracing/jaegertracing_test.go b/jaegertracing/jaegertracing_test.go index 8fa311e..893bc48 100644 --- a/jaegertracing/jaegertracing_test.go +++ b/jaegertracing/jaegertracing_test.go @@ -354,21 +354,21 @@ func TestTraceWithCustomOperationName(t *testing.T) { e.Use(TraceWithConfig(TraceConfig{ Tracer: tracer, ComponentName: "EchoTracer", - OperationNameFunc: func(ctx echo.Context) string { + OperationNameFunc: func(c echo.Context) string { // This is an example of operation name customization // In most cases default formatting is more than enough - req := ctx.Request() + req := c.Request() opName := "HTTP " + req.Method - path := ctx.Path() - paramNames := ctx.ParamNames() + path := c.Path() + paramNames := c.ParamNames() for _, name := range paramNames { from := ":" + name to := "{" + name + "}" path = strings.ReplaceAll(path, from, to) } - + return opName + " " + path }, }))