feat(contrib/go.uber.org/zap): add integration#4729
Conversation
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 83f03f2 | Docs | Datadog PR Page | Give us feedback! |
…ype with Context() method
# Conflicts: # internal/orchestrion/_integration/go.mod # orchestrion/all/go.mod
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files🚀 New features to boost your workflow:
|
BenchmarksBenchmark execution time: 2026-07-23 16:13:00 Comparing candidate commit 83f03f2 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 326 metrics, 0 unstable metrics, 1 flaky benchmarks without significant changes.
|
…support-zap # Conflicts: # go.work.sum # internal/orchestrion/_integration/go.mod # internal/orchestrion/_integration/go.sum # orchestrion/all/go.mod # orchestrion/all/go.sum
Config Audit |
…ing instead of unresolvable ContextProvider interface
… in supported configurations
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8ed411062a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
|
View all feedbacks in Devflow UI.
The expected merge time in
Tests failed on this commit 65cb6c3: What to do next?
|
|
@rarguelloF check-modules workflow seems failing. |
|
/merge |
|
View all feedbacks in Devflow UI.
This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
The expected merge time in
Tests failed on this commit cd2af2c: What to do next?
|
|
PR Shepherd is now watching this PR: fixing basic CI failures, rebasing when it falls behind, and re-queueing after transient merge-queue failures. To disable it, add the If you have any questions, reach the team in #ai-devx-flow. |
What does this PR do?
Adds a new
contrib/go.uber.org/zapintegration for go.uber.org/zap:TraceFields(ctx), which returnszap.Fieldvalues carrying the active span's trace/span IDs, for manual trace/log correlation.TraceFieldsFromRequest(req)is the*http.Requestequivalent and returns nil for a nil request.DD_TRACE_128_BIT_TRACEID_LOGGING_ENABLED: trace IDs are logged in 128-bit hex by default, or as a 64-bit decimal value when the flag is set tofalse, matching the other log-correlation integrations.(*zap.Logger)and(*zap.SugaredLogger)logging methods to inject those trace/span ID fields whenever acontext.Context(directly, or via a type implementing it) or a*http.Requestis in scope, with no code changes required. Covered methods:Logger:Debug,Info,Warn,Error,DPanic,Panic,Fatal,Log.SugaredLogger: the same set, thef/w/lnvariants, andLog/Logf/Logw/Logln.contrib/go.uber.org/zap, plus integration tests underinternal/orchestrion/_integration/zapcovering logger creation, child loggers, the global logger, goroutine propagation, request-derived context, nil requests, calls with no context in scope, value-receiver loggers, the genericLogmethod, the sugared logger, and variadic argument forwarding.Requires Orchestrion v1.11.0+, since the aspects rely on the
method-calljoin-point type, which older versions (e.g. v1.6.0, previously pinned) do not support. Users on an olderorchestrionCLI need to update it manually, since it won't auto-update.Benchmarks
Overhead of injecting the trace fields, measured on an Apple M4 Max via
go test -bench . -benchmem. Theinstrumentedcase mirrors what Orchestrion injects (logger.With(TraceFields(ctx)...).<Method>(...)), so the delta frombaselineis the per-call cost:The instrumented path adds roughly 350ns and about 1.5 KB / 9 allocations per call, from building the fields and cloning the logger via
With. These benchmarks measure the overhead, they do not gate it.Known limitation
Loggers reached through a type that embeds
*zap.Loggeror*zap.SugaredLoggerare not auto-instrumented when the log call is a promoted method (e.g.wrapper.Info(...)), because themethod-calljoin-point matches on the receiver expression's static type rather than the type that declares the method. Workarounds: call through the embedded field (wrapper.Logger.Info(...)), or useTraceFields/TraceFieldsFromRequestmanually. Supporting promoted methods is tracked as a follow-up Orchestrion enhancement.Motivation
go.uber.org/zapis one of the most widely used structured logging libraries in the Go ecosystem. This adds it alongside our existingzerologandlogrusintegrations so zap users get automatic trace/log correlation.Reviewer's Checklist
make lintlocally.make testlocally.make generatelocally.make fix-moduleslocally.Unsure? Have a question? Request a review!