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',