Skip to content

[processor/datadogsemantics] Make defaults explicit and add test #39596

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

IbraheemA
Copy link
Contributor

Description

Explicitly set defaults for each field - whatever the Datadog backend would populate if you send the field as blank; e.g., if we send a blank env, it would show up in the UI as the string default, so we should surface that to the user with this processor. Also, populate datadog.* fields even if they would be blank (this includes overriding them even if the result would be blank if the overrideIncomingDatadogFields option is set, for consistency)

Link to tracking issue

Fixes

Testing

Documentation

@IbraheemA IbraheemA requested review from songy23, mx-psi and a team as code owners April 23, 2025 20:28
@songy23 songy23 added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Apr 23, 2025
Copy link
Contributor

@jackgopack4 jackgopack4 left a comment

Choose a reason for hiding this comment

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

I would prefer if each attribute followed the same pattern as much as possible. If there is a way you can either set service variable explicitly prior to calling GetOTelService, or leave a comment above those lines explaining what service gets set to by default, that would be appreciated

if err = tp.insertAttrIfMissingOrShouldOverride(rattr, "datadog.service", service); err != nil {
return ptrace.Traces{}, err
}
if err = tp.insertAttrIfMissingOrShouldOverride(rattr, "datadog.service", traceutil.GetOTelService(otelres, true)); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

am I understanding correctly that this change, if otelres is blank, then traceutil.GetOTelService will return "otlpresourcenoservicename" and that's what datadog.service will be set to?
https://github.com/DataDog/datadog-agent/blob/0d44e61fa623ef2572ba8d7fbe30e2632540d8aa/pkg/trace/traceutil/otel_util.go#L276
Worth adding a link to the function or noting the default setting in the comments here?

Copy link
Contributor

Choose a reason for hiding this comment

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

alternatively, you could always make that an exportable constant in pkg/trace/traceutil and set service equal to the value before calling GetOTelService.

I just think we should try to have the pattern for each attribute follow a similar pattern to the maximum extent practical, so the code is easy to understand later

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, I added a comment explaining the default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
processor/datadogsemantics Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants