33
33
34
34
# pylint: disable=unused-import; needed for typing and sphinx
35
35
from opentelemetry import metrics
36
+ from opentelemetry .context import Context
36
37
from opentelemetry .metrics ._internal .observation import Observation
37
38
from opentelemetry .util .types import Attributes
38
39
@@ -173,6 +174,7 @@ def add(
173
174
self ,
174
175
amount : Union [int , float ],
175
176
attributes : Optional [Attributes ] = None ,
177
+ context : Optional [Context ] = None ,
176
178
) -> None :
177
179
pass
178
180
@@ -192,18 +194,20 @@ def add(
192
194
self ,
193
195
amount : Union [int , float ],
194
196
attributes : Optional [Attributes ] = None ,
197
+ context : Optional [Context ] = None ,
195
198
) -> None :
196
- return super ().add (amount , attributes = attributes )
199
+ return super ().add (amount , attributes = attributes , context = context )
197
200
198
201
199
202
class _ProxyCounter (_ProxyInstrument [Counter ], Counter ):
200
203
def add (
201
204
self ,
202
205
amount : Union [int , float ],
203
206
attributes : Optional [Attributes ] = None ,
207
+ context : Optional [Context ] = None ,
204
208
) -> None :
205
209
if self ._real_instrument :
206
- self ._real_instrument .add (amount , attributes )
210
+ self ._real_instrument .add (amount , attributes , context )
207
211
208
212
def _create_real_instrument (self , meter : "metrics.Meter" ) -> Counter :
209
213
return meter .create_counter (self ._name , self ._unit , self ._description )
@@ -217,6 +221,7 @@ def add(
217
221
self ,
218
222
amount : Union [int , float ],
219
223
attributes : Optional [Attributes ] = None ,
224
+ context : Optional [Context ] = None ,
220
225
) -> None :
221
226
pass
222
227
@@ -236,18 +241,20 @@ def add(
236
241
self ,
237
242
amount : Union [int , float ],
238
243
attributes : Optional [Attributes ] = None ,
244
+ context : Optional [Context ] = None ,
239
245
) -> None :
240
- return super ().add (amount , attributes = attributes )
246
+ return super ().add (amount , attributes = attributes , context = context )
241
247
242
248
243
249
class _ProxyUpDownCounter (_ProxyInstrument [UpDownCounter ], UpDownCounter ):
244
250
def add (
245
251
self ,
246
252
amount : Union [int , float ],
247
253
attributes : Optional [Attributes ] = None ,
254
+ context : Optional [Context ] = None ,
248
255
) -> None :
249
256
if self ._real_instrument :
250
- self ._real_instrument .add (amount , attributes )
257
+ self ._real_instrument .add (amount , attributes , context )
251
258
252
259
def _create_real_instrument (self , meter : "metrics.Meter" ) -> UpDownCounter :
253
260
return meter .create_up_down_counter (
@@ -328,6 +335,7 @@ def record(
328
335
self ,
329
336
amount : Union [int , float ],
330
337
attributes : Optional [Attributes ] = None ,
338
+ context : Optional [Context ] = None ,
331
339
) -> None :
332
340
pass
333
341
@@ -347,18 +355,20 @@ def record(
347
355
self ,
348
356
amount : Union [int , float ],
349
357
attributes : Optional [Attributes ] = None ,
358
+ context : Optional [Context ] = None ,
350
359
) -> None :
351
- return super ().record (amount , attributes = attributes )
360
+ return super ().record (amount , attributes = attributes , context = context )
352
361
353
362
354
363
class _ProxyHistogram (_ProxyInstrument [Histogram ], Histogram ):
355
364
def record (
356
365
self ,
357
366
amount : Union [int , float ],
358
367
attributes : Optional [Attributes ] = None ,
368
+ context : Optional [Context ] = None ,
359
369
) -> None :
360
370
if self ._real_instrument :
361
- self ._real_instrument .record (amount , attributes )
371
+ self ._real_instrument .record (amount , attributes , context )
362
372
363
373
def _create_real_instrument (self , meter : "metrics.Meter" ) -> Histogram :
364
374
return meter .create_histogram (
@@ -406,6 +416,7 @@ def set(
406
416
self ,
407
417
amount : Union [int , float ],
408
418
attributes : Optional [Attributes ] = None ,
419
+ context : Optional [Context ] = None ,
409
420
) -> None :
410
421
pass
411
422
@@ -425,8 +436,9 @@ def set(
425
436
self ,
426
437
amount : Union [int , float ],
427
438
attributes : Optional [Attributes ] = None ,
439
+ context : Optional [Context ] = None ,
428
440
) -> None :
429
- return super ().set (amount , attributes = attributes )
441
+ return super ().set (amount , attributes = attributes , context = context )
430
442
431
443
432
444
class _ProxyGauge (
@@ -437,9 +449,10 @@ def set(
437
449
self ,
438
450
amount : Union [int , float ],
439
451
attributes : Optional [Attributes ] = None ,
452
+ context : Optional [Context ] = None ,
440
453
) -> None :
441
454
if self ._real_instrument :
442
- self ._real_instrument .set (amount , attributes )
455
+ self ._real_instrument .set (amount , attributes , context )
443
456
444
457
def _create_real_instrument (self , meter : "metrics.Meter" ) -> Gauge :
445
458
return meter .create_gauge (self ._name , self ._unit , self ._description )
0 commit comments