diff --git a/packages/opentelemetry-exporter-collector/src/transform.ts b/packages/opentelemetry-exporter-collector/src/transform.ts index 7080713ff77..ee627621591 100644 --- a/packages/opentelemetry-exporter-collector/src/transform.ts +++ b/packages/opentelemetry-exporter-collector/src/transform.ts @@ -19,12 +19,11 @@ import { Link, SpanKind, SpanStatus, - TimedEvent, TraceState, } from '@opentelemetry/api'; import * as core from '@opentelemetry/core'; import { Resource } from '@opentelemetry/resources'; -import { ReadableSpan } from '@opentelemetry/tracing'; +import { ReadableSpan, TimedEvent } from '@opentelemetry/tracing'; import { CollectorExporterBase } from './CollectorExporterBase'; import { COLLECTOR_SPAN_KIND_MAPPING, diff --git a/packages/opentelemetry-exporter-zipkin/src/transform.ts b/packages/opentelemetry-exporter-zipkin/src/transform.ts index 032227716f9..4f8e3145c69 100644 --- a/packages/opentelemetry-exporter-zipkin/src/transform.ts +++ b/packages/opentelemetry-exporter-zipkin/src/transform.ts @@ -15,7 +15,7 @@ */ import * as api from '@opentelemetry/api'; -import { ReadableSpan } from '@opentelemetry/tracing'; +import { ReadableSpan, TimedEvent } from '@opentelemetry/tracing'; import { hrTimeToMicroseconds } from '@opentelemetry/core'; import * as zipkinTypes from './types'; import { Resource } from '@opentelemetry/resources'; @@ -94,7 +94,7 @@ export function _toZipkinTags( * Converts OpenTelemetry Events to Zipkin Annotations format. */ export function _toZipkinAnnotations( - events: api.TimedEvent[] + events: TimedEvent[] ): zipkinTypes.Annotation[] { return events.map(event => ({ timestamp: hrTimeToMicroseconds(event.time), diff --git a/packages/opentelemetry-tracing/src/Span.ts b/packages/opentelemetry-tracing/src/Span.ts index bfaf77b20b9..79ab92544a4 100644 --- a/packages/opentelemetry-tracing/src/Span.ts +++ b/packages/opentelemetry-tracing/src/Span.ts @@ -26,6 +26,7 @@ import { import { Resource } from '@opentelemetry/resources'; import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; import { ReadableSpan } from './export/ReadableSpan'; +import { TimedEvent } from './TimedEvent'; import { Tracer } from './Tracer'; import { SpanProcessor } from './SpanProcessor'; import { TraceParams } from './types'; @@ -43,7 +44,7 @@ export class Span implements api.Span, ReadableSpan { readonly parentSpanId?: string; readonly attributes: api.SpanAttributes = {}; readonly links: api.Link[] = []; - readonly events: api.TimedEvent[] = []; + readonly events: TimedEvent[] = []; readonly startTime: api.HrTime; readonly resource: Resource; readonly instrumentationLibrary: InstrumentationLibrary; diff --git a/packages/opentelemetry-tracing/src/TimedEvent.ts b/packages/opentelemetry-tracing/src/TimedEvent.ts new file mode 100644 index 00000000000..93cb9b47f3f --- /dev/null +++ b/packages/opentelemetry-tracing/src/TimedEvent.ts @@ -0,0 +1,29 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { HrTime, SpanAttributes } from '@opentelemetry/api'; + +/** + * Represents a timed event. + * A timed event is an event with a timestamp. + */ +export interface TimedEvent { + time: HrTime; + /** The name of the event. */ + name: string; + /** The attributes of the event. */ + attributes?: SpanAttributes; +} diff --git a/packages/opentelemetry-tracing/src/export/ReadableSpan.ts b/packages/opentelemetry-tracing/src/export/ReadableSpan.ts index 9813965b0c8..381de674fff 100644 --- a/packages/opentelemetry-tracing/src/export/ReadableSpan.ts +++ b/packages/opentelemetry-tracing/src/export/ReadableSpan.ts @@ -21,10 +21,10 @@ import { HrTime, Link, SpanContext, - TimedEvent, } from '@opentelemetry/api'; import { Resource } from '@opentelemetry/resources'; import { InstrumentationLibrary } from '@opentelemetry/core'; +import { TimedEvent } from '../TimedEvent'; export interface ReadableSpan { readonly name: string; diff --git a/packages/opentelemetry-tracing/src/index.ts b/packages/opentelemetry-tracing/src/index.ts index 720241a3107..188b5105cec 100644 --- a/packages/opentelemetry-tracing/src/index.ts +++ b/packages/opentelemetry-tracing/src/index.ts @@ -24,4 +24,5 @@ export * from './export/SimpleSpanProcessor'; export * from './export/SpanExporter'; export * from './Span'; export * from './SpanProcessor'; +export * from './TimedEvent'; export * from './types';