Skip to content

Commit

Permalink
fix: specification compliant resource collision precedence (#1975)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>
Co-authored-by: Bartlomiej Obecny <bobecny@gmail.com>
Co-authored-by: Valentin Marchaud <contact@vmarchaud.fr>
  • Loading branch information
4 people authored Mar 2, 2021
1 parent 3588601 commit 4c609aa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ To request automatic tracing support for a module not on this list, please [file

## Upgrade guidelines

### 0.17.0 to 0.18.0

[PR-1975](https://github.com/open-telemetry/opentelemetry-js/pull/1975)

- 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.

### 0.16.0 to 0.17.0

[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
Expand Down
6 changes: 3 additions & 3 deletions packages/opentelemetry-resources/src/Resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class Resource {

/**
* Returns a new, merged {@link Resource} by merging the current Resource
* with the other Resource. In case of a collision, current Resource takes
* with the other Resource. In case of a collision, other Resource takes
* precedence.
*
* @param other the Resource that will be merged with this.
Expand All @@ -66,8 +66,8 @@ export class Resource {
// SpanAttributes from resource overwrite attributes from other resource.
const mergedAttributes = Object.assign(
{},
other.attributes,
this.attributes
this.attributes,
other.attributes
);
return new Resource(mergedAttributes);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-resources/test/Resource.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('Resource', () => {

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

0 comments on commit 4c609aa

Please sign in to comment.