-
Notifications
You must be signed in to change notification settings - Fork 4
/
metric.service.ts
81 lines (70 loc) · 2.24 KB
/
metric.service.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import {
Attributes,
BatchObservableCallback,
Counter,
Gauge,
Histogram,
Meter,
MetricOptions,
Observable,
ObservableCounter,
ObservableGauge,
ObservableUpDownCounter,
UpDownCounter
} from '@opentelemetry/api'
export const MetricService = Symbol('MetricService')
/**
* OpenTelemetry Metric Naming Conventions
*
* Format: <system>_<entity>_<unit>_<action>_<state>
*
* Unit Suffixes:
* - _seconds: Duration measurements
* - _bytes: Size measurements
* - _count: Current counts (gauge)
* - _total: Cumulative counts (counter)
* - _ratio: Percentages/ratios
*
* Examples:
* - http_requests_total
* - http_request_duration_seconds
* - db_connections_active_count
* - memory_heap_bytes_used
* - cache_hits_ratio
* - queue_messages_processed_total
* - user_sessions_active_count
* - file_upload_bytes_total
*
* Rules:
* - Use snake_case
* - Always include unit in name
* - Be explicit about aggregation type
* - Keep names stable/consistent
* - Start with system/subsystem
*
* @see https://opentelemetry.io/docs/specs/otel/metrics/semantic_conventions
*/
export interface MetricService {
getMeter(): Meter
createCounter<T extends Attributes = Attributes>(name: string, options?: MetricOptions): Counter<T>
createHistogram<T extends Attributes = Attributes>(name: string, options?: MetricOptions): Histogram<T>
createGauge<T extends Attributes = Attributes>(name: string, options?: MetricOptions): Gauge<T>
createUpDownCounter<T extends Attributes = Attributes>(name: string, options?: MetricOptions): UpDownCounter<T>
createObservableGauge<T extends Attributes = Attributes>(name: string, options?: MetricOptions): ObservableGauge<T>
createObservableCounter<T extends Attributes = Attributes>(
name: string,
options?: MetricOptions
): ObservableCounter<T>
createObservableUpDownCounter<T extends Attributes = Attributes>(
name: string,
options?: MetricOptions
): ObservableUpDownCounter<T>
addBatchObservableCallback<T extends Attributes = Attributes>(
callback: BatchObservableCallback<T>,
observables: Observable<T>[]
): void
removeBatchObservableCallback<T extends Attributes = Attributes>(
callback: BatchObservableCallback<T>,
observables: Observable<T>[]
): void
}