diff --git a/src/tracing/decorators/span.spec.ts b/src/tracing/decorators/span.spec.ts index bbdfe713..f199cdb6 100644 --- a/src/tracing/decorators/span.spec.ts +++ b/src/tracing/decorators/span.spec.ts @@ -6,6 +6,8 @@ import { Span } from './span'; const TestDecoratorThatSetsMetadata = () => SetMetadata('some-metadata', true); +const symbol = Symbol('testSymbol'); + class TestSpan { @Span() singleSpan() { } @@ -26,6 +28,9 @@ class TestSpan { @Span() @TestDecoratorThatSetsMetadata() metadata() { } + + @Span() + [symbol]() { } } describe('Span', () => { @@ -114,4 +119,13 @@ describe('Span', () => { time: expect.anything(), }); }); + + it('should handle symbols', () => { + instance[symbol](); + + const spans = traceExporter.getFinishedSpans(); + + expect(spans).toHaveLength(1); + expect(spans.map(span => span.name)).toEqual(['TestSpan.Symbol(testSymbol)']); + }); }); diff --git a/src/tracing/decorators/span.ts b/src/tracing/decorators/span.ts index 5040ed82..95f922a1 100644 --- a/src/tracing/decorators/span.ts +++ b/src/tracing/decorators/span.ts @@ -9,11 +9,11 @@ const recordException = (span: ApiSpan, error: any) => { }; export function Span(name?: string, options: SpanOptions = {}) { - return (target: any, propertyKey: string, propertyDescriptor: PropertyDescriptor) => { + return (target: any, propertyKey: PropertyKey, propertyDescriptor: PropertyDescriptor) => { const originalFunction = propertyDescriptor.value; const wrappedFunction = function PropertyDescriptor(...args: any[]) { const tracer = trace.getTracer('default'); - const spanName = name || `${target.constructor.name}.${propertyKey}`; + const spanName = name || `${target.constructor.name}.${String(propertyKey)}`; return tracer.startActiveSpan(spanName, options, span => { if (originalFunction.constructor.name === 'AsyncFunction') {