Skip to content

Commit

Permalink
test(tracing): make sure metadata is kept
Browse files Browse the repository at this point in the history
  • Loading branch information
mentos1386 committed Mar 29, 2022
1 parent bdc9ae3 commit d8d5b9b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/tracing/decorators/span.spec.ts
@@ -1,8 +1,12 @@
import 'reflect-metadata';
import { SpanStatusCode } from '@opentelemetry/api';
import { tracing } from '@opentelemetry/sdk-node';
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
import { SetMetadata } from '@nestjs/common';
import { Span } from './span';

const TestDecoratorThatSetsMetadata = () => SetMetadata('some-metadata', true);

class TestSpan {
@Span()
singleSpan() {}
Expand All @@ -16,6 +20,10 @@ class TestSpan {
error() {
throw new Error('hello world');
}

@Span()
@TestDecoratorThatSetsMetadata()
metadata() {}
}

describe('Span', () => {
Expand Down Expand Up @@ -43,6 +51,10 @@ describe('Span', () => {
await provider.shutdown();
});

it('should maintain reflect metadataa', async () => {
expect(Reflect.getMetadata('some-metadata', instance.metadata)).toEqual(true);
});

it('should set correct span', async () => {
instance.singleSpan();

Expand Down

0 comments on commit d8d5b9b

Please sign in to comment.