4646from logging import getLogger
4747from os import environ
4848from threading import Lock
49- from typing import Dict , List , Optional , Sequence , Union , cast
49+ from typing import Any , Dict , List , Optional , Sequence , Union , cast
5050
5151from opentelemetry .environment_variables import OTEL_PYTHON_METER_PROVIDER
5252from opentelemetry .metrics ._internal .instrument import (
5353 CallbackT ,
5454 Counter ,
5555 Gauge ,
5656 Histogram ,
57- MetricsCommonAdvisory ,
58- MetricsHistogramAdvisory ,
5957 NoOpCounter ,
6058 NoOpGauge ,
6159 NoOpHistogram ,
6765 ObservableGauge ,
6866 ObservableUpDownCounter ,
6967 UpDownCounter ,
70- _MetricsInstrumentAdvisory ,
7168 _ProxyCounter ,
7269 _ProxyGauge ,
7370 _ProxyHistogram ,
@@ -188,7 +185,7 @@ class _InstrumentRegistrationStatus:
188185 instrument_id : str
189186 already_registered : bool
190187 conflict : bool
191- current_advisory : Optional [_MetricsInstrumentAdvisory ]
188+ current_advisory : Optional [Any ]
192189
193190
194191class Meter (ABC ):
@@ -208,9 +205,7 @@ def __init__(
208205 self ._name = name
209206 self ._version = version
210207 self ._schema_url = schema_url
211- self ._instrument_ids : Dict [
212- str , Optional [_MetricsInstrumentAdvisory ]
213- ] = {}
208+ self ._instrument_ids : Dict [str , Optional [Any ]] = {}
214209 self ._instrument_ids_lock = Lock ()
215210
216211 @property
@@ -240,7 +235,7 @@ def _register_instrument(
240235 type_ : type ,
241236 unit : str ,
242237 description : str ,
243- advisory : Optional [_MetricsInstrumentAdvisory ] = None ,
238+ advisory : Optional [Any ] = None ,
244239 ) -> _InstrumentRegistrationStatus :
245240 """
246241 Register an instrument with the name, type, unit and description as
@@ -303,7 +298,6 @@ def create_counter(
303298 name : str ,
304299 unit : str = "" ,
305300 description : str = "" ,
306- advisory : Optional [MetricsCommonAdvisory ] = None ,
307301 ) -> Counter :
308302 """Creates a `Counter` instrument
309303
@@ -320,7 +314,6 @@ def create_up_down_counter(
320314 name : str ,
321315 unit : str = "" ,
322316 description : str = "" ,
323- advisory : Optional [MetricsCommonAdvisory ] = None ,
324317 ) -> UpDownCounter :
325318 """Creates an `UpDownCounter` instrument
326319
@@ -338,7 +331,6 @@ def create_observable_counter(
338331 callbacks : Optional [Sequence [CallbackT ]] = None ,
339332 unit : str = "" ,
340333 description : str = "" ,
341- advisory : Optional [MetricsCommonAdvisory ] = None ,
342334 ) -> ObservableCounter :
343335 """Creates an `ObservableCounter` instrument
344336
@@ -435,7 +427,7 @@ def create_histogram(
435427 name : str ,
436428 unit : str = "" ,
437429 description : str = "" ,
438- advisory : Optional [MetricsHistogramAdvisory ] = None ,
430+ explicit_bucket_boundaries_advisory : Optional [Sequence [ float ] ] = None ,
439431 ) -> Histogram :
440432 """Creates a :class:`~opentelemetry.metrics.Histogram` instrument
441433
@@ -451,7 +443,6 @@ def create_gauge( # type: ignore # pylint: disable=no-self-use
451443 name : str ,
452444 unit : str = "" ,
453445 description : str = "" ,
454- advisory : Optional [MetricsCommonAdvisory ] = None ,
455446 ) -> Gauge :
456447 """Creates a ``Gauge`` instrument
457448
@@ -470,7 +461,6 @@ def create_observable_gauge(
470461 callbacks : Optional [Sequence [CallbackT ]] = None ,
471462 unit : str = "" ,
472463 description : str = "" ,
473- advisory : Optional [MetricsCommonAdvisory ] = None ,
474464 ) -> ObservableGauge :
475465 """Creates an `ObservableGauge` instrument
476466
@@ -491,7 +481,6 @@ def create_observable_up_down_counter(
491481 callbacks : Optional [Sequence [CallbackT ]] = None ,
492482 unit : str = "" ,
493483 description : str = "" ,
494- advisory : Optional [MetricsCommonAdvisory ] = None ,
495484 ) -> ObservableUpDownCounter :
496485 """Creates an `ObservableUpDownCounter` instrument
497486
@@ -540,7 +529,6 @@ def create_counter(
540529 name : str ,
541530 unit : str = "" ,
542531 description : str = "" ,
543- advisory : Optional [MetricsCommonAdvisory ] = None ,
544532 ) -> Counter :
545533 with self ._lock :
546534 if self ._real_meter :
@@ -554,7 +542,6 @@ def create_up_down_counter(
554542 name : str ,
555543 unit : str = "" ,
556544 description : str = "" ,
557- advisory : Optional [MetricsCommonAdvisory ] = None ,
558545 ) -> UpDownCounter :
559546 with self ._lock :
560547 if self ._real_meter :
@@ -571,7 +558,6 @@ def create_observable_counter(
571558 callbacks : Optional [Sequence [CallbackT ]] = None ,
572559 unit : str = "" ,
573560 description : str = "" ,
574- advisory : Optional [MetricsCommonAdvisory ] = None ,
575561 ) -> ObservableCounter :
576562 with self ._lock :
577563 if self ._real_meter :
@@ -589,14 +575,19 @@ def create_histogram(
589575 name : str ,
590576 unit : str = "" ,
591577 description : str = "" ,
592- advisory : Optional [MetricsHistogramAdvisory ] = None ,
578+ explicit_bucket_boundaries_advisory : Optional [Sequence [ float ] ] = None ,
593579 ) -> Histogram :
594580 with self ._lock :
595581 if self ._real_meter :
596582 return self ._real_meter .create_histogram (
597- name , unit , description , advisory
583+ name ,
584+ unit ,
585+ description ,
586+ explicit_bucket_boundaries_advisory ,
598587 )
599- proxy = _ProxyHistogram (name , unit , description , advisory )
588+ proxy = _ProxyHistogram (
589+ name , unit , description , explicit_bucket_boundaries_advisory
590+ )
600591 self ._instruments .append (proxy )
601592 return proxy
602593
@@ -605,7 +596,6 @@ def create_gauge(
605596 name : str ,
606597 unit : str = "" ,
607598 description : str = "" ,
608- advisory : Optional [MetricsCommonAdvisory ] = None ,
609599 ) -> Gauge :
610600 with self ._lock :
611601 if self ._real_meter :
@@ -620,7 +610,6 @@ def create_observable_gauge(
620610 callbacks : Optional [Sequence [CallbackT ]] = None ,
621611 unit : str = "" ,
622612 description : str = "" ,
623- advisory : Optional [MetricsCommonAdvisory ] = None ,
624613 ) -> ObservableGauge :
625614 with self ._lock :
626615 if self ._real_meter :
@@ -639,7 +628,6 @@ def create_observable_up_down_counter(
639628 callbacks : Optional [Sequence [CallbackT ]] = None ,
640629 unit : str = "" ,
641630 description : str = "" ,
642- advisory : Optional [MetricsCommonAdvisory ] = None ,
643631 ) -> ObservableUpDownCounter :
644632 with self ._lock :
645633 if self ._real_meter :
@@ -667,11 +655,10 @@ def create_counter(
667655 name : str ,
668656 unit : str = "" ,
669657 description : str = "" ,
670- advisory : Optional [MetricsCommonAdvisory ] = None ,
671658 ) -> Counter :
672659 """Returns a no-op Counter."""
673660 status = self ._register_instrument (
674- name , NoOpCounter , unit , description , advisory
661+ name , NoOpCounter , unit , description
675662 )
676663 if status .conflict :
677664 self ._log_instrument_registration_conflict (
@@ -689,12 +676,9 @@ def create_gauge(
689676 name : str ,
690677 unit : str = "" ,
691678 description : str = "" ,
692- advisory : Optional [MetricsCommonAdvisory ] = None ,
693679 ) -> Gauge :
694680 """Returns a no-op Gauge."""
695- status = self ._register_instrument (
696- name , NoOpGauge , unit , description , advisory
697- )
681+ status = self ._register_instrument (name , NoOpGauge , unit , description )
698682 if status .conflict :
699683 self ._log_instrument_registration_conflict (
700684 name ,
@@ -710,11 +694,10 @@ def create_up_down_counter(
710694 name : str ,
711695 unit : str = "" ,
712696 description : str = "" ,
713- advisory : Optional [MetricsCommonAdvisory ] = None ,
714697 ) -> UpDownCounter :
715698 """Returns a no-op UpDownCounter."""
716699 status = self ._register_instrument (
717- name , NoOpUpDownCounter , unit , description , advisory
700+ name , NoOpUpDownCounter , unit , description
718701 )
719702 if status .conflict :
720703 self ._log_instrument_registration_conflict (
@@ -732,11 +715,10 @@ def create_observable_counter(
732715 callbacks : Optional [Sequence [CallbackT ]] = None ,
733716 unit : str = "" ,
734717 description : str = "" ,
735- advisory : Optional [MetricsCommonAdvisory ] = None ,
736718 ) -> ObservableCounter :
737719 """Returns a no-op ObservableCounter."""
738720 status = self ._register_instrument (
739- name , NoOpObservableCounter , unit , description , advisory
721+ name , NoOpObservableCounter , unit , description
740722 )
741723 if status .conflict :
742724 self ._log_instrument_registration_conflict (
@@ -758,11 +740,18 @@ def create_histogram(
758740 name : str ,
759741 unit : str = "" ,
760742 description : str = "" ,
761- advisory : Optional [MetricsHistogramAdvisory ] = None ,
743+ explicit_bucket_boundaries_advisory : Optional [Sequence [ float ] ] = None ,
762744 ) -> Histogram :
763745 """Returns a no-op Histogram."""
746+ # FIXME: should be use a dataclass here instead for the advisory param?
764747 status = self ._register_instrument (
765- name , NoOpHistogram , unit , description , advisory
748+ name ,
749+ NoOpHistogram ,
750+ unit ,
751+ description ,
752+ {
753+ "explicit_bucket_boundaries_advisory" : explicit_bucket_boundaries_advisory
754+ },
766755 )
767756 if status .conflict :
768757 self ._log_instrument_registration_conflict (
@@ -773,7 +762,10 @@ def create_histogram(
773762 status ,
774763 )
775764 return NoOpHistogram (
776- name , unit = unit , description = description , advisory = advisory
765+ name ,
766+ unit = unit ,
767+ description = description ,
768+ explicit_bucket_boundaries_advisory = explicit_bucket_boundaries_advisory ,
777769 )
778770
779771 def create_observable_gauge (
@@ -782,11 +774,10 @@ def create_observable_gauge(
782774 callbacks : Optional [Sequence [CallbackT ]] = None ,
783775 unit : str = "" ,
784776 description : str = "" ,
785- advisory : Optional [MetricsCommonAdvisory ] = None ,
786777 ) -> ObservableGauge :
787778 """Returns a no-op ObservableGauge."""
788779 status = self ._register_instrument (
789- name , NoOpObservableGauge , unit , description , advisory
780+ name , NoOpObservableGauge , unit , description
790781 )
791782 if status .conflict :
792783 self ._log_instrument_registration_conflict (
@@ -809,11 +800,10 @@ def create_observable_up_down_counter(
809800 callbacks : Optional [Sequence [CallbackT ]] = None ,
810801 unit : str = "" ,
811802 description : str = "" ,
812- advisory : Optional [MetricsCommonAdvisory ] = None ,
813803 ) -> ObservableUpDownCounter :
814804 """Returns a no-op ObservableUpDownCounter."""
815805 status = self ._register_instrument (
816- name , NoOpObservableUpDownCounter , unit , description , advisory
806+ name , NoOpObservableUpDownCounter , unit , description
817807 )
818808 if status .conflict :
819809 self ._log_instrument_registration_conflict (
0 commit comments