Skip to content

Commit

Permalink
Renaming according to echo conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
m1x0n authored and aldas committed Jun 19, 2022
1 parent 3cc8455 commit d0a6a6e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions jaegertracing/jaegertracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
)

Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions jaegertracing/jaegertracing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
}))
Expand Down

0 comments on commit d0a6a6e

Please sign in to comment.