@@ -703,8 +703,8 @@ def _get_aggregator():
703703 )
704704
705705
706- def _get_aggregator_and_update_tags (key , tags ):
707- # type: (str, Optional[MetricTags]) -> Tuple[Optional[MetricsAggregator], Optional[LocalAggregator], Optional[MetricTags]]
706+ def _get_aggregator_and_update_tags (key , value , unit , tags ):
707+ # type: (str, Optional[MetricValue], MeasurementUnit, Optional[ MetricTags]) -> Tuple[Optional[MetricsAggregator], Optional[LocalAggregator], Optional[MetricTags]]
708708 hub = sentry_sdk .Hub .current
709709 client = hub .client
710710 if client is None or client .metrics_aggregator is None :
@@ -732,7 +732,7 @@ def _get_aggregator_and_update_tags(key, tags):
732732 if before_emit_callback is not None :
733733 with recursion_protection () as in_metrics :
734734 if not in_metrics :
735- if not before_emit_callback (key , updated_tags ):
735+ if not before_emit_callback (key , value , unit , updated_tags ):
736736 return None , None , updated_tags
737737
738738 return client .metrics_aggregator , local_aggregator , updated_tags
@@ -748,7 +748,9 @@ def increment(
748748):
749749 # type: (...) -> None
750750 """Increments a counter."""
751- aggregator , local_aggregator , tags = _get_aggregator_and_update_tags (key , tags )
751+ aggregator , local_aggregator , tags = _get_aggregator_and_update_tags (
752+ key , value , unit , tags
753+ )
752754 if aggregator is not None :
753755 aggregator .add (
754756 "c" , key , value , unit , tags , timestamp , local_aggregator , stacklevel
@@ -809,7 +811,10 @@ def __exit__(self, exc_type, exc_value, tb):
809811 # type: (Any, Any, Any) -> None
810812 assert self ._span , "did not enter"
811813 aggregator , local_aggregator , tags = _get_aggregator_and_update_tags (
812- self .key , self .tags
814+ self .key ,
815+ self .value ,
816+ self .unit ,
817+ self .tags ,
813818 )
814819 if aggregator is not None :
815820 elapsed = TIMING_FUNCTIONS [self .unit ]() - self .entered # type: ignore
@@ -864,7 +869,9 @@ def timing(
864869 - it can be used as a decorator
865870 """
866871 if value is not None :
867- aggregator , local_aggregator , tags = _get_aggregator_and_update_tags (key , tags )
872+ aggregator , local_aggregator , tags = _get_aggregator_and_update_tags (
873+ key , value , unit , tags
874+ )
868875 if aggregator is not None :
869876 aggregator .add (
870877 "d" , key , value , unit , tags , timestamp , local_aggregator , stacklevel
@@ -882,7 +889,9 @@ def distribution(
882889):
883890 # type: (...) -> None
884891 """Emits a distribution."""
885- aggregator , local_aggregator , tags = _get_aggregator_and_update_tags (key , tags )
892+ aggregator , local_aggregator , tags = _get_aggregator_and_update_tags (
893+ key , value , unit , tags
894+ )
886895 if aggregator is not None :
887896 aggregator .add (
888897 "d" , key , value , unit , tags , timestamp , local_aggregator , stacklevel
@@ -899,7 +908,9 @@ def set(
899908):
900909 # type: (...) -> None
901910 """Emits a set."""
902- aggregator , local_aggregator , tags = _get_aggregator_and_update_tags (key , tags )
911+ aggregator , local_aggregator , tags = _get_aggregator_and_update_tags (
912+ key , value , unit , tags
913+ )
903914 if aggregator is not None :
904915 aggregator .add (
905916 "s" , key , value , unit , tags , timestamp , local_aggregator , stacklevel
@@ -916,7 +927,9 @@ def gauge(
916927):
917928 # type: (...) -> None
918929 """Emits a gauge."""
919- aggregator , local_aggregator , tags = _get_aggregator_and_update_tags (key , tags )
930+ aggregator , local_aggregator , tags = _get_aggregator_and_update_tags (
931+ key , value , unit , tags
932+ )
920933 if aggregator is not None :
921934 aggregator .add (
922935 "g" , key , value , unit , tags , timestamp , local_aggregator , stacklevel
0 commit comments