@@ -571,18 +571,13 @@ def test_transaction_name(
571571
572572@minimum_python_37_with_gevent
573573@pytest .mark .forked
574- @pytest .mark .parametrize ("sample_rate" , [1.0 , None ])
575574def test_metric_summaries (
576- sentry_init , capture_envelopes , sample_rate , maybe_monkeypatched_threading
575+ sentry_init , capture_envelopes , maybe_monkeypatched_threading
577576):
578577 sentry_init (
579578 release = "fun-release@1.0.0" ,
580579 environment = "not-fun-env" ,
581580 enable_tracing = True ,
582- _experiments = {
583- "enable_metrics" : True ,
584- "metrics_summary_sample_rate" : sample_rate ,
585- },
586581 )
587582 ts = time .time ()
588583 envelopes = capture_envelopes ()
@@ -680,121 +675,6 @@ def test_metric_summaries(
680675 }
681676
682677
683- @minimum_python_37_with_gevent
684- @pytest .mark .forked
685- def test_metrics_summary_disabled (
686- sentry_init , capture_envelopes , maybe_monkeypatched_threading
687- ):
688- sentry_init (
689- release = "fun-release@1.0.0" ,
690- environment = "not-fun-env" ,
691- enable_tracing = True ,
692- _experiments = {"enable_metrics" : True , "metrics_summary_sample_rate" : 0.0 },
693- )
694- ts = time .time ()
695- envelopes = capture_envelopes ()
696-
697- with start_transaction (
698- op = "stuff" , name = "/foo" , source = TRANSACTION_SOURCE_ROUTE
699- ) as transaction :
700- with metrics .timing ("my-timer-metric" , tags = {"a" : "b" }, timestamp = ts ):
701- pass
702-
703- Hub .current .flush ()
704-
705- (transaction , envelope ) = envelopes
706-
707- # Metrics Emission
708- assert envelope .items [0 ].headers ["type" ] == "statsd"
709- m = parse_metrics (envelope .items [0 ].payload .get_bytes ())
710-
711- assert len (m ) == 1
712- assert m [0 ][1 ] == "my-timer-metric@second"
713- assert m [0 ][2 ] == "d"
714- assert len (m [0 ][3 ]) == 1
715- assert m [0 ][4 ] == {
716- "a" : "b" ,
717- "transaction" : "/foo" ,
718- "release" : "fun-release@1.0.0" ,
719- "environment" : "not-fun-env" ,
720- }
721-
722- # Measurement Attachment
723- t = transaction .items [0 ].get_transaction_event ()
724- assert "_metrics_summary" not in t
725- assert "_metrics_summary" not in t ["spans" ][0 ]
726-
727-
728- @minimum_python_37_with_gevent
729- @pytest .mark .forked
730- def test_metrics_summary_filtered (
731- sentry_init , capture_envelopes , maybe_monkeypatched_threading
732- ):
733- def should_summarize_metric (key , tags ):
734- return key == "foo"
735-
736- sentry_init (
737- release = "fun-release@1.0.0" ,
738- environment = "not-fun-env" ,
739- enable_tracing = True ,
740- _experiments = {
741- "enable_metrics" : True ,
742- "metrics_summary_sample_rate" : 1.0 ,
743- "should_summarize_metric" : should_summarize_metric ,
744- },
745- )
746- ts = time .time ()
747- envelopes = capture_envelopes ()
748-
749- with start_transaction (
750- op = "stuff" , name = "/foo" , source = TRANSACTION_SOURCE_ROUTE
751- ) as transaction :
752- metrics .timing ("foo" , value = 3.0 , tags = {"a" : "b" }, timestamp = ts )
753- metrics .timing ("foo" , value = 2.0 , tags = {"b" : "c" }, timestamp = ts )
754- metrics .timing ("bar" , value = 1.0 , tags = {"a" : "b" }, timestamp = ts )
755-
756- Hub .current .flush ()
757-
758- (transaction , envelope ) = envelopes
759-
760- # Metrics Emission
761- assert envelope .items [0 ].headers ["type" ] == "statsd"
762- m = parse_metrics (envelope .items [0 ].payload .get_bytes ())
763-
764- assert len (m ) == 3
765- assert m [0 ][1 ] == "bar@second"
766- assert m [1 ][1 ] == "foo@second"
767- assert m [2 ][1 ] == "foo@second"
768-
769- # Measurement Attachment
770- t = transaction .items [0 ].get_transaction_event ()["_metrics_summary" ]
771- assert len (t ["d:foo@second" ]) == 2
772- assert {
773- "tags" : {
774- "a" : "b" ,
775- "environment" : "not-fun-env" ,
776- "release" : "fun-release@1.0.0" ,
777- "transaction" : "/foo" ,
778- },
779- "min" : 3.0 ,
780- "max" : 3.0 ,
781- "count" : 1 ,
782- "sum" : 3.0 ,
783- } in t ["d:foo@second" ]
784- assert {
785- "tags" : {
786- "b" : "c" ,
787- "environment" : "not-fun-env" ,
788- "release" : "fun-release@1.0.0" ,
789- "transaction" : "/foo" ,
790- },
791- "min" : 2.0 ,
792- "max" : 2.0 ,
793- "count" : 1 ,
794- "sum" : 2.0 ,
795- } in t ["d:foo@second" ]
796-
797-
798678@minimum_python_37_with_gevent
799679@pytest .mark .forked
800680def test_tag_normalization (
0 commit comments