1 | import { Attributes, AttributeValue } from '../common/Attributes';
|
2 | import { Context } from '../context/types';
|
3 | import { BatchObservableResult, ObservableResult } from './ObservableResult';
|
4 | /**
|
5 | * Advisory options influencing aggregation configuration parameters.
|
6 | * @experimental
|
7 | */
|
8 | export interface MetricAdvice {
|
9 | /**
|
10 | * Hint the explicit bucket boundaries for SDK if the metric is been
|
11 | * aggregated with a HistogramAggregator.
|
12 | */
|
13 | explicitBucketBoundaries?: number[];
|
14 | }
|
15 | /**
|
16 | * Options needed for metric creation
|
17 | */
|
18 | export interface MetricOptions {
|
19 | /**
|
20 | * The description of the Metric.
|
21 | * @default ''
|
22 | */
|
23 | description?: string;
|
24 | /**
|
25 | * The unit of the Metric values.
|
26 | * @default ''
|
27 | */
|
28 | unit?: string;
|
29 | /**
|
30 | * Indicates the type of the recorded value.
|
31 | * @default {@link ValueType.DOUBLE}
|
32 | */
|
33 | valueType?: ValueType;
|
34 | /**
|
35 | * The advice influencing aggregation configuration parameters.
|
36 | * @experimental
|
37 | */
|
38 | advice?: MetricAdvice;
|
39 | }
|
40 | /** The Type of value. It describes how the data is reported. */
|
41 | export declare enum ValueType {
|
42 | INT = 0,
|
43 | DOUBLE = 1
|
44 | }
|
45 | /**
|
46 | * Counter is the most common synchronous instrument. This instrument supports
|
47 | * an `Add(increment)` function for reporting a sum, and is restricted to
|
48 | * non-negative increments. The default aggregation is Sum, as for any additive
|
49 | * instrument.
|
50 | *
|
51 | * Example uses for Counter:
|
52 | * <ol>
|
53 | * <li> count the number of bytes received. </li>
|
54 | * <li> count the number of requests completed. </li>
|
55 | * <li> count the number of accounts created. </li>
|
56 | * <li> count the number of checkpoints run. </li>
|
57 | * <li> count the number of 5xx errors. </li>
|
58 | * <ol>
|
59 | */
|
60 | export interface Counter<AttributesTypes extends MetricAttributes = MetricAttributes> {
|
61 | /**
|
62 | * Increment value of counter by the input. Inputs must not be negative.
|
63 | */
|
64 | add(value: number, attributes?: AttributesTypes, context?: Context): void;
|
65 | }
|
66 | export interface UpDownCounter<AttributesTypes extends MetricAttributes = MetricAttributes> {
|
67 | /**
|
68 | * Increment value of counter by the input. Inputs may be negative.
|
69 | */
|
70 | add(value: number, attributes?: AttributesTypes, context?: Context): void;
|
71 | }
|
72 | export interface Histogram<AttributesTypes extends MetricAttributes = MetricAttributes> {
|
73 | /**
|
74 | * Records a measurement. Value of the measurement must not be negative.
|
75 | */
|
76 | record(value: number, attributes?: AttributesTypes, context?: Context): void;
|
77 | }
|
78 | /**
|
79 | * @deprecated please use {@link Attributes}
|
80 | */
|
81 | export declare type MetricAttributes = Attributes;
|
82 | /**
|
83 | * @deprecated please use {@link AttributeValue}
|
84 | */
|
85 | export declare type MetricAttributeValue = AttributeValue;
|
86 | /**
|
87 | * The observable callback for Observable instruments.
|
88 | */
|
89 | export declare type ObservableCallback<AttributesTypes extends MetricAttributes = MetricAttributes> = (observableResult: ObservableResult<AttributesTypes>) => void | Promise<void>;
|
90 | /**
|
91 | * The observable callback for a batch of Observable instruments.
|
92 | */
|
93 | export declare type BatchObservableCallback<AttributesTypes extends MetricAttributes = MetricAttributes> = (observableResult: BatchObservableResult<AttributesTypes>) => void | Promise<void>;
|
94 | export interface Observable<AttributesTypes extends MetricAttributes = MetricAttributes> {
|
95 | /**
|
96 | * Sets up a function that will be called whenever a metric collection is initiated.
|
97 | *
|
98 | * If the function is already in the list of callbacks for this Observable, the function is not added a second time.
|
99 | */
|
100 | addCallback(callback: ObservableCallback<AttributesTypes>): void;
|
101 | /**
|
102 | * Removes a callback previously registered with {@link Observable.addCallback}.
|
103 | */
|
104 | removeCallback(callback: ObservableCallback<AttributesTypes>): void;
|
105 | }
|
106 | export declare type ObservableCounter<AttributesTypes extends MetricAttributes = MetricAttributes> = Observable<AttributesTypes>;
|
107 | export declare type ObservableUpDownCounter<AttributesTypes extends MetricAttributes = MetricAttributes> = Observable<AttributesTypes>;
|
108 | export declare type ObservableGauge<AttributesTypes extends MetricAttributes = MetricAttributes> = Observable<AttributesTypes>;
|
109 | //# sourceMappingURL=Metric.d.ts.map |
\ | No newline at end of file |