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

Resource: remove unnecessary diagnostic when accessing attributes #5119

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ For semantic convention package changes, see the [semconv CHANGELOG](packages/se

### :rocket: (Enhancement)

* fix(resources): remove diagnostic error when accessing attributes while async attributes are resolving. [#5119](https://github.com/open-telemetry/opentelemetry-js/pull/5119) @seemk

### :bug: (Bug Fix)

### :books: (Refine Doc)
Expand Down
6 changes: 0 additions & 6 deletions packages/opentelemetry-resources/src/Resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@ export class Resource implements IResource {
}

get attributes(): ResourceAttributes {
if (this.asyncAttributesPending) {
diag.error(
'Accessing resource attributes before async attributes settled'
);
}

return this._attributes ?? {};
}

Expand Down
18 changes: 0 additions & 18 deletions packages/opentelemetry-resources/test/Resource.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,6 @@ describe('Resource', () => {
assert.strictEqual(resource.attributes['custom.boolean'], true);
});

it('should log when accessing attributes before async attributes promise has settled', () => {
const debugStub = sinon.spy(diag, 'error');
const resource = new Resource(
{},
new Promise(resolve => {
setTimeout(resolve, 1);
})
);

resource.attributes;

assert.ok(
debugStub.calledWithMatch(
'Accessing resource attributes before async attributes settled'
)
);
});

describe('.empty()', () => {
it('should return an empty resource (except required service name)', () => {
const resource = Resource.empty();
Expand Down