Skip to content

Commit

Permalink
Create new resource from list
Browse files Browse the repository at this point in the history
  • Loading branch information
dyladan committed Jan 23, 2025
1 parent f13ba2c commit 15f54f0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 1 addition & 2 deletions packages/opentelemetry-resources/src/Resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ export class Resource implements IResource {
static FromAttributeList(
attributes: [string, MaybePromise<AttributeValue | undefined>][]
): Resource {
// cast required to access private fields
const res = Resource.EMPTY as Resource;
const res = new Resource({});
res._rawAttributes = attributes;
res._asyncAttributesPending =
attributes.filter(([_, val]) => isPromiseLike(val)).length > 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ describe('PeriodicExportingMetricReader', () => {
merge: sinon.stub(),
asyncAttributesPending: true, // ensure we try to await async attributes
waitForAsyncAttributes: waitForAsyncAttributesStub, // resolve when awaited
getRawAttributes: () => [],
},
scopeMetrics: scopeMetrics,
};
Expand Down Expand Up @@ -383,6 +384,7 @@ describe('PeriodicExportingMetricReader', () => {
merge: sinon.stub(),
asyncAttributesPending: true, // ensure we try to await async attributes
waitForAsyncAttributes: waitForAsyncAttributesStub, // resolve when awaited
getRawAttributes: () => [],
},
scopeMetrics: scopeMetrics,
};
Expand Down Expand Up @@ -428,6 +430,7 @@ describe('PeriodicExportingMetricReader', () => {
merge: sinon.stub(),
asyncAttributesPending: true, // ensure we try to await async attributes
waitForAsyncAttributes: waitForAsyncAttributesStub, // reject when awaited
getRawAttributes: () => [],
},
scopeMetrics: [],
};
Expand Down

0 comments on commit 15f54f0

Please sign in to comment.