@@ -703,8 +703,8 @@ def _get_aggregator():
703
703
)
704
704
705
705
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]]
708
708
hub = sentry_sdk .Hub .current
709
709
client = hub .client
710
710
if client is None or client .metrics_aggregator is None :
@@ -732,7 +732,7 @@ def _get_aggregator_and_update_tags(key, tags):
732
732
if before_emit_callback is not None :
733
733
with recursion_protection () as in_metrics :
734
734
if not in_metrics :
735
- if not before_emit_callback (key , updated_tags ):
735
+ if not before_emit_callback (key , value , unit , updated_tags ):
736
736
return None , None , updated_tags
737
737
738
738
return client .metrics_aggregator , local_aggregator , updated_tags
@@ -748,7 +748,9 @@ def increment(
748
748
):
749
749
# type: (...) -> None
750
750
"""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
+ )
752
754
if aggregator is not None :
753
755
aggregator .add (
754
756
"c" , key , value , unit , tags , timestamp , local_aggregator , stacklevel
@@ -809,7 +811,10 @@ def __exit__(self, exc_type, exc_value, tb):
809
811
# type: (Any, Any, Any) -> None
810
812
assert self ._span , "did not enter"
811
813
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 ,
813
818
)
814
819
if aggregator is not None :
815
820
elapsed = TIMING_FUNCTIONS [self .unit ]() - self .entered # type: ignore
@@ -864,7 +869,9 @@ def timing(
864
869
- it can be used as a decorator
865
870
"""
866
871
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
+ )
868
875
if aggregator is not None :
869
876
aggregator .add (
870
877
"d" , key , value , unit , tags , timestamp , local_aggregator , stacklevel
@@ -882,7 +889,9 @@ def distribution(
882
889
):
883
890
# type: (...) -> None
884
891
"""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
+ )
886
895
if aggregator is not None :
887
896
aggregator .add (
888
897
"d" , key , value , unit , tags , timestamp , local_aggregator , stacklevel
@@ -899,7 +908,9 @@ def set(
899
908
):
900
909
# type: (...) -> None
901
910
"""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
+ )
903
914
if aggregator is not None :
904
915
aggregator .add (
905
916
"s" , key , value , unit , tags , timestamp , local_aggregator , stacklevel
@@ -916,7 +927,9 @@ def gauge(
916
927
):
917
928
# type: (...) -> None
918
929
"""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
+ )
920
933
if aggregator is not None :
921
934
aggregator .add (
922
935
"g" , key , value , unit , tags , timestamp , local_aggregator , stacklevel
0 commit comments