contrib(zap): add log/trace correlation for uber-go/zap#4610
contrib(zap): add log/trace correlation for uber-go/zap#4610highlyavailable wants to merge 6 commits intoDataDog:mainfrom
Conversation
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@highlyavailable Thanks for contributing it! It'd be great if you can add an |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
🚀 New features to boost your workflow:
|
|
@highlyavailable Check the CI checks, as there are some failing. |
Add PackageGoUberOrgZap constant and PackageInfo entry to prepare for the upcoming uber-go/zap logging contrib integration.
Add contrib/go.uber.org/zap with a TraceFields helper that extracts
Datadog trace and span IDs from context and returns them as zap fields.
Supports both 128-bit and 64-bit trace ID formats.
Usage: logger.Info("msg", ddzap.TraceFields(ctx)...)
Add go.uber.org/zap to the contribIntegrations map in tracer/option.go so it shows up in startup diagnostics. Also add the package to supported_integrations.md and update go.work.sum.
Adds an orchestrion.yml that marks go.uber.org/zap as imported when Orchestrion auto-instrumentation is active. Full automatic context injection isn't possible since zap's zapcore.Core.Write() doesn't accept context.Context, but integration discovery is handled.
9895fa7 to
6a25ead
Compare
Hi @darccio, I added a commit with an
Made some updates for the failing CI checks, waiting on the approval now 👍 |
|
@highlyavailable Thanks. I'll let @DataDog/apm-idm-go to discuss the implementation design. About the |
Was failing CI jobs, after reading through their logs I think I need to set the integration count (56 → 57) and register DD_TRACE_ZAP_ANALYTICS_ENABLED as a supported config
|
Hi @darccio. Just pushed an update to tests and config which should take care of the failing CI. For orchestrion.yml, what’s in there right now is just wiring up integration telemetry. I wasn’t really sure about the best way to handle actual trace injection given zap’s constraints, so would really appreciate any guidance on how you (or others) all think that should be done. Also saw the overlap with #4241, main difference is I went with That said, I’m very open to aligning with #4241 or reshaping the API if you have a preferred direction, happy to adjust and thank you for the feedback so far |
…g-correlation # Conflicts: # go.work.sum
What does this PR do?
Adds a new contrib package at
contrib/go.uber.org/zapthat provides log/trace correlation foruber-go/zap. Just the single helperTraceFields(ctx context.Context) []zap.Fieldwhich pulls DD trace and span IDs from the context and returns them as zap fields.Usage:
Zap's
zapcore.Core.Write()doesn't takecontext.Context, wrapping the core didn't seem like an option, but I am happy to get your feedback if you can think of a better implementation.I added support for both 128-bit and 64-bit trace ID formats via
DD_TRACE_128_BIT_TRACEID_LOGGING_ENABLED.Motivation
go.uber.org/zapis one of the most widely used structured loggers in Go and there's currently no Datadog logging integration for it. This closes that gap, following the same patterns used by the existing zerolog and logrus contribs.