|
| 1 | +/** |
| 2 | + * Copyright 2019, OpenCensus 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 | + * http://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 {Measurement, View} from '../stats/types'; |
| 18 | +import {TagKey, TagValue} from '../tags/types'; |
| 19 | +import * as configTypes from '../trace/config/types'; |
| 20 | +import * as modelTypes from '../trace/model/types'; |
| 21 | + |
| 22 | +/** Defines a trace exporter interface. */ |
| 23 | +export interface Exporter extends modelTypes.SpanEventListener { |
| 24 | + /** |
| 25 | + * Sends a list of root spans to the service. |
| 26 | + * @param rootSpans A list of root spans to publish. |
| 27 | + */ |
| 28 | + publish(rootSpans: modelTypes.RootSpan[]): Promise<number|string|void>; |
| 29 | +} |
| 30 | + |
| 31 | +/** |
| 32 | + * An interface that describes the possible events that will be emitted from a |
| 33 | + * Stats instance. Stats exporters should implement this interface. |
| 34 | + */ |
| 35 | +export interface StatsEventListener { |
| 36 | + /** |
| 37 | + * Is called whenever a new view is registered |
| 38 | + * @deprecated since version 0.0.9 - use {@link start} instead |
| 39 | + * @param view The registered view |
| 40 | + */ |
| 41 | + onRegisterView(view: View): void; |
| 42 | + /** |
| 43 | + * Is called whenever a new measurement is recorded. |
| 44 | + * @deprecated since version 0.0.9 - use {@link start} instead |
| 45 | + * @param views The views related to the measurement |
| 46 | + * @param measurement The recorded measurement |
| 47 | + */ |
| 48 | + onRecord( |
| 49 | + views: View[], measurement: Measurement, |
| 50 | + tags: Map<TagKey, TagValue>): void; |
| 51 | + |
| 52 | + /** |
| 53 | + * Starts the exporter that polls Metric from Metrics library and send |
| 54 | + * batched data to backend. |
| 55 | + */ |
| 56 | + start(): void; |
| 57 | +} |
| 58 | + |
| 59 | +export type ExporterConfig = configTypes.BufferConfig; |
0 commit comments