|
1 |
| -import { SpanContext as SpanContextInterface } from '@sentry/types'; |
| 1 | +import { Span as SpanInterface } from '@sentry/types'; |
2 | 2 | import { uuid4 } from '@sentry/utils';
|
3 | 3 |
|
4 |
| -export const TRACEPARENT_REGEX = /([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})/; |
| 4 | +export const TRACEPARENT_REGEXP = /([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})/; |
5 | 5 |
|
6 | 6 | /**
|
7 |
| - * SpanContext containg all data about a span |
| 7 | + * Span containg all data about a span |
8 | 8 | */
|
9 |
| -export class SpanContext implements SpanContextInterface { |
| 9 | +export class Span implements SpanInterface { |
10 | 10 | public constructor(
|
11 | 11 | private readonly _traceId: string = uuid4(),
|
12 | 12 | private readonly _spanId: string = uuid4().substring(16),
|
13 | 13 | private readonly _recorded: boolean = false,
|
14 |
| - private readonly _parent?: SpanContext, |
| 14 | + private readonly _parent?: Span, |
15 | 15 | ) {}
|
16 | 16 |
|
17 | 17 | /**
|
18 | 18 | * Continues a trace
|
19 | 19 | * @param traceparent Traceparent string
|
20 | 20 | */
|
21 |
| - public static fromTraceparent(traceparent: string): SpanContext | undefined { |
22 |
| - const matches = traceparent.match(TRACEPARENT_REGEX); |
| 21 | + public static fromTraceparent(traceparent: string): Span | undefined { |
| 22 | + const matches = traceparent.match(TRACEPARENT_REGEXP); |
23 | 23 | if (matches) {
|
24 |
| - const parent = new SpanContext(matches[2], matches[3], matches[4] === '01' ? true : false); |
25 |
| - return new SpanContext(matches[2], undefined, undefined, parent); |
| 24 | + const parent = new Span(matches[2], matches[3], matches[4] === '01' ? true : false); |
| 25 | + return new Span(matches[2], undefined, undefined, parent); |
26 | 26 | }
|
27 | 27 | return undefined;
|
28 | 28 | }
|
|
0 commit comments