-
Notifications
You must be signed in to change notification settings - Fork 5
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 log/slog instrumentation #208
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #208 +/- ##
=======================================
Coverage 64.76% 64.76%
=======================================
Files 76 76
Lines 3993 3993
=======================================
Hits 2586 2586
Misses 1134 1134
Partials 273 273
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Add instrumentation for log/slog. Implemented using dd-trace-go's log/slog.Handler wrapper to wrap any handler passed to log/slog.New. This commit does not instrument the default log/slog.Logger. We could do that, for example, by adding some logic like this to func main() if log/slog is imported by package main: slog.SetDefault( slog.New( slogtrace.WrapHandler( slog.Default().Handler(), ), ), ) Will leave that as a followup for now.
5682ecc
to
18ed591
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome 🤩 . This looks good to me - but I'm not super familiar with orchestrion internals.
What does this PR do?
Add instrumentation for
log/slog
. Implemented using dd-trace-go'slog/slog.Handler
wrapper to wrap any handler passed tolog/slog.New
.This commit does not instrument the default
log/slog.Logger
. We coulddo that, for example, by adding some logic like this to
func main()
iflog/slog
is imported by package main:Will leave that as a followup for now.
Motivation
I maintain an app that uses
log/slog
for logging. I'd like to eventuallyinstrument the app using Orchestrion, and having trace-log correlation is very
useful for debugging.
Reviewer's Checklist