Skip to content
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

Implement Config Consistency #4725

Merged
merged 30 commits into from
Oct 22, 2024

Conversation

khanayan123
Copy link
Collaborator

@khanayan123 khanayan123 commented Sep 25, 2024

What does this PR do?

This pull request updates configuration defaults and behaviors to ensure alignment with standardized definitions across SDKs

changes:

  • Introduce support for DD_TRACE_<INTEGRATION>_ENABLED, allowing the enablement or disablement of specific integrations based on the provided integration name.
  • Set the default value for DD_TRACE_RATE_LIMIT to 100.
  • Add DD_TRACE_ENABLED to the configuration object to enable transmission via telemetry.
  • Ensure that leading and trailing white spaces are trimmed from items in DD_TRACE_HEADER_TAGS.
  • Update the behavior of the version tag such that when a span is created with a service name different from the global service name, it will not inherit the global version value.
  • Update configuration settings listed in the RFC to send telemetry using their respective environment variable names

Motivation

The changes are driven by the need to meet the requirements outlined in the configuration consistency RFC

Additional Notes

This PR was tested against the system tests here

Copy link

github-actions bot commented Sep 25, 2024

Overall package size

Self size: 7.55 MB
Deduped: 62.29 MB
No deduping: 62.57 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | @datadog/native-appsec | 8.1.1 | 18.67 MB | 18.68 MB | | @datadog/native-iast-taint-tracking | 3.1.0 | 12.27 MB | 12.28 MB | | @datadog/pprof | 5.3.0 | 9.85 MB | 10.22 MB | | protobufjs | 7.2.5 | 2.77 MB | 5.16 MB | | @datadog/native-iast-rewriter | 2.5.0 | 2.51 MB | 2.59 MB | | @opentelemetry/core | 1.14.0 | 872.87 kB | 1.47 MB | | @datadog/native-metrics | 2.0.0 | 898.77 kB | 1.3 MB | | @opentelemetry/api | 1.8.0 | 1.21 MB | 1.21 MB | | import-in-the-middle | 1.11.2 | 112.74 kB | 826.22 kB | | msgpack-lite | 0.1.26 | 201.16 kB | 281.59 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | pprof-format | 2.1.0 | 111.69 kB | 111.69 kB | | @datadog/sketches-js | 2.1.0 | 109.9 kB | 109.9 kB | | semver | 7.6.3 | 95.82 kB | 95.82 kB | | lodash.sortby | 4.7.0 | 75.76 kB | 75.76 kB | | lru-cache | 7.14.0 | 74.95 kB | 74.95 kB | | ignore | 5.3.1 | 51.46 kB | 51.46 kB | | int64-buffer | 0.1.10 | 49.18 kB | 49.18 kB | | shell-quote | 1.8.1 | 44.96 kB | 44.96 kB | | istanbul-lib-coverage | 3.2.0 | 29.34 kB | 29.34 kB | | rfdc | 1.3.1 | 25.21 kB | 25.21 kB | | tlhunter-sorted-set | 0.1.0 | 24.94 kB | 24.94 kB | | limiter | 1.1.5 | 23.17 kB | 23.17 kB | | dc-polyfill | 0.1.4 | 23.1 kB | 23.1 kB | | retry | 0.13.1 | 18.85 kB | 18.85 kB | | jest-docblock | 29.7.0 | 8.99 kB | 12.76 kB | | crypto-randomuuid | 1.0.0 | 11.18 kB | 11.18 kB | | koalas | 1.0.2 | 6.47 kB | 6.47 kB | | path-to-regexp | 0.1.10 | 6.38 kB | 6.38 kB | | module-details-from-path | 1.0.3 | 4.47 kB | 4.47 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@pr-commenter
Copy link

pr-commenter bot commented Sep 26, 2024

Benchmarks

Benchmark execution time: 2024-10-18 19:50:26

Comparing candidate commit 732d9d1 in PR branch khanayan123/implement-config-consistency with baseline commit 7f93d36 in branch master.

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

Copy link

codecov bot commented Sep 30, 2024

Codecov Report

Attention: Patch coverage is 72.72727% with 3 lines in your changes missing coverage. Please review.

Project coverage is 79.91%. Comparing base (bb0bbcc) to head (040d6bc).
Report is 27 commits behind head on master.

Files with missing lines Patch % Lines
packages/dd-trace/src/config.js 66.66% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #4725       +/-   ##
===========================================
- Coverage   91.42%   79.91%   -11.51%     
===========================================
  Files         112      303      +191     
  Lines        3475    13096     +9621     
  Branches       33       33               
===========================================
+ Hits         3177    10466     +7289     
- Misses        298     2630     +2332     
Flag Coverage Δ
?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@khanayan123 khanayan123 changed the title initial commit upstream Implement Config Consistency Oct 2, 2024
@khanayan123 khanayan123 marked this pull request as ready for review October 2, 2024 01:49
@khanayan123 khanayan123 requested review from a team as code owners October 2, 2024 01:49
mtoffl01
mtoffl01 previously approved these changes Oct 3, 2024

// edge case handling, if a user manually sets a service name different from the tracer's service name
// then we need to ensure that the version is set to undefined
// in every other scenario version should be set to the tracer's version
Copy link

Choose a reason for hiding this comment

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

I assume by "manually" you mean when creating a custom span and passing a service name != global service name?
Does this apply to integration service names that differ from global service name (since it's not "manual" but does have the "different service name" effect)

Copy link
Member

Choose a reason for hiding this comment

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

@khanayan123 the comment says that we need to do something but why do we need to do it?

Copy link
Collaborator Author

@khanayan123 khanayan123 Oct 7, 2024

Choose a reason for hiding this comment

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

Updated the comment, the reason we need to do it is to align with the unified service tagging spec https://docs.datadoghq.com/getting_started/tagging/unified_service_tagging/?tab=kubernetes

DD_VERSION (version) Environment Variable Name: DD_VERSION Behavior: Adds version tag to all spans that have the same service name as the default service name (aka DD_SERVICE). Spans with a different service name do not get this tag.

Configure spans with DD_VERSION to add version to all spans that fall under the service that belongs to the tracer (generally DD_SERVICE). This means that if your service creates spans with the name of an external service, those spans do not receive version as a tag.

Adds version tag to all spans that have the same service name as the default service name (aka DD_SERVICE). Spans with a different service name do not get this tag.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

other SDKs such as golang already do this

@@ -245,6 +245,39 @@ describe('Tracer', () => {
expect(span.addTags).to.have.been.calledWith(fields.tags)
})

it('If a user sets spans service name differs from the tracers, ensure the spans version is undefined.', () => {
Copy link

Choose a reason for hiding this comment

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

Suggested change
it('If a user sets spans service name differs from the tracers, ensure the spans version is undefined.', () => {
it('If span is granted a service name that differs from the global service name, ensure span's `version` tag is undefined.', () => {

Copy link
Collaborator

@watson watson left a comment

Choose a reason for hiding this comment

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

Since this PR changes default values, one could argue it's a breaking change and should be labeled with semver-major. However, to be pragmatic about it, I think it should just be labeled it with semver-minor (currently it's labeled with semver-patch).

@khanayan123 khanayan123 force-pushed the khanayan123/implement-config-consistency branch from 040d6bc to 1d50a50 Compare October 7, 2024 20:14
// Check for DD_TRACE_<INTEGRATION>_ENABLED environment variables
for (const [key, value] of Object.entries(process.env)) {
const match = key.match(/^DD_TRACE_(.+)_ENABLED$/)
if (match && value.toLowerCase() === 'false') {
Copy link
Member

Choose a reason for hiding this comment

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

In practice customers use both false and 0

@@ -1144,7 +1147,16 @@ class Config {
}

if (typeof value === 'string') {
value = value.split(',')
// Split by commas and trim each item in header tags mapping
if (name === 'headerTags') {
Copy link
Member

Choose a reason for hiding this comment

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

Is there any way to do this in a way that we don't put hyper-specific code, like this header tags check, in a common generic code path?

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 it's fair to remove white spaces around all values in a mapping, going to remove that check for headerTags


// As per unified service tagging spec if a span is created with a service name different from the global
// service name it will not inherit the global version value
if (options?.tags?.service && options?.tags?.service !== this._service) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (options?.tags?.service && options?.tags?.service !== this._service) {
if (options?.tags?.service && options.tags.service !== this._service) {

Copy link
Member

Choose a reason for hiding this comment

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

Since at this point we already know options.tags is an object

@@ -546,7 +547,7 @@ class Config {
this._setValue(defaults, 'tracePropagationStyle.otelPropagators', false)
this._setValue(defaults, 'tracing', true)
this._setValue(defaults, 'url', undefined)
this._setValue(defaults, 'version', pkg.version)
Copy link
Member

Choose a reason for hiding this comment

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

Is this a breaking change? What implications does it come with?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Depends on our definition of breaking change, this shouldn't be a breaking change in the sense that it's part of the UST definition which with this change we would be adhering more closer to, so one could also consider it a patch.

https://docs.datadoghq.com/getting_started/tagging/unified_service_tagging

The implications of this is that unless a 'version' is manually set users will not automatically have version set on their traces, the only caveat being an edge case for dsm to maintain their functionality.

Copy link
Member

Choose a reason for hiding this comment

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

Revert this and I think we can land it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

reverted

@khanayan123 khanayan123 merged commit 1522a48 into master Oct 22, 2024
198 checks passed
@khanayan123 khanayan123 deleted the khanayan123/implement-config-consistency branch October 22, 2024 01:09
rochdev pushed a commit that referenced this pull request Oct 31, 2024
* standardize configurations
rochdev pushed a commit that referenced this pull request Oct 31, 2024
* standardize configurations
rochdev pushed a commit that referenced this pull request Oct 31, 2024
* standardize configurations
rochdev pushed a commit that referenced this pull request Nov 6, 2024
* standardize configurations
rochdev pushed a commit that referenced this pull request Nov 6, 2024
* standardize configurations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants