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

Missing trace_id + span_id when using with otelfiber #27

Closed
scorpionknifes opened this issue Aug 17, 2024 · 2 comments
Closed

Missing trace_id + span_id when using with otelfiber #27

scorpionknifes opened this issue Aug 17, 2024 · 2 comments

Comments

@scorpionknifes
Copy link

I'm trying to use the official otelfiber and this library to log trace_id and user_id

app.Use(otelfiber.Middleware())
app.Use(slogfiber.NewWithConfig(logger, slogfiber.Config{
    WithSpanID:  true,
    WithTraceID: true,
}))

I noticed the otelfiber library uses c.UserContext()
https://github.com/gofiber/contrib/blob/c62abb213b0a82b35be9ecf39237760e0ee84c84/otelfiber/fiber.go#L119-L120

And this library uses c.Context() which trace doesn't exist.

slog-fiber/middleware.go

Lines 181 to 182 in 7bd189e

// otel
baseAttributes = append(baseAttributes, extractTraceSpanID(c.Context(), config.WithTraceID, config.WithSpanID)...)

I'm not sure if i'm implementing this wrong or the library is deliberately using the fasthttp context?

@scorpionknifes
Copy link
Author

scorpionknifes commented Aug 17, 2024

Side note I think trace id and span id need to be trace_id instead of trace-id
https://opentelemetry.io/docs/specs/otel/compatibility/logging_trace_context

@samber
Copy link
Owner

samber commented Aug 17, 2024

i made a fix, thanks for the feedback

@samber samber closed this as completed Aug 17, 2024
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

2 participants