Skip to content

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

Merged
merged 3 commits into from
May 13, 2025

Conversation

arshukla98
Copy link
Contributor

Closes: #7247

@github-actions github-actions bot requested review from akats7 and flc1125 April 24, 2025 07:35
Copy link

codecov bot commented Apr 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.2%. Comparing base (abb5c4f) to head (50403a2).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           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     
Files with missing lines Coverage Δ
...ntation/github.com/gin-gonic/gin/otelgin/config.go 100.0% <100.0%> (ø)
...umentation/github.com/gin-gonic/gin/otelgin/gin.go 93.1% <100.0%> (+0.1%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@arshukla98 arshukla98 marked this pull request as ready for review April 28, 2025 07:14
@arshukla98 arshukla98 requested a review from a team as a code owner April 28, 2025 07:14
Copy link
Member

@dmathieu dmathieu left a 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.

@arshukla98 arshukla98 marked this pull request as draft April 28, 2025 08:04
@arshukla98 arshukla98 closed this Apr 30, 2025
@arshukla98 arshukla98 reopened this Apr 30, 2025
@@ -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)),
Copy link
Member

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?

Copy link
Contributor Author

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](

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.

Copy link
Member

@flc1125 flc1125 May 5, 2025

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.

@arshukla98 arshukla98 marked this pull request as ready for review May 5, 2025 08:26
@flc1125
Copy link
Member

flc1125 commented May 5, 2025

Additionally, please correct the title of this PR.

@arshukla98 arshukla98 marked this pull request as draft May 5, 2025 13:12
@arshukla98 arshukla98 changed the title otelgin: Add a WithSpanOptions option otelgin: Add a WithSpanStartOptions option May 6, 2025
Copy link
Member

@flc1125 flc1125 left a 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.

@arshukla98 arshukla98 marked this pull request as ready for review May 6, 2025 10:23
@arshukla98 arshukla98 requested a review from dmathieu May 8, 2025 07:53
@dmathieu dmathieu merged commit 71a2939 into open-telemetry:main May 13, 2025
27 of 28 checks passed
@MrAlias MrAlias added this to the v1.36.0 milestone May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

otelgin: Add a WithSpanOptions option
5 participants