-
Notifications
You must be signed in to change notification settings - Fork 780
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
[prototype] feat(sdk-trace): add option to opt-out from merging the resource with Resource.default() #4617
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4617 +/- ##
==========================================
+ Coverage 93.39% 93.93% +0.53%
==========================================
Files 46 310 +264
Lines 712 8150 +7438
Branches 120 1639 +1519
==========================================
+ Hits 665 7656 +6991
- Misses 47 494 +447
|
Some notes, thinking out loud. How to create NodeSDK without getting Resource.default() merged in? // - Option 1: If we had to do it all over again it would be: If you explicitly
// pass in a `resource` then `.default()` is NOT used.
// Cons: Breaks backward compat. NodeSDK *is* pre-1.0, so we *could*, but
// probably don't want to until a major version bump.
const sdk = new NodeSDK({ resource: new Resource({foo: 'bar'}) }); // no defaults
const sdk = new NodeSDK({ resource: Resource.empty() }); // no defaults
const sdk = new NodeSDK({ resource: Resource.default() }); // yes defaults
const sdk = new NodeSDK(); // yes defaults
// - Option 2: Boolean option to say not to merge defaults.
// Defaults to always merge with Resource.default() for now.
//
// Could consider later (for SDK 2.0?) changing `mergeResourceWithDefaults`
// to a tri-state: true, false, or unspecified. Unspecified means it
// depends on whether `resource` is given. Eventually then the behaviour
// would be as in Option 1, with the option to explicitly keep it stable
// by specifying `mergeResourceWithDefaults`.
const sdk = new NodeSDK({ mergeResourceWithDefaults: false }); // no defaults |
This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
@pichlermarc Interested in adding a doc section for this in the sdk-node/README.md and then taking this out of draft? See discussion at #4930 |
1eb145d
to
9e44234
Compare
@trentm sorry for letting this sit for so long. I'm picking this up again. I don't have good answers to these questions yet but I'll comment here and will take it out of draft once I figured out what's best for NodeSDK. When we merge this I'll also follow up on the Maybe for now we just allow the same flag as proposed in the NodeSDK for this PR. |
The spec states that
However, we merge with
Resource.default()
regardless of if another resource was explicitly specified or not.This leaves us with a difficult choice:
Resource.default()
- this would likely break telemetry for users that rely on our non spec-compliant behavior of merging all the time, resource attributes that used to be there, would not be there anymore. (I'm not in favor of this)OTEL_NODE_MERGE_DEFAULT_RESOURCE
or similar).