Skip to content

Commit

Permalink
feat(sdk-trace): add option to opt-out from merging the resource with…
Browse files Browse the repository at this point in the history
… Resource.default()
  • Loading branch information
pichlermarc committed Apr 9, 2024
1 parent c046867 commit 1eb145d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ export class BasicTracerProvider implements TracerProvider {
reconfigureLimits(config)
);
this.resource = mergedConfig.resource ?? Resource.empty();
this.resource = Resource.default().merge(this.resource);

if (mergedConfig.mergeResourceWithDefaults) {
this.resource = Resource.default().merge(this.resource);
}

this._config = Object.assign({}, mergedConfig, {
resource: this.resource,
});
Expand Down
1 change: 1 addition & 0 deletions packages/opentelemetry-sdk-trace-base/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export function loadDefaultConfig() {
attributePerLinkCountLimit:
getEnv().OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT,
},
mergeResourceWithDefaults: true,
};
}

Expand Down
6 changes: 6 additions & 0 deletions packages/opentelemetry-sdk-trace-base/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ export interface TracerConfig {
/** Span Limits */
spanLimits?: SpanLimits;

/**
* Merge resource with {@link Resource.default()}?
* Default: {@code true}
**/
mergeResourceWithDefaults?: boolean;

/** Resource associated with trace telemetry */
resource?: IResource;

Expand Down

0 comments on commit 1eb145d

Please sign in to comment.