Skip to content

Commit b208b2b

Browse files
authored
feat: add span processor (open-telemetry#136)
1 parent 7f5d71b commit b208b2b

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* Copyright 2019, OpenTelemetry Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { Span } from '@opentelemetry/types';
18+
19+
/**
20+
* SpanProcessor is the interface Tracer SDK uses to allow synchronous hooks
21+
* for when a {@link Span} is started or when a {@link Span} is ended.
22+
*/
23+
export interface SpanProcessor {
24+
/**
25+
* Called when a {@link Span} is started, if the `span.isRecordingEvents()`
26+
* returns true.
27+
* @param span the Span that just started.
28+
*/
29+
onStart(span: Span): void;
30+
31+
/**
32+
* Called when a {@link Span} is ended, if the `span.isRecordingEvents()`
33+
* returns true.
34+
* @param span the Span that just ended.
35+
*/
36+
onEnd(span: Span): void;
37+
38+
/**
39+
* Shuts down the processor. Called when SDK is shut down. This is an
40+
* opportunity for processor to do any cleanup required.
41+
*/
42+
shutdown(): void;
43+
}

packages/opentelemetry-basic-tracer/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ export * from './export/SpanExporter';
2020
export * from './types';
2121
export * from './BasicTracer';
2222
export * from './Span';
23+
export * from './SpanProcessor';

0 commit comments

Comments
 (0)