UNPKG

4.98 kBTypeScriptView Raw
1import { BatchObservableCallback, Counter, Histogram, MetricAttributes, MetricOptions, Observable, ObservableCounter, ObservableGauge, ObservableUpDownCounter, UpDownCounter } from './Metric';
2/**
3 * An interface describes additional metadata of a meter.
4 */
5export interface MeterOptions {
6 /**
7 * The schemaUrl of the meter or instrumentation library
8 */
9 schemaUrl?: string;
10}
11/**
12 * An interface to allow the recording metrics.
13 *
14 * {@link Metric}s are used for recording pre-defined aggregation (`Counter`),
15 * or raw values (`Histogram`) in which the aggregation and attributes
16 * for the exported metric are deferred.
17 */
18export interface Meter {
19 /**
20 * Creates and returns a new `Histogram`.
21 * @param name the name of the metric.
22 * @param [options] the metric options.
23 */
24 createHistogram<AttributesTypes extends MetricAttributes = MetricAttributes>(name: string, options?: MetricOptions): Histogram<AttributesTypes>;
25 /**
26 * Creates a new `Counter` metric. Generally, this kind of metric when the
27 * value is a quantity, the sum is of primary interest, and the event count
28 * and value distribution are not of primary interest.
29 * @param name the name of the metric.
30 * @param [options] the metric options.
31 */
32 createCounter<AttributesTypes extends MetricAttributes = MetricAttributes>(name: string, options?: MetricOptions): Counter<AttributesTypes>;
33 /**
34 * Creates a new `UpDownCounter` metric. UpDownCounter is a synchronous
35 * instrument and very similar to Counter except that Add(increment)
36 * supports negative increments. It is generally useful for capturing changes
37 * in an amount of resources used, or any quantity that rises and falls
38 * during a request.
39 * Example uses for UpDownCounter:
40 * <ol>
41 * <li> count the number of active requests. </li>
42 * <li> count memory in use by instrumenting new and delete. </li>
43 * <li> count queue size by instrumenting enqueue and dequeue. </li>
44 * <li> count semaphore up and down operations. </li>
45 * </ol>
46 *
47 * @param name the name of the metric.
48 * @param [options] the metric options.
49 */
50 createUpDownCounter<AttributesTypes extends MetricAttributes = MetricAttributes>(name: string, options?: MetricOptions): UpDownCounter<AttributesTypes>;
51 /**
52 * Creates a new `ObservableGauge` metric.
53 *
54 * The callback SHOULD be safe to be invoked concurrently.
55 *
56 * @param name the name of the metric.
57 * @param [options] the metric options.
58 */
59 createObservableGauge<AttributesTypes extends MetricAttributes = MetricAttributes>(name: string, options?: MetricOptions): ObservableGauge<AttributesTypes>;
60 /**
61 * Creates a new `ObservableCounter` metric.
62 *
63 * The callback SHOULD be safe to be invoked concurrently.
64 *
65 * @param name the name of the metric.
66 * @param [options] the metric options.
67 */
68 createObservableCounter<AttributesTypes extends MetricAttributes = MetricAttributes>(name: string, options?: MetricOptions): ObservableCounter<AttributesTypes>;
69 /**
70 * Creates a new `ObservableUpDownCounter` metric.
71 *
72 * The callback SHOULD be safe to be invoked concurrently.
73 *
74 * @param name the name of the metric.
75 * @param [options] the metric options.
76 */
77 createObservableUpDownCounter<AttributesTypes extends MetricAttributes = MetricAttributes>(name: string, options?: MetricOptions): ObservableUpDownCounter<AttributesTypes>;
78 /**
79 * Sets up a function that will be called whenever a metric collection is
80 * initiated.
81 *
82 * If the function is already in the list of callbacks for this Observable,
83 * the function is not added a second time.
84 *
85 * Only the associated observables can be observed in the callback.
86 * Measurements of observables that are not associated observed in the
87 * callback are dropped.
88 *
89 * @param callback the batch observable callback
90 * @param observables the observables associated with this batch observable callback
91 */
92 addBatchObservableCallback<AttributesTypes extends MetricAttributes = MetricAttributes>(callback: BatchObservableCallback<AttributesTypes>, observables: Observable<AttributesTypes>[]): void;
93 /**
94 * Removes a callback previously registered with {@link Meter.addBatchObservableCallback}.
95 *
96 * The callback to be removed is identified using a combination of the callback itself,
97 * and the set of the observables associated with it.
98 *
99 * @param callback the batch observable callback
100 * @param observables the observables associated with this batch observable callback
101 */
102 removeBatchObservableCallback<AttributesTypes extends MetricAttributes = MetricAttributes>(callback: BatchObservableCallback<AttributesTypes>, observables: Observable<AttributesTypes>[]): void;
103}
104//# sourceMappingURL=Meter.d.ts.map
\No newline at end of file