Skip to content

Commit e0c621a

Browse files
committed
add span processor boilerplate
1 parent 89e4e9f commit e0c621a

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed
Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,41 @@
1+
import { Context } from '@opentelemetry/api';
2+
import { Span as OtelSpan, SpanProcessor as OtelSpanProcessor } from '@opentelemetry/sdk-trace-base';
3+
import { getCurrentHub } from '@sentry/core';
4+
15
/**
2-
* Test function
6+
* Converts OpenTelemetry Spans to Sentry Spans and sends them to Sentry via
7+
* the Sentry SDK.
38
*/
4-
export function test(): void {
5-
// no-op
9+
export class SentrySpanProcessor implements OtelSpanProcessor {
10+
/**
11+
* @inheritDoc
12+
*/
13+
public onStart(span: OtelSpan, parentContext: Context): void {
14+
// do something
15+
}
16+
17+
/**
18+
* @inheritDoc
19+
*/
20+
public onEnd(span: OtelSpan): void {
21+
// do something
22+
}
23+
24+
/**
25+
* @inheritDoc
26+
*/
27+
public shutdown(): Promise<void> {
28+
return Promise.resolve();
29+
}
30+
31+
/**
32+
* @inheritDoc
33+
*/
34+
public async forceFlush(): Promise<void> {
35+
const client = getCurrentHub().getClient();
36+
if (client) {
37+
return client.flush().then();
38+
}
39+
return Promise.resolve();
40+
}
641
}

0 commit comments

Comments
 (0)