Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/

### :rocket: (Enhancement)

* feat: print instrumentation library info with console span exporter [#4848](https://github.com/open-telemetry/opentelemetry-js/pull/4848) @blumamir

### :bug: (Bug Fix)

### :books: (Refine Doc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export class ConsoleSpanExporter implements SpanExporter {
resource: {
attributes: span.resource.attributes,
},
instrumentationLibrary: span.instrumentationLibrary,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside: Do you think we'll ever change the property to span.instrumentationScope given that the InstrumentationLibrary type is deprecated (https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-core/src/common/types.ts#L42-L63) ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should emit it with the name instrumentationScope. Updated the PR Thanks 👍

traceId: span.spanContext().traceId,
parentId: span.parentSpanId,
traceState: span.spanContext().traceState?.serialize(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ describe('ConsoleSpanExporter', () => {
new SimpleSpanProcessor(consoleExporter)
);

const tracer = basicTracerProvider.getTracer('default');
const instrumentationLibraryName = '@opentelemetry/sdk-trace-base/test';
const instrumentationLibraryVersion = '1.2.3';
const tracer = basicTracerProvider.getTracer(instrumentationLibraryName, instrumentationLibraryVersion);
const context: SpanContext = {
traceId: 'a3cda95b652f4a1592b449d5929fda1b',
spanId: '5e0c63257de34c92',
Expand All @@ -80,6 +82,7 @@ describe('ConsoleSpanExporter', () => {
'duration',
'events',
'id',
'instrumentationLibrary',
'kind',
'links',
'name',
Expand All @@ -95,6 +98,8 @@ describe('ConsoleSpanExporter', () => {
assert.ok(firstEvent.name === 'foobar');
assert.ok(consoleSpan.id === firstSpan.spanContext().spanId);
assert.ok(keys === expectedKeys, 'expectedKeys');
assert.ok(firstSpan.instrumentationLibrary.name === instrumentationLibraryName);
assert.ok(firstSpan.instrumentationLibrary.version === instrumentationLibraryVersion);

assert.ok(spyExport.calledOnce);
});
Expand Down