From 039db0b3fc0dd56b72a13195db9865186aed3288 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Th=C3=A9riault?= <113933910+raphael-theriault-swi@users.noreply.github.com> Date: Thu, 10 Oct 2024 01:01:10 -0700 Subject: [PATCH 1/2] fix(exporter-logs-otlp-proto): Use correct config type in constructor (#5058) --- experimental/CHANGELOG.md | 1 + .../src/platform/node/OTLPLogExporter.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) 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, From 6be903a90225431def0f554d1fbac315e329de9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Zi=C3=B3=C5=82kowski?= Date: Fri, 11 Oct 2024 22:59:41 +0200 Subject: [PATCH 2/2] fix(resources): wait for async attributes for detecting resources (#4687) Co-authored-by: David Luna --- CHANGELOG.md | 1 + packages/opentelemetry-resources/src/detect-resources.ts | 1 + .../opentelemetry-resources/test/detect-resources.test.ts | 6 +++++- 3 files changed, 7 insertions(+), 1 deletion(-) 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/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', }); });