Skip to content

Conversation

@wantsui
Copy link
Collaborator

@wantsui wantsui commented Nov 11, 2025

What does this PR do?

Uses the new tag normalization logic that was copied from the Trace Agent for headers.

Motivation:

While working on #5033, it was noticed that the current normalization logic in dd-trace-rb is missing some of the logic from https://github.com/DataDog/datadog-agent/blob/45799c842bbd216bcda208737f9f11cade6fdd95/pkg/trace/traceutil/normalize.go#L131 , specifically around:

  • character limit truncation after 200 characters
  • consecutive _ are merged
  • if the first letter is not a letter, look for the next first letter since tags have to start with a letter

Change log entry

feat: swap out the existing headers normalization logic with the tag normalizer

Additional Notes:

I am not sure if we consider this to be a bug or a missing feature, but note that with this new logic, some of the headers results are going to be empty strings ie: "", which can be seen in the tests below.

How to test the change?

I've been using:

bundle exec rspec spec/datadog/tracing/metadata/ext_spec.rb

@wantsui wantsui requested a review from marcotc November 11, 2025 22:18
@github-actions
Copy link

github-actions bot commented Nov 11, 2025

👋 Hey @DataDog/ruby-guild, please fill "Change log entry" section in the pull request description.

If changes need to be present in CHANGELOG.md you can state it this way

**Change log entry**

Yes. A brief summary to be placed into the CHANGELOG.md

(possible answers Yes/Yep/Yeah)

Or you can opt out like that

**Change log entry**

None.

(possible answers No/Nope/None)

Visited at: 2025-11-12 16:20:11 UTC

Comment on lines 28 to 40
it 'preserves them' do
is_expected.to eq(tag)
is_expected.to eq("")
end
end

context 'with unsupported characters' do
let(:tag) { "\\ \t!@?" }

it 'replaces each with an underscore' do
is_expected.to eq('_' * tag.size)
# turns into an empty string because in a tag, the first character must be a letter
is_expected.to eq('')
end
end
Copy link
Member

Choose a reason for hiding this comment

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

When changing the logic -- please update the test description as well! It'd be quite confusing to have a test saying "it replaces each with an underscore" that actually is not true :P

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh! good catch, I'll use a better description for this!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I updated the description but open to feedback on the wording !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants