-
Notifications
You must be signed in to change notification settings - Fork 565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
otelgin: add routeName
argument to SpanNameFormatter
function
#5741
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We had #4280 which didn't get traction, but did the same thing, using *gin.Context
instead of a new argument.
Are there any other information from the gin context we may want to use in span name formatter?
Co-authored-by: Damien Mathieu <[email protected]>
@dmathieu Currently no other info needed from the |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5741 +/- ##
=====================================
Coverage 66.6% 66.6%
=====================================
Files 192 192
Lines 15525 15525
=====================================
+ Hits 10351 10354 +3
+ Misses 4883 4881 -2
+ Partials 291 290 -1
|
Ping @hanyuancheung |
@dmathieu @hanyuancheung Any suggestions for this PR? |
@hanyuancheung Any suggestions? Or any principles to follow? |
@dmathieu @hanyuancheung Do you have any suggestions for this PR? Or should I change to add new function like |
otelgin is now deprecated due to a lack of owner: #6190 |
// name. By default, the route name (path template or regexp) is used. The route | ||
// name is provided so you can use it in the span name without needing to | ||
// duplicate the logic for extracting it from the request. | ||
func WithSpanNameFormatter(f func(routeName string, r *http.Request) string) Option { | ||
return optionFunc(func(c *config) { | ||
c.SpanNameFormatter = f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion to add:
if f != nil {
....
}
@@ -75,7 +75,7 @@ func Middleware(service string, opts ...Option) gin.HandlerFunc { | |||
if cfg.SpanNameFormatter == nil { | |||
spanName = c.FullPath() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be considered to adjust to the form of: method path
.
I feel that this PR can be reconsidered for evaluation. Currently, it seems that |
For
Gin
framework, the route name can only be get by usingFullPath()
function ingin.Context
, the originalSpanNameFormatter
only has thehttp.Request
argument that can not get the right route name if route parameters used.This PR add
routeName
argument toSpanNameFormatter
function, align withSpanNameFormatter
inotelmux
.