Skip to content

feat(contrib): Add rs/zerolog ddtracer integration#4370

Merged
darccio merged 17 commits intoDataDog:mainfrom
takanuva15:main
Feb 13, 2026
Merged

feat(contrib): Add rs/zerolog ddtracer integration#4370
darccio merged 17 commits intoDataDog:mainfrom
takanuva15:main

Conversation

@takanuva15
Copy link
Contributor

@takanuva15 takanuva15 commented Jan 22, 2026

What does this PR do?

Adds integration for rs/zerolog as discussed here

Motivation

We use zerolog and Datadog together and would like to have Datadog support rs/zerolog for us natively

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • New code is free of linting errors. You can check this by running ./scripts/lint.sh locally.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild.

Unsure? Have a question? Request a review!

@takanuva15
Copy link
Contributor Author

@darccio I don't have permission to request review from dd-trace-go-guild on this PR - can you add them for me?

@darccio
Copy link
Member

darccio commented Jan 26, 2026

@takanuva15 It was automatically requested.

image

@takanuva15
Copy link
Contributor Author

@darccio I see some checks are failing but the logs all seem to be wiped out. Can you help clarify what needs to be fixed?

image

@takanuva15
Copy link
Contributor Author

@darccio Hi, I see some checks are failing but the logs all seem to be wiped out. Can you help clarify what needs to be fixed?

@darccio
Copy link
Member

darccio commented Feb 6, 2026

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bdf80c8a04

ℹ️ 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".

Comment on lines 40 to 43
if ok, _ := regexp.Match(`\d+`, data["dd.trace_id"].([]byte)); !ok {
t.Errorf("no trace ID")
}
if ok, _ := regexp.Match(`\d+`, data["dd.span_id"].([]byte)); !ok {

Choose a reason for hiding this comment

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

P2 Badge Fix panic when checking JSON fields

json.Unmarshal into map[string]interface{} yields string values for JSON strings, so data["dd.trace_id"].([]byte) and data["dd.span_id"].([]byte) will panic on the first run of this integration test (the zerolog output encodes these fields as JSON strings). This makes the test fail even when trace/span IDs are present. Use regexp.MatchString on a string value (or cast to string first) to avoid the panic and correctly validate the fields.

Useful? React with 👍 / 👎.

@darccio
Copy link
Member

darccio commented Feb 6, 2026

@takanuva15 Let me check.

Copy link
Member

@darccio darccio left a comment

Choose a reason for hiding this comment

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

You must update ddtrace/tracer/option_test.go test TestAgentIntegration:

func TestAgentIntegration(t *testing.T) {
	t.Run("err", func(t *testing.T) {
		assert.False(t, MarkIntegrationImported("this-integration-does-not-exist"))
	})

	// this test is run before configuring integrations and after: ensures we clean up global state
	defaultUninstrumentedTest := func(t *testing.T) {
		cfg, err := newTestConfig()
		assert.Nil(t, err)
		defer clearIntegrationsForTests()

		cfg.loadContribIntegrations(nil)
		assert.Equal(t, 55, len(cfg.integrations)) // <-- it must be 56
		for integrationName, v := range cfg.integrations {
			assert.False(t, v.Instrumented, "integrationName=%s", integrationName)
		}
	}
	// ...

@darccio
Copy link
Member

darccio commented Feb 6, 2026

BTW @takanuva15, please run make fix-modules and make generate too.

@darccio
Copy link
Member

darccio commented Feb 12, 2026

@takanuva15 Sorry for taking over, but this is faster than asking for changes. I want to merge it this week before the beginning of our next release train.

@takanuva15
Copy link
Contributor Author

@takanuva15 Sorry for taking over, but this is faster than asking for changes. I want to merge it this week before the beginning of our next release train.

lol no problemo, whatever it takes to make it successful

@darccio
Copy link
Member

darccio commented Feb 12, 2026

@takanuva15 Can you merge DataDog:main into your branch? It isn't working on GitHub UI.

@takanuva15
Copy link
Contributor Author

@takanuva15 Can you merge DataDog:main into your branch? It isn't working on GitHub UI.

done. (I rebased the entire branch onto latest main)

Copy link
Member

@darccio darccio left a comment

Choose a reason for hiding this comment

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

Requesting changes to apply linting fixes.

@darccio darccio merged commit 6845906 into DataDog:main Feb 13, 2026
87 checks passed
@takanuva15
Copy link
Contributor Author

@darccio awesome thanks! Do you know which release version this PR will become available?

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.

2 participants