Skip to content

Conversation

@wantsui
Copy link
Collaborator

@wantsui wantsui commented Nov 7, 2025

What does this PR do?

The goal of AIDM-253 is to add process tags to the trace payloads.

I'm creating a draft for now but I still need to research some things like:
[x] add memoization or some kind of cache to avoid looking for these values over and over when are fixed by process
[] figure out the best place to add more tests to assert on the overall behavior (right now I have a test in process_spec to assert on the values)
[x] research if Windows is part of this testing strategy -> Not supported
[x] determine how to approach server type since it's not at the process level -> Will remove in this PR and add later
[x] normalization of tags

After this gets merged, the next step is to add it for the other products.

Main tests:

bundle exec rspec spec/datadog/core/environment/process_spec.rb
bundle exec rspec spec/datadog/tracing/transport/trace_formatter_spec.rb
bundle exec rspec spec/datadog/core/normalizer_spec.rb

Motivation:

Change log entry

Add process tags to trace payloads.

Additional Notes:

How to test the change?

… This is still missing memoization and additional tests.
@github-actions github-actions bot added core Involves Datadog core libraries tracing labels Nov 7, 2025
@github-actions
Copy link

github-actions bot commented Nov 7, 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-11 18:46:13 UTC

@datadog-official
Copy link

datadog-official bot commented Nov 7, 2025

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage
Patch Coverage: 100.00%
Total Coverage: 98.44% (+0.02%)

View detailed report

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 9ad5be5 | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@wantsui wantsui added the AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos label Nov 7, 2025

def entrypoint_basedir
current_basedir = File.expand_path(File.dirname($0.to_s))
normalized_basedir = current_basedir.tr(File::SEPARATOR, '/')
Copy link
Member

Choose a reason for hiding this comment

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

This convert possible windows separator to unix, correct?

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 don't have a way to test in Windows to confirm this, but also based on the compatibility docs we don't support Windows: https://docs.datadoghq.com/tracing/trace_collection/compatibility/ruby/#supported-operating-systems?

def tag_process_tags!
return unless trace.experimental_propagate_process_tags_enabled
process_tags = Core::Environment::Process.formatted_process_tags_k1_v1
return if process_tags.empty?
Copy link
Member

Choose a reason for hiding this comment

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

This is impossible right? If so, we can remove it, as it would give us a false sense of uncertainty here.

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 think I fixed it in 8dae705 by just removing the check in process tags, but let me know if you spot issues with it!

@pr-commenter
Copy link

pr-commenter bot commented Nov 10, 2025

Benchmarks

Benchmark execution time: 2025-11-11 20:54:12

Comparing candidate commit f5ca84a in PR branch add-process-tags-to-tracing with baseline commit 4d6369e in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 44 metrics, 2 unstable metrics.

format!
expect(first_span.meta).to include('_dd.tags.process')
expect(first_span.meta['_dd.tags.process']).to eq(Datadog::Core::Environment::Process.serialized)
# TODO figure out if we need an assertion for the value, ie
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@marcotc - do you think there's value in asserting for the values of the tag? Or is the test in process_spec enough?

@github-actions
Copy link

github-actions bot commented Nov 11, 2025

Typing analysis

Note: Ignored files are excluded from the next sections.

Untyped methods

This PR introduces 5 untyped methods and 2 partially typed methods. It decreases the percentage of typed methods from 53.12% to 52.89% (-0.23%).

Untyped methods (+5-0)Introduced:
sig/datadog/core/environment/process.rbs:7
└── def self?.entrypoint_workdir: () -> untyped
sig/datadog/core/environment/process.rbs:9
└── def self?.entrypoint_type: () -> untyped
sig/datadog/core/environment/process.rbs:11
└── def self?.entrypoint_name: () -> untyped
sig/datadog/core/environment/process.rbs:13
└── def self?.entrypoint_basedir: () -> untyped
sig/datadog/core/environment/process.rbs:15
└── def self?.serialized: () -> untyped
Partially typed methods (+2-0)Introduced:
sig/datadog/core/environment/process.rbs:14
└── def self?.serialized_kv_helper: (untyped key, untyped value) -> ::String
sig/datadog/core/normalizer.rbs:5
└── def self.normalize: (untyped original_value) -> ("" | untyped)

Untyped other declarations

This PR introduces 1 untyped other declaration. It increases the percentage of typed other declarations from 66.92% to 67.05% (+0.13%).

Untyped other declarations (+1-0)Introduced:
sig/datadog/core/environment/process.rbs:5
└── @serialized: untyped

If you believe a method or an attribute is rightfully untyped or partially typed, you can add # untyped:accept to the end of the line to remove it from the stats.

@wantsui wantsui marked this pull request as ready for review November 12, 2025 15:31
@wantsui wantsui requested review from a team as code owners November 12, 2025 15:31
@wantsui wantsui requested a review from mabdinur November 12, 2025 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos core Involves Datadog core libraries tracing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants