-
Notifications
You must be signed in to change notification settings - Fork 501
feat(contrib): Add rs/zerolog ddtracer integration #4370
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
Merged
+803
−4
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
084899e
feat(contrib): Add rs/zerolog ddtracer integration
takanuva15 5056a13
Apply suggestion from @darccio
darccio d0bcf8f
feat(internal/orchestrion/_integration): add replace directive for rs…
darccio b2a0df0
fix(zerolog): update orchestrion.yml
darccio 0b3e556
chore(contrib/rs/zerolog): update go.mod
darccio 8b77512
contrib(contrib/rs/zerolog): update go.sum
darccio 260fde9
fix(contrib/rs/zerolog): build fixed in inject-declarations template
darccio b49aa39
fix(contrib/rs/zerolog): generate a span in testcase
darccio 30ffb13
fix(contrib/rs/zerolog): add missing import for integration tests
darccio d6ff4d7
contrib(contrib/rs/zerolog): Updates
takanuva15 2afd7e5
fix(contrib/rs/zerolog): revert accidental overwrite on zerolog.go
darccio 90652a5
fix(contrib/rs/zerolog): generate span in testcase in Orchestrion int…
darccio 2233b29
Merge branch 'main' into main
darccio 48531ea
fix(contrib/rs/zerolog): use the right import in integration test
darccio f17cfe6
fix(contrib/rs/zerolog): reorder imports in integration test
darccio 16ad025
chore(contrib/rs/zerolog): fix import formatting
darccio de0057b
fix(contrib/rs/zerolog): bump to 1.25
darccio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // Unless explicitly stated otherwise all files in this repository are licensed | ||
| // under the Apache License Version 2.0. | ||
| // This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
| // Copyright 2022 Datadog, Inc. | ||
|
|
||
| package zerolog_test | ||
|
|
||
| import ( | ||
| "context" | ||
| "os" | ||
| "time" | ||
|
|
||
| "github.com/rs/zerolog" | ||
|
|
||
| ddzerolog "github.com/DataDog/dd-trace-go/contrib/rs/zerolog/v2" | ||
|
|
||
| "github.com/DataDog/dd-trace-go/v2/ddtrace/tracer" | ||
| ) | ||
|
|
||
| func ExampleHook() { | ||
| _ = tracer.Start() | ||
| defer tracer.Stop() | ||
| // Ensure your tracer is started and stopped | ||
| // Setup zerolog, do this once at the beginning of your program | ||
| zlog := zerolog.New(os.Stdout). | ||
| Hook(&ddzerolog.DDContextLogHook{}) | ||
|
|
||
| span, sctx := tracer.StartSpanFromContext(context.Background(), "mySpan") | ||
| defer span.Finish() | ||
|
|
||
| // Pass the current span context to the logger (Time is set for consistency in output here) | ||
| cLog := zlog.Info().Ctx(sctx).Time("time", time.Date(2000, 1, 1, 1, 1, 1, 0, time.UTC)) | ||
| // Log as desired using the context-aware logger | ||
| cLog.Msg("Completed some work!") | ||
| // You should see: | ||
| // {"dd.span_id":0,"dd.trace_id":0,"level":"info","msg":"Completed some work!","time":"2000-01-01T01:01:01Z"} | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| module github.com/DataDog/dd-trace-go/contrib/rs/zerolog/v2 | ||
|
|
||
| go 1.25.0 | ||
|
|
||
| require ( | ||
| github.com/DataDog/dd-trace-go/v2 v2.7.0-dev.1 | ||
| github.com/rs/zerolog v1.34.0 | ||
| github.com/stretchr/testify v1.11.1 | ||
| ) | ||
|
|
||
| require ( | ||
| github.com/DataDog/datadog-agent/comp/core/tagger/origindetection v0.75.2 // indirect | ||
| github.com/DataDog/datadog-agent/pkg/obfuscate v0.75.2 // indirect | ||
| github.com/DataDog/datadog-agent/pkg/opentelemetry-mapping-go/otlp/attributes v0.75.2 // indirect | ||
| github.com/DataDog/datadog-agent/pkg/proto v0.75.2 // indirect | ||
| github.com/DataDog/datadog-agent/pkg/remoteconfig/state v0.75.2 // indirect | ||
| github.com/DataDog/datadog-agent/pkg/template v0.75.2 // indirect | ||
| github.com/DataDog/datadog-agent/pkg/trace v0.75.2 // indirect | ||
| github.com/DataDog/datadog-agent/pkg/util/log v0.75.2 // indirect | ||
| github.com/DataDog/datadog-agent/pkg/util/scrubber v0.75.2 // indirect | ||
| github.com/DataDog/datadog-agent/pkg/version v0.75.2 // indirect | ||
| github.com/DataDog/datadog-go/v5 v5.8.2 // indirect | ||
| github.com/DataDog/go-libddwaf/v4 v4.8.0 // indirect | ||
| github.com/DataDog/go-runtime-metrics-internal v0.0.4-0.20250721125240-fdf1ef85b633 // indirect | ||
| github.com/DataDog/go-sqllexer v0.1.10 // indirect | ||
| github.com/DataDog/go-tuf v1.1.1-0.5.2 // indirect | ||
| github.com/DataDog/sketches-go v1.4.7 // indirect | ||
| github.com/Microsoft/go-winio v0.6.2 // indirect | ||
| github.com/cenkalti/backoff/v5 v5.0.3 // indirect | ||
| github.com/cespare/xxhash/v2 v2.3.0 // indirect | ||
| github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575 // indirect | ||
| github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect | ||
| github.com/dustin/go-humanize v1.0.1 // indirect | ||
| github.com/ebitengine/purego v0.9.1 // indirect | ||
| github.com/go-ole/go-ole v1.3.0 // indirect | ||
| github.com/golang/protobuf v1.5.4 // indirect | ||
| github.com/google/uuid v1.6.0 // indirect | ||
| github.com/hashicorp/go-version v1.8.0 // indirect | ||
| github.com/json-iterator/go v1.1.12 // indirect | ||
| github.com/klauspost/compress v1.18.0 // indirect | ||
| github.com/klauspost/cpuid/v2 v2.2.3 // indirect | ||
| github.com/linkdata/deadlock v0.5.5 // indirect | ||
| github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35 // indirect | ||
| github.com/mattn/go-colorable v0.1.13 // indirect | ||
| github.com/mattn/go-isatty v0.0.19 // indirect | ||
| github.com/minio/simdjson-go v0.4.5 // indirect | ||
| github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
| github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect | ||
| github.com/outcaste-io/ristretto v0.2.3 // indirect | ||
| github.com/petermattis/goid v0.0.0-20250813065127-a731cc31b4fe // indirect | ||
| github.com/philhofer/fwd v1.2.0 // indirect | ||
| github.com/pkg/errors v0.9.1 // indirect | ||
| github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect | ||
| github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect | ||
| github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect | ||
| github.com/puzpuzpuz/xsync/v3 v3.5.1 // indirect | ||
| github.com/secure-systems-lab/go-securesystemslib v0.9.0 // indirect | ||
| github.com/shirou/gopsutil/v4 v4.25.11 // indirect | ||
| github.com/tinylib/msgp v1.6.1 // indirect | ||
| github.com/tklauser/go-sysconf v0.3.16 // indirect | ||
| github.com/tklauser/numcpus v0.11.0 // indirect | ||
| github.com/trailofbits/go-mutexasserts v0.0.0-20250514102930-c1f3d2e37561 // indirect | ||
| github.com/yusufpapurcu/wmi v1.2.4 // indirect | ||
| go.opentelemetry.io/collector/component v1.48.0 // indirect | ||
| go.opentelemetry.io/collector/featuregate v1.48.0 // indirect | ||
| go.opentelemetry.io/collector/pdata v1.48.0 // indirect | ||
| go.opentelemetry.io/collector/pdata/pprofile v0.142.0 // indirect | ||
| go.opentelemetry.io/otel v1.39.0 // indirect | ||
| go.opentelemetry.io/otel/metric v1.39.0 // indirect | ||
| go.opentelemetry.io/otel/trace v1.39.0 // indirect | ||
| go.uber.org/atomic v1.11.0 // indirect | ||
| go.uber.org/multierr v1.11.0 // indirect | ||
| go.uber.org/zap v1.27.1 // indirect | ||
| go.yaml.in/yaml/v3 v3.0.4 // indirect | ||
| golang.org/x/exp v0.0.0-20251209150349-8475f28825e9 // indirect | ||
| golang.org/x/mod v0.31.0 // indirect | ||
| golang.org/x/sys v0.39.0 // indirect | ||
| golang.org/x/time v0.14.0 // indirect | ||
| golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect | ||
| google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 // indirect | ||
| google.golang.org/protobuf v1.36.10 // indirect | ||
| gopkg.in/ini.v1 v1.67.0 // indirect | ||
| gopkg.in/yaml.v3 v3.0.1 // indirect | ||
| ) | ||
|
|
||
| replace github.com/DataDog/dd-trace-go/v2 => ../../.. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.