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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
|
# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Final
from opentelemetry.metrics import Counter, Histogram, Meter, UpDownCounter
DB_CLIENT_CONNECTION_COUNT: Final = "db.client.connection.count"
"""
The number of connections that are currently in state described by the `state` attribute
Instrument: updowncounter
Unit: {connection}
"""
def create_db_client_connection_count(meter: Meter) -> UpDownCounter:
"""The number of connections that are currently in state described by the `state` attribute"""
return meter.create_up_down_counter(
name=DB_CLIENT_CONNECTION_COUNT,
description="The number of connections that are currently in state described by the `state` attribute",
unit="{connection}",
)
DB_CLIENT_CONNECTION_CREATE_TIME: Final = "db.client.connection.create_time"
"""
The time it took to create a new connection
Instrument: histogram
Unit: s
"""
def create_db_client_connection_create_time(meter: Meter) -> Histogram:
"""The time it took to create a new connection"""
return meter.create_histogram(
name=DB_CLIENT_CONNECTION_CREATE_TIME,
description="The time it took to create a new connection",
unit="s",
)
DB_CLIENT_CONNECTION_IDLE_MAX: Final = "db.client.connection.idle.max"
"""
The maximum number of idle open connections allowed
Instrument: updowncounter
Unit: {connection}
"""
def create_db_client_connection_idle_max(meter: Meter) -> UpDownCounter:
"""The maximum number of idle open connections allowed"""
return meter.create_up_down_counter(
name=DB_CLIENT_CONNECTION_IDLE_MAX,
description="The maximum number of idle open connections allowed",
unit="{connection}",
)
DB_CLIENT_CONNECTION_IDLE_MIN: Final = "db.client.connection.idle.min"
"""
The minimum number of idle open connections allowed
Instrument: updowncounter
Unit: {connection}
"""
def create_db_client_connection_idle_min(meter: Meter) -> UpDownCounter:
"""The minimum number of idle open connections allowed"""
return meter.create_up_down_counter(
name=DB_CLIENT_CONNECTION_IDLE_MIN,
description="The minimum number of idle open connections allowed",
unit="{connection}",
)
DB_CLIENT_CONNECTION_MAX: Final = "db.client.connection.max"
"""
The maximum number of open connections allowed
Instrument: updowncounter
Unit: {connection}
"""
def create_db_client_connection_max(meter: Meter) -> UpDownCounter:
"""The maximum number of open connections allowed"""
return meter.create_up_down_counter(
name=DB_CLIENT_CONNECTION_MAX,
description="The maximum number of open connections allowed",
unit="{connection}",
)
DB_CLIENT_CONNECTION_PENDING_REQUESTS: Final = (
"db.client.connection.pending_requests"
)
"""
The number of current pending requests for an open connection
Instrument: updowncounter
Unit: {request}
"""
def create_db_client_connection_pending_requests(
meter: Meter,
) -> UpDownCounter:
"""The number of current pending requests for an open connection"""
return meter.create_up_down_counter(
name=DB_CLIENT_CONNECTION_PENDING_REQUESTS,
description="The number of current pending requests for an open connection",
unit="{request}",
)
DB_CLIENT_CONNECTION_TIMEOUTS: Final = "db.client.connection.timeouts"
"""
The number of connection timeouts that have occurred trying to obtain a connection from the pool
Instrument: counter
Unit: {timeout}
"""
def create_db_client_connection_timeouts(meter: Meter) -> Counter:
"""The number of connection timeouts that have occurred trying to obtain a connection from the pool"""
return meter.create_counter(
name=DB_CLIENT_CONNECTION_TIMEOUTS,
description="The number of connection timeouts that have occurred trying to obtain a connection from the pool",
unit="{timeout}",
)
DB_CLIENT_CONNECTION_USE_TIME: Final = "db.client.connection.use_time"
"""
The time between borrowing a connection and returning it to the pool
Instrument: histogram
Unit: s
"""
def create_db_client_connection_use_time(meter: Meter) -> Histogram:
"""The time between borrowing a connection and returning it to the pool"""
return meter.create_histogram(
name=DB_CLIENT_CONNECTION_USE_TIME,
description="The time between borrowing a connection and returning it to the pool",
unit="s",
)
DB_CLIENT_CONNECTION_WAIT_TIME: Final = "db.client.connection.wait_time"
"""
The time it took to obtain an open connection from the pool
Instrument: histogram
Unit: s
"""
def create_db_client_connection_wait_time(meter: Meter) -> Histogram:
"""The time it took to obtain an open connection from the pool"""
return meter.create_histogram(
name=DB_CLIENT_CONNECTION_WAIT_TIME,
description="The time it took to obtain an open connection from the pool",
unit="s",
)
DB_CLIENT_CONNECTIONS_CREATE_TIME: Final = "db.client.connections.create_time"
"""
Deprecated: Replaced by `db.client.connection.create_time`. Note: the unit also changed from `ms` to `s`.
"""
def create_db_client_connections_create_time(meter: Meter) -> Histogram:
"""Deprecated, use `db.client.connection.create_time` instead. Note: the unit also changed from `ms` to `s`"""
return meter.create_histogram(
name=DB_CLIENT_CONNECTIONS_CREATE_TIME,
description="Deprecated, use `db.client.connection.create_time` instead. Note: the unit also changed from `ms` to `s`.",
unit="ms",
)
DB_CLIENT_CONNECTIONS_IDLE_MAX: Final = "db.client.connections.idle.max"
"""
Deprecated: Replaced by `db.client.connection.idle.max`.
"""
def create_db_client_connections_idle_max(meter: Meter) -> UpDownCounter:
"""Deprecated, use `db.client.connection.idle.max` instead"""
return meter.create_up_down_counter(
name=DB_CLIENT_CONNECTIONS_IDLE_MAX,
description="Deprecated, use `db.client.connection.idle.max` instead.",
unit="{connection}",
)
DB_CLIENT_CONNECTIONS_IDLE_MIN: Final = "db.client.connections.idle.min"
"""
Deprecated: Replaced by `db.client.connection.idle.min`.
"""
def create_db_client_connections_idle_min(meter: Meter) -> UpDownCounter:
"""Deprecated, use `db.client.connection.idle.min` instead"""
return meter.create_up_down_counter(
name=DB_CLIENT_CONNECTIONS_IDLE_MIN,
description="Deprecated, use `db.client.connection.idle.min` instead.",
unit="{connection}",
)
DB_CLIENT_CONNECTIONS_MAX: Final = "db.client.connections.max"
"""
Deprecated: Replaced by `db.client.connection.max`.
"""
def create_db_client_connections_max(meter: Meter) -> UpDownCounter:
"""Deprecated, use `db.client.connection.max` instead"""
return meter.create_up_down_counter(
name=DB_CLIENT_CONNECTIONS_MAX,
description="Deprecated, use `db.client.connection.max` instead.",
unit="{connection}",
)
DB_CLIENT_CONNECTIONS_PENDING_REQUESTS: Final = (
"db.client.connections.pending_requests"
)
"""
Deprecated: Replaced by `db.client.connection.pending_requests`.
"""
def create_db_client_connections_pending_requests(
meter: Meter,
) -> UpDownCounter:
"""Deprecated, use `db.client.connection.pending_requests` instead"""
return meter.create_up_down_counter(
name=DB_CLIENT_CONNECTIONS_PENDING_REQUESTS,
description="Deprecated, use `db.client.connection.pending_requests` instead.",
unit="{request}",
)
DB_CLIENT_CONNECTIONS_TIMEOUTS: Final = "db.client.connections.timeouts"
"""
Deprecated: Replaced by `db.client.connection.timeouts`.
"""
def create_db_client_connections_timeouts(meter: Meter) -> Counter:
"""Deprecated, use `db.client.connection.timeouts` instead"""
return meter.create_counter(
name=DB_CLIENT_CONNECTIONS_TIMEOUTS,
description="Deprecated, use `db.client.connection.timeouts` instead.",
unit="{timeout}",
)
DB_CLIENT_CONNECTIONS_USAGE: Final = "db.client.connections.usage"
"""
Deprecated: Replaced by `db.client.connection.count`.
"""
def create_db_client_connections_usage(meter: Meter) -> UpDownCounter:
"""Deprecated, use `db.client.connection.count` instead"""
return meter.create_up_down_counter(
name=DB_CLIENT_CONNECTIONS_USAGE,
description="Deprecated, use `db.client.connection.count` instead.",
unit="{connection}",
)
DB_CLIENT_CONNECTIONS_USE_TIME: Final = "db.client.connections.use_time"
"""
Deprecated: Replaced by `db.client.connection.use_time`. Note: the unit also changed from `ms` to `s`.
"""
def create_db_client_connections_use_time(meter: Meter) -> Histogram:
"""Deprecated, use `db.client.connection.use_time` instead. Note: the unit also changed from `ms` to `s`"""
return meter.create_histogram(
name=DB_CLIENT_CONNECTIONS_USE_TIME,
description="Deprecated, use `db.client.connection.use_time` instead. Note: the unit also changed from `ms` to `s`.",
unit="ms",
)
DB_CLIENT_CONNECTIONS_WAIT_TIME: Final = "db.client.connections.wait_time"
"""
Deprecated: Replaced by `db.client.connection.wait_time`. Note: the unit also changed from `ms` to `s`.
"""
def create_db_client_connections_wait_time(meter: Meter) -> Histogram:
"""Deprecated, use `db.client.connection.wait_time` instead. Note: the unit also changed from `ms` to `s`"""
return meter.create_histogram(
name=DB_CLIENT_CONNECTIONS_WAIT_TIME,
description="Deprecated, use `db.client.connection.wait_time` instead. Note: the unit also changed from `ms` to `s`.",
unit="ms",
)
DB_CLIENT_COSMOSDB_ACTIVE_INSTANCE_COUNT: Final = (
"db.client.cosmosdb.active_instance.count"
)
"""
Deprecated: Replaced by `azure.cosmosdb.client.active_instance.count`.
"""
def create_db_client_cosmosdb_active_instance_count(
meter: Meter,
) -> UpDownCounter:
"""Deprecated, use `azure.cosmosdb.client.active_instance.count` instead"""
return meter.create_up_down_counter(
name=DB_CLIENT_COSMOSDB_ACTIVE_INSTANCE_COUNT,
description="Deprecated, use `azure.cosmosdb.client.active_instance.count` instead.",
unit="{instance}",
)
DB_CLIENT_COSMOSDB_OPERATION_REQUEST_CHARGE: Final = (
"db.client.cosmosdb.operation.request_charge"
)
"""
Deprecated: Replaced by `azure.cosmosdb.client.operation.request_charge`.
"""
def create_db_client_cosmosdb_operation_request_charge(
meter: Meter,
) -> Histogram:
"""Deprecated, use `azure.cosmosdb.client.operation.request_charge` instead"""
return meter.create_histogram(
name=DB_CLIENT_COSMOSDB_OPERATION_REQUEST_CHARGE,
description="Deprecated, use `azure.cosmosdb.client.operation.request_charge` instead.",
unit="{request_unit}",
)
DB_CLIENT_OPERATION_DURATION: Final = "db.client.operation.duration"
"""
Duration of database client operations
Instrument: histogram
Unit: s
Note: Batch operations SHOULD be recorded as a single operation.
"""
def create_db_client_operation_duration(meter: Meter) -> Histogram:
"""Duration of database client operations"""
return meter.create_histogram(
name=DB_CLIENT_OPERATION_DURATION,
description="Duration of database client operations.",
unit="s",
)
DB_CLIENT_RESPONSE_RETURNED_ROWS: Final = "db.client.response.returned_rows"
"""
The actual number of records returned by the database operation
Instrument: histogram
Unit: {row}
"""
def create_db_client_response_returned_rows(meter: Meter) -> Histogram:
"""The actual number of records returned by the database operation"""
return meter.create_histogram(
name=DB_CLIENT_RESPONSE_RETURNED_ROWS,
description="The actual number of records returned by the database operation.",
unit="{row}",
)
|