diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ad9ff304de..7194d8ba174 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -110,6 +110,7 @@ For semantic convention package changes, see the [semconv CHANGELOG](packages/se * fix(resources): prevent circular import (resource -> detector -> resource -> ...) [#4653](https://github.com/open-telemetry/opentelemetry-js/pull/4653) @pichlermarc * fixes a circular import warning which would appear in rollup when bundling `@opentelemetry/resources` * fix(exporter-metrics-otlp-grpc): add explicit otlp-exporter-base dependency to exporter-metrics-otlp-grpc [#4678](https://github.com/open-telemetry/opentelemetry-js/pull/4678) @AkselAllas +* fix(resources) wait for async attributes for detecting resources [#4687](https://github.com/open-telemetry/opentelemetry-js/pull/4687) @ziolekjj ## 1.24.0 diff --git a/experimental/CHANGELOG.md b/experimental/CHANGELOG.md index 37252e92ccc..d7b1415697d 100644 --- a/experimental/CHANGELOG.md +++ b/experimental/CHANGELOG.md @@ -47,6 +47,7 @@ All notable changes to experimental packages in this project will be documented * `configureExporterTimeout` * `invalidTimeout` * fix(sdk-node): use warn instead of error on unknown OTEL_NODE_RESOURCE_DETECTORS values [#5034](https://github.com/open-telemetry/opentelemetry-js/pull/5034) +* fix(exporter-logs-otlp-proto): Use correct config type in Node constructor ### :books: (Refine Doc) diff --git a/experimental/packages/exporter-logs-otlp-proto/src/platform/node/OTLPLogExporter.ts b/experimental/packages/exporter-logs-otlp-proto/src/platform/node/OTLPLogExporter.ts index 828a11cbc6d..d897208389e 100644 --- a/experimental/packages/exporter-logs-otlp-proto/src/platform/node/OTLPLogExporter.ts +++ b/experimental/packages/exporter-logs-otlp-proto/src/platform/node/OTLPLogExporter.ts @@ -15,8 +15,8 @@ */ import { - OTLPExporterConfigBase, OTLPExporterNodeBase, + OTLPExporterNodeConfigBase, } from '@opentelemetry/otlp-exporter-base'; import { IExportLogsServiceResponse, @@ -37,7 +37,7 @@ export class OTLPLogExporter extends OTLPExporterNodeBase implements LogRecordExporter { - constructor(config: OTLPExporterConfigBase = {}) { + constructor(config: OTLPExporterNodeConfigBase = {}) { super( config, ProtobufLogsSerializer, diff --git a/packages/opentelemetry-resources/src/detect-resources.ts b/packages/opentelemetry-resources/src/detect-resources.ts index 4fa477a4f81..0bfa13cac8b 100644 --- a/packages/opentelemetry-resources/src/detect-resources.ts +++ b/packages/opentelemetry-resources/src/detect-resources.ts @@ -70,6 +70,7 @@ export const detectResourcesSync = ( if (isPromiseLike(resourceOrPromise)) { const createPromise = async () => { const resolvedResource = await resourceOrPromise; + await resolvedResource.waitForAsyncAttributes?.(); return resolvedResource.attributes; }; resource = new Resource({}, createPromise()); diff --git a/packages/opentelemetry-resources/test/detect-resources.test.ts b/packages/opentelemetry-resources/test/detect-resources.test.ts index 0db97057db9..7c3b1a212c9 100644 --- a/packages/opentelemetry-resources/test/detect-resources.test.ts +++ b/packages/opentelemetry-resources/test/detect-resources.test.ts @@ -28,7 +28,10 @@ describe('detectResourcesSync', () => { it('handles resource detectors which return Promise', async () => { const detector: Detector = { async detect() { - return new Resource({ sync: 'fromsync' }); + return new Resource( + { sync: 'fromsync' }, + Promise.resolve().then(() => ({ async: 'fromasync' })) + ); }, }; const resource = detectResourcesSync({ @@ -38,6 +41,7 @@ describe('detectResourcesSync', () => { await resource.waitForAsyncAttributes?.(); assert.deepStrictEqual(resource.attributes, { sync: 'fromsync', + async: 'fromasync', }); });