|
| 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 | +} |
0 commit comments