-
Notifications
You must be signed in to change notification settings - Fork 669
otelgin: Add a WithSpanStartOptions option #7261
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7261 +/- ##
=======================================
- Coverage 81.2% 81.2% -0.1%
=======================================
Files 207 207
Lines 18263 18270 +7
=======================================
+ Hits 14835 14839 +4
- Misses 3007 3009 +2
- Partials 421 422 +1
🚀 New features to boost your workflow:
|
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.
This is missing tests and a changelog entry.
@@ -31,6 +31,13 @@ const ( | |||
// server handling the request. | |||
func Middleware(service string, opts ...Option) gin.HandlerFunc { | |||
cfg := config{} | |||
|
|||
defaultOpts := []Option{ | |||
WithSpanOptions(oteltrace.WithSpanKind(oteltrace.SpanKindServer)), |
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.
What is the reason for moving this part here?
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.
This structure is also used in otelhttp
, as seen [here](
opentelemetry-go-contrib/instrumentation/net/http/otelhttp/handler.go
Lines 52 to 60 in f368d04
func NewMiddleware(operation string, opts ...Option) func(http.Handler) http.Handler { | |
h := middleware{ | |
operation: operation, | |
} | |
defaultOpts := []Option{ | |
WithSpanOptions(trace.WithSpanKind(trace.SpanKindServer)), | |
WithSpanNameFormatter(defaultHandlerFormatter), | |
} |
Let me know if you’d prefer to remove it.
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.
According to the principle of Occam's Razor: Do not multiply entities beyond necessity.
From what I understand, the operating result would be the same even without modifying this part.
instrumentation/github.com/gin-gonic/gin/otelgin/test/gin_test.go
Outdated
Show resolved
Hide resolved
instrumentation/github.com/gin-gonic/gin/otelgin/test/gin_test.go
Outdated
Show resolved
Hide resolved
Additionally, please correct the title of this PR. |
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.
If you are ready for review, you can remove the draft mode.
Co-authored-by: Damien Mathieu <[email protected]>
Closes: #7247