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

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

Copy link
Contributor

github-actions bot commented May 9, 2025

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label May 9, 2025
@mx-psi mx-psi requested a review from jackgopack4 May 9, 2025 09:32
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.

thanks for clarifying. everything makes sense to me. sorry for the delay.

@github-actions github-actions bot removed the Stale label May 10, 2025
@mx-psi mx-psi merged commit 4bc0aab into open-telemetry:main May 13, 2025
173 checks passed
@github-actions github-actions bot added this to the next release milestone May 13, 2025
johnleslie pushed a commit to johnleslie/opentelemetry-collector-contrib that referenced this pull request May 23, 2025
…n-telemetry#39596)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### 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)

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes

<!--Describe what testing was performed and which tests were added.-->
#### Testing

<!--Describe the documentation added.-->
#### Documentation

<!--Please delete paragraphs that you did not use before submitting.-->

---------

Co-authored-by: Pablo Baeyens <[email protected]>
johnleslie pushed a commit to johnleslie/opentelemetry-collector-contrib that referenced this pull request May 23, 2025
…n-telemetry#39596)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### 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)

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes

<!--Describe what testing was performed and which tests were added.-->
#### Testing

<!--Describe the documentation added.-->
#### Documentation

<!--Please delete paragraphs that you did not use before submitting.-->

---------

Co-authored-by: Pablo Baeyens <[email protected]>
dragonlord93 pushed a commit to dragonlord93/opentelemetry-collector-contrib that referenced this pull request May 23, 2025
…n-telemetry#39596)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### 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)

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes

<!--Describe what testing was performed and which tests were added.-->
#### Testing

<!--Describe the documentation added.-->
#### Documentation

<!--Please delete paragraphs that you did not use before submitting.-->

---------

Co-authored-by: Pablo Baeyens <[email protected]>
dd-jasminesun pushed a commit to DataDog/opentelemetry-collector-contrib that referenced this pull request Jun 23, 2025
…n-telemetry#39596)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### 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)

<!-- Issue number (e.g. #1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes

<!--Describe what testing was performed and which tests were added.-->
#### Testing

<!--Describe the documentation added.-->
#### Documentation

<!--Please delete paragraphs that you did not use before submitting.-->

---------

Co-authored-by: Pablo Baeyens <[email protected]>
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.

5 participants