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

[feature] Log OTEL internal logs #3202

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Tsuribori
Copy link
Contributor

Description

Currently the internal logs of the OTEL library aren't logged making it hard to debug situations like #3117

The OTEL library expects a Logr logger to be passed to it so this pull request implements a Logr LogSink that logs through the existing logging mechanism.

When tracing is enabled this will produce logs like the following for example:

timestamp="14/08/2024 19:00:18.752" func=trace.(*TracerProvider).Tracer level=INFO name=github.com/uptrace/bun version="" schemaURL="" msg="Tracer created"
timestamp="14/08/2024 19:00:19.173" func=trace.(*TracerProvider).Tracer level=INFO name=github.com/superseriousbusiness/gotosocial/internal/tracing version=0.0.0-testrig schemaURL="" msg="Tracer created"
timestamp="14/08/2024 19:05:23.394" func=trace.(*batchSpanProcessor).exportSpans level=DEBUG count=2 total_dropped=0 msg="exporting spans"

Checklist

Please put an x inside each checkbox to indicate that you've read and followed it: [ ] -> [x]

If this is a documentation change, only the first checkbox must be filled (you can delete the others if you want).

  • I/we have read the GoToSocial contribution guidelines.
  • I/we have discussed the proposed changes already, either in an issue on the repository, or in the Matrix chat.
  • I/we have not leveraged AI to create the proposed changes.
  • I/we have performed a self-review of added code.
  • I/we have written code that is legible and maintainable by others.
  • I/we have commented the added code, particularly in hard-to-understand areas.
  • I/we have made any necessary changes to documentation.
  • I/we have added tests that cover new code.
  • I/we have run tests and they pass locally with the changes.
  • I/we have run go fmt ./... and golangci-lint run.

@@ -20,6 +20,7 @@ package log
import (
"context"
"fmt"
"github.com/go-logr/logr"
Copy link
Member

Choose a reason for hiding this comment

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

Please respect the import sorting, stdlib first, external in a second block.

@daenney
Copy link
Member

daenney commented Aug 15, 2024

This adds ogging output when tracing is enabled that's not necessarily useful to people under normal conditions.

I agree it's useful for debugging tracing issues, but I think we should put this behind a config flag that enables the internal tracing logger only when requested. Something like tracing-logger-enabled, to stick with the current naming conventions.

@NyaaaWhatsUpDoc
Copy link
Member

honestly i was going to suggest maybe moving this into the tracing package itself so this code is only there when the build tag is enabled. are you good with me having a poke around on this branch @Tsuribori and maybe trying shifting it around?

@Tsuribori
Copy link
Contributor Author

honestly i was going to suggest maybe moving this into the tracing package itself so this code is only there when the build tag is enabled. are you good with me having a poke around on this branch @Tsuribori and maybe trying shifting it around?

Sure

@daenney
Copy link
Member

daenney commented Aug 15, 2024

honestly i was going to suggest maybe moving this into the tracing package itself so this code is only there when the build tag is enabled. are you good with me having a poke around on this branch @Tsuribori and maybe trying shifting it around?

I think that's fine too, but I would still like to be able to run with tracing enabled but without additional logging by the tracer itself.

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.

3 participants