From f25943a0606c763b410f0b39a601cb2a3d542d37 Mon Sep 17 00:00:00 2001 From: Marc Pichler Date: Wed, 10 Apr 2024 13:17:42 +0200 Subject: [PATCH] feat(sdk-trace-base): log resource attributes in ConsoleSpanExporter (#4605) * feat(sdk-trace-base): log resoruce attributes in ConsoleSpanExporter * fixup! feat(sdk-trace-base): log resoruce attributes in ConsoleSpanExporter --- CHANGELOG.md | 2 ++ .../src/export/ConsoleSpanExporter.ts | 3 +++ .../test/common/export/ConsoleSpanExporter.test.ts | 1 + 3 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c3d6bfe7a..8e1ec010f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/ ### :rocket: (Enhancement) +feat(sdk-trace-base): log resource attributes in ConsoleSpanExporter [#4605](https://github.com/open-telemetry/opentelemetry-js/pull/4605) @pichlermarc + ### :bug: (Bug Fix) * fix(sdk-trace-web): fix invalid timings in span events [#4486](https://github.com/open-telemetry/opentelemetry-js/pull/4486) @Abinet18 diff --git a/packages/opentelemetry-sdk-trace-base/src/export/ConsoleSpanExporter.ts b/packages/opentelemetry-sdk-trace-base/src/export/ConsoleSpanExporter.ts index 596b3cefd3..dcca6d23bf 100644 --- a/packages/opentelemetry-sdk-trace-base/src/export/ConsoleSpanExporter.ts +++ b/packages/opentelemetry-sdk-trace-base/src/export/ConsoleSpanExporter.ts @@ -62,6 +62,9 @@ export class ConsoleSpanExporter implements SpanExporter { */ private _exportInfo(span: ReadableSpan) { return { + resource: { + attributes: span.resource.attributes, + }, traceId: span.spanContext().traceId, parentId: span.parentSpanId, traceState: span.spanContext().traceState?.serialize(), diff --git a/packages/opentelemetry-sdk-trace-base/test/common/export/ConsoleSpanExporter.test.ts b/packages/opentelemetry-sdk-trace-base/test/common/export/ConsoleSpanExporter.test.ts index d005a2f803..ab50d26b57 100644 --- a/packages/opentelemetry-sdk-trace-base/test/common/export/ConsoleSpanExporter.test.ts +++ b/packages/opentelemetry-sdk-trace-base/test/common/export/ConsoleSpanExporter.test.ts @@ -84,6 +84,7 @@ describe('ConsoleSpanExporter', () => { 'links', 'name', 'parentId', + 'resource', 'status', 'timestamp', 'traceId',