diff --git a/sdk/core/core-rest-pipeline/test/tracingPolicy.spec.ts b/sdk/core/core-rest-pipeline/test/tracingPolicy.spec.ts index 5643463b7b56..041fbdc589d0 100644 --- a/sdk/core/core-rest-pipeline/test/tracingPolicy.spec.ts +++ b/sdk/core/core-rest-pipeline/test/tracingPolicy.spec.ts @@ -14,30 +14,47 @@ import { import { setTracer, NoOpTracer, - NoOpSpan, + Span, + Tracer, SpanContext, TraceFlags, TraceState, context, setSpan, SpanStatus, - SpanStatusCode + SpanStatusCode, + SpanAttributes, + SpanAttributeValue } from "@azure/core-tracing"; -class MockSpan extends NoOpSpan { +class MockSpan implements Span { private _endCalled = false; private _status: SpanStatus = { code: SpanStatusCode.UNSET }; - private _attributes: { [s: string]: unknown } = {}; + private _attributes: SpanAttributes = {}; constructor( private traceId: string, private spanId: string, private flags: TraceFlags, private state: string - ) { - super(); + ) {} + + addEvent(): this { + throw new Error("Method not implemented."); + } + + isRecording(): boolean { + return true; + } + + recordException(): void { + throw new Error("Method not implemented."); + } + + updateName(): this { + throw new Error("Method not implemented."); } didEnd(): boolean { @@ -57,7 +74,12 @@ class MockSpan extends NoOpSpan { return this; } - setAttribute(key: string, value: unknown) { + setAttributes(attributes: SpanAttributes): this { + this._attributes = attributes; + return this; + } + + setAttribute(key: string, value: SpanAttributeValue) { this._attributes[key] = value; return this; } @@ -66,7 +88,7 @@ class MockSpan extends NoOpSpan { return this._attributes[key]; } - spanContext(): SpanContext { + context(): SpanContext { const state = this.state; const traceState = { @@ -95,7 +117,7 @@ class MockSpan extends NoOpSpan { } } -class MockTracer extends NoOpTracer { +class MockTracer implements Tracer { private spans: MockSpan[] = []; private _startSpanCalled = false; @@ -104,9 +126,7 @@ class MockTracer extends NoOpTracer { private spanId = "", private flags = TraceFlags.NONE, private state = "" - ) { - super(); - } + ) {} getStartedSpans(): MockSpan[] { return this.spans;