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

feat: add support for span id and custom key for trace id and span id for otelzap #126

Closed

Conversation

pragmaticivan
Copy link

fixes #109

@pragmaticivan pragmaticivan force-pushed the span-id-and-custom-key-support branch from d507252 to be42e44 Compare May 3, 2024 20:55
@@ -439,7 +450,7 @@ func (s *SugaredLogger) FatalfContext(ctx context.Context, template string, args
func (s *SugaredLogger) logArgs(
ctx context.Context, lvl zapcore.Level, template string, args []interface{},
) {
if lvl < s.l.minLevel {
if lvl <= s.l.minLevel {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current code for this line is causing some weird behaviors when the log level is debug

@pragmaticivan pragmaticivan force-pushed the span-id-and-custom-key-support branch from be42e44 to f100fd1 Compare May 3, 2024 20:57
@vmihailenco
Copy link
Member

Thanks for the PR, but otelzap now uses Otel Logs API which has top-level fields for trace & span ids.

@pragmaticivan
Copy link
Author

Hi @vmihailenco could you clarify that? this PR is backward compatible, it happens that many vendors don't follow the same API yet and this would be required to support New Relic for example.

@vmihailenco
Copy link
Member

@pragmaticivan otelzap now does not inject trace_id/span_id and instead relies on Otel Logs API to do it automatically: https://github.com/uptrace/opentelemetry-go-extra/blob/main/otelzap/otelzap.go#L164-L196

And Otel Logs API will set trace/span ids on the log.Record structure directly without using attributes.

@vmihailenco
Copy link
Member

would be required to support New Relic for example.

New Relic would just need to support OpenTelemetry Logs API.

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.

Add span_id with trace_id for zap
2 participants