Skip to content

Commit 4c609aa

Browse files
srikanthccvdyladanobecnyvmarchaud
authored
fix: specification compliant resource collision precedence (#1975)
Co-authored-by: Daniel Dyla <[email protected]> Co-authored-by: Bartlomiej Obecny <[email protected]> Co-authored-by: Valentin Marchaud <[email protected]>
1 parent 3588601 commit 4c609aa

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,12 @@ To request automatic tracing support for a module not on this list, please [file
245245

246246
## Upgrade guidelines
247247

248+
### 0.17.0 to 0.18.0
249+
250+
[PR-1975](https://github.com/open-telemetry/opentelemetry-js/pull/1975)
251+
252+
- Breaking change - The resulting resource MUST have all attributes that are on any of the two input resources. If a key exists on both the old and updating resource, the value of the updating resource MUST be picked - previously it was opposite.
253+
248254
### 0.16.0 to 0.17.0
249255

250256
[PR-1880](https://github.com/open-telemetry/opentelemetry-js/pull/1880) feat(diag-logger): introduce a new global level api.diag for internal diagnostic logging

packages/opentelemetry-resources/src/Resource.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class Resource {
5454

5555
/**
5656
* Returns a new, merged {@link Resource} by merging the current Resource
57-
* with the other Resource. In case of a collision, current Resource takes
57+
* with the other Resource. In case of a collision, other Resource takes
5858
* precedence.
5959
*
6060
* @param other the Resource that will be merged with this.
@@ -66,8 +66,8 @@ export class Resource {
6666
// SpanAttributes from resource overwrite attributes from other resource.
6767
const mergedAttributes = Object.assign(
6868
{},
69-
other.attributes,
70-
this.attributes
69+
this.attributes,
70+
other.attributes
7171
);
7272
return new Resource(mergedAttributes);
7373
}

packages/opentelemetry-resources/test/Resource.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe('Resource', () => {
5050

5151
it('should return merged resource when collision in attributes', () => {
5252
const expectedResource = new Resource({
53-
'k8s.io/container/name': 'c1',
53+
'k8s.io/container/name': 'c2',
5454
'k8s.io/namespace/name': 'default',
5555
'k8s.io/pod/name': 'pod-xyz-123',
5656
'k8s.io/location': 'location1',

0 commit comments

Comments
 (0)