Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core)!: remove deprecated InstrumentationLibrary #5308

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ For semantic convention package changes, see the [semconv CHANGELOG](packages/se
* refactor(sdk-trace-base)!: remove `new Span` constructor in favor of `Tracer.startSpan` API [#5048](https://github.com/open-telemetry/opentelemetry-js/pull/5048) @david-luna
* refactor(sdk-trace-base)!: remove `BasicTracerProvider.addSpanProcessor` API in favor of constructor options. [#5134](https://github.com/open-telemetry/opentelemetry-js/pull/5134) @david-luna
* refactor(sdk-trace-base)!: make `resource` property private in `BasicTracerProvider` and remove `getActiveSpanProcessor` API. [#5192](https://github.com/open-telemetry/opentelemetry-js/pull/5192) @david-luna
* feat(core)!: remove deprecated type `InstrumentationLibrary` [#5308](https://github.com/open-telemetry/opentelemetry-js/pull/5308) @pichlermarc
* (user-facing): please use equivalent type `InstrumentationScope` instead
* feat(sdk-trace-base)!: replace usages fo `InstrumentationLibrary` with `InstrumentationScope` [#5308](https://github.com/open-telemetry/opentelemetry-js/pull/5308) @pichlermarc
* (user-facing) rename `Tracer.instrumentationLibrary` -> `Tracer.instrumentationScope`
* (user-facing) rename `ReadableSpan.instrumentationLibrary` -> `ReadableSpan.instrumentationScope`
* also renames the property in implementations of `ReadableSpan`
* feat(exporter-jaeger): use `ReadableSpan.instrumentationScope` over `ReadableSpan.instrumentationLibrary` [#5308](https://github.com/open-telemetry/opentelemetry-js/pull/5308) @pichlermarc
* feat(exporter-zipkin): use `ReadableSpan.instrumentationScope` over `ReadableSpan.instrumentationLibrary` [#5308](https://github.com/open-telemetry/opentelemetry-js/pull/5308) @pichlermarc

### :rocket: (Enhancement)

Expand Down
24 changes: 11 additions & 13 deletions experimental/packages/otlp-transformer/src/trace/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,22 @@ export function createExportTraceServiceRequest(
function createResourceMap(readableSpans: ReadableSpan[]) {
const resourceMap: Map<IResource, Map<string, ReadableSpan[]>> = new Map();
for (const record of readableSpans) {
let ilmMap = resourceMap.get(record.resource);
let ilsMap = resourceMap.get(record.resource);

if (!ilmMap) {
ilmMap = new Map();
resourceMap.set(record.resource, ilmMap);
if (!ilsMap) {
ilsMap = new Map();
resourceMap.set(record.resource, ilsMap);
}

// TODO this is duplicated in basic tracer. Consolidate on a common helper in core
const instrumentationLibraryKey = `${record.instrumentationLibrary.name}@${
record.instrumentationLibrary.version || ''
}:${record.instrumentationLibrary.schemaUrl || ''}`;
let records = ilmMap.get(instrumentationLibraryKey);
const instrumentationScopeKey = `${record.instrumentationScope.name}@${
record.instrumentationScope.version || ''
}:${record.instrumentationScope.schemaUrl || ''}`;
let records = ilsMap.get(instrumentationScopeKey);

if (!records) {
records = [];
ilmMap.set(instrumentationLibraryKey, records);
ilsMap.set(instrumentationScopeKey, records);
}

records.push(record);
Expand Down Expand Up @@ -160,11 +160,9 @@ function spanRecordsToResourceSpans(
);

scopeResourceSpans.push({
scope: createInstrumentationScope(
scopeSpans[0].instrumentationLibrary
),
scope: createInstrumentationScope(scopeSpans[0].instrumentationScope),
spans: spans,
schemaUrl: scopeSpans[0].instrumentationLibrary.schemaUrl,
schemaUrl: scopeSpans[0].instrumentationScope.schemaUrl,
});
}
ilmEntry = ilmIterator.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ describe('Trace', () => {
},
},
],
instrumentationLibrary: {
instrumentationScope: {
name: 'myLib',
version: '0.1.0',
schemaUrl: 'http://url.to.schema',
Expand Down
12 changes: 0 additions & 12 deletions packages/opentelemetry-core/src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,6 @@ export interface ShimWrapped extends Function {
__original: Function;
}

/**
* An instrumentation library consists of the name and optional version
* used to obtain a tracer or meter from a provider. This metadata is made
* available on ReadableSpan and MetricRecord for use by the export pipeline.
* @deprecated Use {@link InstrumentationScope} instead.
*/
export interface InstrumentationLibrary {
readonly name: string;
readonly version?: string;
readonly schemaUrl?: string;
}

/**
* An instrumentation scope consists of the name and optional version
* used to obtain a tracer or meter from a provider. This metadata is made
Expand Down
1 change: 0 additions & 1 deletion packages/opentelemetry-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export {
} from './common/time';
export {
ErrorHandler,
InstrumentationLibrary,
InstrumentationScope,
ShimWrapped,
TimeOriginLegacy,
Expand Down
6 changes: 3 additions & 3 deletions packages/opentelemetry-exporter-jaeger/src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ export function spanToThrift(span: ReadableSpan): ThriftSpan {
})
);

if (span.instrumentationLibrary) {
if (span.instrumentationScope) {
tags.push({
key: 'otel.library.name',
value: toTagValue(span.instrumentationLibrary.name),
value: toTagValue(span.instrumentationScope.name),
});
tags.push({
key: 'otel.library.version',
value: toTagValue(span.instrumentationLibrary.version),
value: toTagValue(span.instrumentationScope.version),
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('JaegerExporter', () => {
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: 'opentelemetry',
}),
instrumentationLibrary: {
instrumentationScope: {
name: 'default',
version: '0.0.1',
},
Expand Down
10 changes: 5 additions & 5 deletions packages/opentelemetry-exporter-jaeger/test/transform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('transform', () => {
version: 1,
cost: 112.12,
}),
instrumentationLibrary: {
instrumentationScope: {
name: 'default',
version: '0.0.1',
},
Expand Down Expand Up @@ -178,7 +178,7 @@ describe('transform', () => {
events: [],
duration: [32, 800000000],
resource: Resource.empty(),
instrumentationLibrary: {
instrumentationScope: {
name: 'default',
version: '0.0.1',
},
Expand Down Expand Up @@ -248,7 +248,7 @@ describe('transform', () => {
events: [],
duration: [32, 800000000],
resource: Resource.empty(),
instrumentationLibrary: {
instrumentationScope: {
name: 'default',
version: '0.0.1',
},
Expand Down Expand Up @@ -296,7 +296,7 @@ describe('transform', () => {
events: [],
duration: [32, 800000000],
resource: Resource.empty(),
instrumentationLibrary: {
instrumentationScope: {
name: 'default',
version: '0.0.1',
},
Expand Down Expand Up @@ -361,7 +361,7 @@ describe('transform', () => {
version: 1,
cost: 112.12,
}),
instrumentationLibrary: {
instrumentationScope: {
name: 'default',
version: '0.0.1',
},
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-exporter-zipkin/test/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const mockedReadableSpan: ReadableSpan = {
version: 1,
cost: 112.12,
}),
instrumentationLibrary: { name: 'default', version: '0.0.1' },
instrumentationScope: { name: 'default', version: '0.0.1' },
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function getReadableSpan() {
links: [],
events: [],
resource: Resource.empty(),
instrumentationLibrary: { name: 'default', version: '0.0.1' },
instrumentationScope: { name: 'default', version: '0.0.1' },
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
Expand Down Expand Up @@ -166,7 +166,7 @@ describe('Zipkin Exporter - node', () => {
},
],
resource: Resource.empty(),
instrumentationLibrary: { name: 'default', version: '0.0.1' },
instrumentationScope: { name: 'default', version: '0.0.1' },
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
Expand All @@ -192,7 +192,7 @@ describe('Zipkin Exporter - node', () => {
links: [],
events: [],
resource: Resource.empty(),
instrumentationLibrary: { name: 'default', version: '0.0.1' },
instrumentationScope: { name: 'default', version: '0.0.1' },
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
Expand Down Expand Up @@ -387,7 +387,7 @@ describe('Zipkin Exporter - node', () => {
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: resource_service_name,
}),
instrumentationLibrary: { name: 'default', version: '0.0.1' },
instrumentationScope: { name: 'default', version: '0.0.1' },
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
Expand All @@ -413,7 +413,7 @@ describe('Zipkin Exporter - node', () => {
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: resource_service_name_prime,
}),
instrumentationLibrary: { name: 'default', version: '0.0.1' },
instrumentationScope: { name: 'default', version: '0.0.1' },
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
Expand Down Expand Up @@ -481,7 +481,7 @@ describe('Zipkin Exporter - node', () => {
},
],
resource: Resource.empty(),
instrumentationLibrary: { name: 'default', version: '0.0.1' },
instrumentationScope: { name: 'default', version: '0.0.1' },
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
Expand All @@ -507,7 +507,7 @@ describe('Zipkin Exporter - node', () => {
links: [],
events: [],
resource: Resource.empty(),
instrumentationLibrary: { name: 'default', version: '0.0.1' },
instrumentationScope: { name: 'default', version: '0.0.1' },
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
Expand Down
8 changes: 4 additions & 4 deletions packages/opentelemetry-sdk-trace-base/src/Span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
getTimeOrigin,
hrTime,
hrTimeDuration,
InstrumentationLibrary,
InstrumentationScope,
isAttributeValue,
isTimeInput,
isTimeInputHrTime,
Expand All @@ -62,7 +62,7 @@ export type Span = APISpan & ReadableSpan;

interface SpanOptions {
resource: IResource;
scope: InstrumentationLibrary;
scope: InstrumentationScope;
context: Context;
spanContext: SpanContext;
name: string;
Expand All @@ -89,7 +89,7 @@ export class SpanImpl implements Span {
readonly events: TimedEvent[] = [];
readonly startTime: HrTime;
readonly resource: IResource;
readonly instrumentationLibrary: InstrumentationLibrary;
readonly instrumentationScope: InstrumentationScope;

private _droppedAttributesCount = 0;
private _droppedEventsCount: number = 0;
Expand Down Expand Up @@ -132,7 +132,7 @@ export class SpanImpl implements Span {
this.links = opts.links || [];
this.startTime = this._getTime(opts.startTime ?? now);
this.resource = opts.resource;
this.instrumentationLibrary = opts.scope;
this.instrumentationScope = opts.scope;

if (opts.attributes != null) {
this.setAttributes(opts.attributes);
Expand Down
10 changes: 5 additions & 5 deletions packages/opentelemetry-sdk-trace-base/src/Tracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import * as api from '@opentelemetry/api';
import {
InstrumentationLibrary,
InstrumentationScope,
sanitizeAttributes,
isTracingSuppressed,
} from '@opentelemetry/core';
Expand All @@ -37,7 +37,7 @@ export class Tracer implements api.Tracer {
private readonly _generalLimits: GeneralLimits;
private readonly _spanLimits: SpanLimits;
private readonly _idGenerator: IdGenerator;
readonly instrumentationLibrary: InstrumentationLibrary;
readonly instrumentationScope: InstrumentationScope;

private readonly _resource: IResource;
private readonly _spanProcessor: SpanProcessor;
Expand All @@ -46,7 +46,7 @@ export class Tracer implements api.Tracer {
* Constructs a new Tracer instance.
*/
constructor(
instrumentationLibrary: InstrumentationLibrary,
instrumentationScope: InstrumentationScope,
config: TracerConfig,
resource: IResource,
spanProcessor: SpanProcessor
Expand All @@ -58,7 +58,7 @@ export class Tracer implements api.Tracer {
this._idGenerator = config.idGenerator || new RandomIdGenerator();
this._resource = resource;
this._spanProcessor = spanProcessor;
this.instrumentationLibrary = instrumentationLibrary;
this.instrumentationScope = instrumentationScope;
}

/**
Expand Down Expand Up @@ -143,7 +143,7 @@ export class Tracer implements api.Tracer {

const span = new SpanImpl({
resource: this._resource,
scope: this.instrumentationLibrary,
scope: this.instrumentationScope,
context,
spanContext,
name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class ConsoleSpanExporter implements SpanExporter {
resource: {
attributes: span.resource.attributes,
},
instrumentationScope: span.instrumentationLibrary,
instrumentationScope: span.instrumentationScope,
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 @@ -23,7 +23,7 @@ import {
SpanContext,
} from '@opentelemetry/api';
import { IResource } from '@opentelemetry/resources';
import { InstrumentationLibrary } from '@opentelemetry/core';
import { InstrumentationScope } from '@opentelemetry/core';
import { TimedEvent } from '../TimedEvent';

export interface ReadableSpan {
Expand All @@ -40,7 +40,7 @@ export interface ReadableSpan {
readonly duration: HrTime;
readonly ended: boolean;
readonly resource: IResource;
readonly instrumentationLibrary: InstrumentationLibrary;
readonly instrumentationScope: InstrumentationScope;
readonly droppedAttributesCount: number;
readonly droppedEventsCount: number;
readonly droppedLinksCount: number;
Expand Down
Loading
Loading