Skip to content
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

Request to inject the spancontext to the gin context in otelgin #2412

Closed
david-gang opened this issue Jun 14, 2022 · 1 comment
Closed

Request to inject the spancontext to the gin context in otelgin #2412

david-gang opened this issue Jun 14, 2022 · 1 comment

Comments

@david-gang
Copy link

david-gang commented Jun 14, 2022

In the current implementation the tracing data is injected into the request context and the gin context is unchanged: https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/instrumentation/github.com/gin-gonic/gin/otelgin/gintrace.go#L77

As outlined in #322 this is the wanted behavior.

On the other hand the gin behavior has changed in 1.8.0 so that the Context.Deadline() Context.Done() Context.Err() fallback to Context.Request.Context() if they exist so maybe it would make sense to inject the tracing data also to the gin context.

The big problem is that gin context is also a context and i cannot prevent the programmers to pass gin context instead of context to downstream functions and this will cause breaking trace data.

More specifically we can rely on gin 1.8.1 and then write the following code:

if c.engine.ContextWithFallback && c.Request != nil || c.Request.Context() != nil {
		// inject span into c
}
@david-gang
Copy link
Author

Update, this is fixed by gin themselves so this can be closed: gin-gonic/gin#2751

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

No branches or pull requests

1 participant