@@ -181,12 +181,12 @@ def create_up_down_counter(
181181
182182 @abstractmethod
183183 def create_observable_counter (
184- self , name , callback , unit = "" , description = ""
184+ self , name , callbacks = None , unit = "" , description = ""
185185 ) -> ObservableCounter :
186186 """Creates an `ObservableCounter` instrument
187187
188188 An observable counter observes a monotonically increasing count by
189- calling a provided callback which returns multiple
189+ calling provided callbacks which returns multiple
190190 :class:`~opentelemetry._metrics.measurement.Measurement`.
191191
192192 For example, an observable counter could be used to report system CPU
@@ -207,7 +207,7 @@ def cpu_time_callback() -> Iterable[Measurement]:
207207
208208 meter.create_observable_counter(
209209 "system.cpu.time",
210- callback= cpu_time_callback,
210+ callbacks=[ cpu_time_callback] ,
211211 unit="s",
212212 description="CPU time"
213213 )
@@ -225,8 +225,8 @@ def cpu_time_callback() -> Iterable[Measurement]:
225225 yield Measurement(int(states[1]) // 100, {"cpu": cpu, "state": "nice"})
226226 # ... other states
227227
228- Alternatively, you can pass a generator directly instead of a callback,
229- which should return iterables of
228+ Alternatively, you can pass a sequence of generators directly instead
229+ of a sequence of callbacks, which each should return iterables of
230230 :class:`~opentelemetry._metrics.measurement.Measurement`::
231231
232232 def cpu_time_callback(states_to_include: set[str]) -> Iterable[Iterable[Measurement]]:
@@ -246,16 +246,17 @@ def cpu_time_callback(states_to_include: set[str]) -> Iterable[Iterable[Measurem
246246
247247 meter.create_observable_counter(
248248 "system.cpu.time",
249- callback= cpu_time_callback({"user", "system"}),
249+ callbacks=[ cpu_time_callback({"user", "system"})] ,
250250 unit="s",
251251 description="CPU time"
252252 )
253253
254254 Args:
255255 name: The name of the instrument to be created
256- callback : A callback that returns an iterable of
256+ callbacks : A sequence of callbacks that return an iterable of
257257 :class:`~opentelemetry._metrics.measurement.Measurement`.
258- Alternatively, can be a generator that yields iterables of
258+ Alternatively, can be a sequence of generators that each yields
259+ iterables of
259260 :class:`~opentelemetry._metrics.measurement.Measurement`.
260261 unit: The unit for measurements this instrument reports. For
261262 example, ``By`` for bytes. UCUM units are recommended.
@@ -275,13 +276,13 @@ def create_histogram(self, name, unit="", description="") -> Histogram:
275276
276277 @abstractmethod
277278 def create_observable_gauge (
278- self , name , callback , unit = "" , description = ""
279+ self , name , callbacks = None , unit = "" , description = ""
279280 ) -> ObservableGauge :
280281 """Creates an `ObservableGauge` instrument
281282
282283 Args:
283284 name: The name of the instrument to be created
284- callback : A callback that returns an iterable of
285+ callbacks : A sequence of callbacks that return an iterable of
285286 :class:`~opentelemetry._metrics.measurement.Measurement`.
286287 Alternatively, can be a generator that yields iterables of
287288 :class:`~opentelemetry._metrics.measurement.Measurement`.
@@ -292,13 +293,13 @@ def create_observable_gauge(
292293
293294 @abstractmethod
294295 def create_observable_up_down_counter (
295- self , name , callback , unit = "" , description = ""
296+ self , name , callbacks = None , unit = "" , description = ""
296297 ) -> ObservableUpDownCounter :
297298 """Creates an `ObservableUpDownCounter` instrument
298299
299300 Args:
300301 name: The name of the instrument to be created
301- callback : A callback that returns an iterable of
302+ callbacks : A sequence of callbacks that return an iterable of
302303 :class:`~opentelemetry._metrics.measurement.Measurement`.
303304 Alternatively, can be a generator that yields iterables of
304305 :class:`~opentelemetry._metrics.measurement.Measurement`.
@@ -358,15 +359,15 @@ def create_up_down_counter(
358359 return proxy
359360
360361 def create_observable_counter (
361- self , name , callback , unit = "" , description = ""
362+ self , name , callbacks = None , unit = "" , description = ""
362363 ) -> ObservableCounter :
363364 with self ._lock :
364365 if self ._real_meter :
365366 return self ._real_meter .create_observable_counter (
366- name , callback , unit , description
367+ name , callbacks , unit , description
367368 )
368369 proxy = _ProxyObservableCounter (
369- name , callback , unit = unit , description = description
370+ name , callbacks , unit = unit , description = description
370371 )
371372 self ._instruments .append (proxy )
372373 return proxy
@@ -382,32 +383,32 @@ def create_histogram(self, name, unit="", description="") -> Histogram:
382383 return proxy
383384
384385 def create_observable_gauge (
385- self , name , callback , unit = "" , description = ""
386+ self , name , callbacks = None , unit = "" , description = ""
386387 ) -> ObservableGauge :
387388 with self ._lock :
388389 if self ._real_meter :
389390 return self ._real_meter .create_observable_gauge (
390- name , callback , unit , description
391+ name , callbacks , unit , description
391392 )
392393 proxy = _ProxyObservableGauge (
393- name , callback , unit = unit , description = description
394+ name , callbacks , unit = unit , description = description
394395 )
395396 self ._instruments .append (proxy )
396397 return proxy
397398
398399 def create_observable_up_down_counter (
399- self , name , callback , unit = "" , description = ""
400+ self , name , callbacks = None , unit = "" , description = ""
400401 ) -> ObservableUpDownCounter :
401402 with self ._lock :
402403 if self ._real_meter :
403404 return self ._real_meter .create_observable_up_down_counter (
404405 name ,
405- callback ,
406+ callbacks ,
406407 unit ,
407408 description ,
408409 )
409410 proxy = _ProxyObservableUpDownCounter (
410- name , callback , unit = unit , description = description
411+ name , callbacks , unit = unit , description = description
411412 )
412413 self ._instruments .append (proxy )
413414 return proxy
@@ -454,11 +455,11 @@ def create_up_down_counter(
454455 return DefaultUpDownCounter (name , unit = unit , description = description )
455456
456457 def create_observable_counter (
457- self , name , callback , unit = "" , description = ""
458+ self , name , callbacks = None , unit = "" , description = ""
458459 ) -> ObservableCounter :
459460 """Returns a no-op ObservableCounter."""
460461 super ().create_observable_counter (
461- name , callback , unit = unit , description = description
462+ name , callbacks , unit = unit , description = description
462463 )
463464 if self ._check_instrument_id (
464465 name , DefaultObservableCounter , unit , description
@@ -473,7 +474,7 @@ def create_observable_counter(
473474 )
474475 return DefaultObservableCounter (
475476 name ,
476- callback ,
477+ callbacks ,
477478 unit = unit ,
478479 description = description ,
479480 )
@@ -495,11 +496,11 @@ def create_histogram(self, name, unit="", description="") -> Histogram:
495496 return DefaultHistogram (name , unit = unit , description = description )
496497
497498 def create_observable_gauge (
498- self , name , callback , unit = "" , description = ""
499+ self , name , callbacks = None , unit = "" , description = ""
499500 ) -> ObservableGauge :
500501 """Returns a no-op ObservableGauge."""
501502 super ().create_observable_gauge (
502- name , callback , unit = unit , description = description
503+ name , callbacks , unit = unit , description = description
503504 )
504505 if self ._check_instrument_id (
505506 name , DefaultObservableGauge , unit , description
@@ -514,17 +515,17 @@ def create_observable_gauge(
514515 )
515516 return DefaultObservableGauge (
516517 name ,
517- callback ,
518+ callbacks ,
518519 unit = unit ,
519520 description = description ,
520521 )
521522
522523 def create_observable_up_down_counter (
523- self , name , callback , unit = "" , description = ""
524+ self , name , callbacks = None , unit = "" , description = ""
524525 ) -> ObservableUpDownCounter :
525526 """Returns a no-op ObservableUpDownCounter."""
526527 super ().create_observable_up_down_counter (
527- name , callback , unit = unit , description = description
528+ name , callbacks , unit = unit , description = description
528529 )
529530 if self ._check_instrument_id (
530531 name , DefaultObservableUpDownCounter , unit , description
@@ -539,7 +540,7 @@ def create_observable_up_down_counter(
539540 )
540541 return DefaultObservableUpDownCounter (
541542 name ,
542- callback ,
543+ callbacks ,
543544 unit = unit ,
544545 description = description ,
545546 )
0 commit comments