@@ -597,33 +597,37 @@ def test_metric_summaries(sentry_init, capture_envelopes):
597597 t = transaction .items [0 ].get_transaction_event ()
598598
599599 assert t ["_metrics_summary" ] == {
600- "c:root-counter@none" : {
601- "count" : 1 ,
602- "min" : 1.0 ,
603- "max" : 1.0 ,
604- "sum" : 1.0 ,
600+ "c:root-counter@none" : [
601+ {
602+ "count" : 1 ,
603+ "min" : 1.0 ,
604+ "max" : 1.0 ,
605+ "sum" : 1.0 ,
606+ "tags" : {
607+ "transaction" : "/foo" ,
608+ "release" : "fun-release@1.0.0" ,
609+ "environment" : "not-fun-env" ,
610+ },
611+ }
612+ ]
613+ }
614+
615+ assert t ["spans" ][0 ]["_metrics_summary" ]["d:my-dist@none" ] == [
616+ {
617+ "count" : 10 ,
618+ "min" : 0.0 ,
619+ "max" : 9.0 ,
620+ "sum" : 45.0 ,
605621 "tags" : {
606- "transaction" : "/foo" ,
607- "release" : "fun-release@1.0.0" ,
608622 "environment" : "not-fun-env" ,
623+ "release" : "fun-release@1.0.0" ,
624+ "transaction" : "/foo" ,
609625 },
610626 }
611- }
612-
613- assert t ["spans" ][0 ]["_metrics_summary" ]["d:my-dist@none" ] == {
614- "count" : 10 ,
615- "min" : 0.0 ,
616- "max" : 9.0 ,
617- "sum" : 45.0 ,
618- "tags" : {
619- "environment" : "not-fun-env" ,
620- "release" : "fun-release@1.0.0" ,
621- "transaction" : "/foo" ,
622- },
623- }
627+ ]
624628
625629 assert t ["spans" ][0 ]["tags" ] == {"a" : "b" }
626- timer = t ["spans" ][0 ]["_metrics_summary" ]["d:my-timer-metric@second" ]
630+ ( timer ,) = t ["spans" ][0 ]["_metrics_summary" ]["d:my-timer-metric@second" ]
627631 assert timer ["count" ] == 1
628632 assert timer ["max" ] == timer ["min" ] == timer ["sum" ]
629633 assert timer ["sum" ] > 0
@@ -697,6 +701,7 @@ def should_summarize_metric(key, tags):
697701 op = "stuff" , name = "/foo" , source = TRANSACTION_SOURCE_ROUTE
698702 ) as transaction :
699703 metrics .timing ("foo" , value = 1.0 , tags = {"a" : "b" }, timestamp = ts )
704+ metrics .timing ("foo" , value = 1.0 , tags = {"b" : "c" }, timestamp = ts )
700705 metrics .timing ("bar" , value = 1.0 , tags = {"a" : "b" }, timestamp = ts )
701706
702707 Hub .current .flush ()
@@ -707,25 +712,40 @@ def should_summarize_metric(key, tags):
707712 assert envelope .items [0 ].headers ["type" ] == "statsd"
708713 m = parse_metrics (envelope .items [0 ].payload .get_bytes ())
709714
710- assert len (m ) == 2
715+ assert len (m ) == 3
711716 assert m [0 ][1 ] == "bar@second"
712717 assert m [1 ][1 ] == "foo@second"
718+ assert m [2 ][1 ] == "foo@second"
713719
714720 # Measurement Attachment
715721 t = transaction .items [0 ].get_transaction_event ()["_metrics_summary" ]
716722 assert t == {
717- "d:foo@second" : {
718- "tags" : {
719- "a" : "b" ,
720- "environment" : "not-fun-env" ,
721- "release" : "fun-release@1.0.0" ,
722- "transaction" : "/foo" ,
723+ "d:foo@second" : [
724+ {
725+ "tags" : {
726+ "a" : "b" ,
727+ "environment" : "not-fun-env" ,
728+ "release" : "fun-release@1.0.0" ,
729+ "transaction" : "/foo" ,
730+ },
731+ "min" : 1.0 ,
732+ "max" : 1.0 ,
733+ "count" : 1 ,
734+ "sum" : 1.0 ,
723735 },
724- "min" : 1.0 ,
725- "max" : 1.0 ,
726- "count" : 1 ,
727- "sum" : 1.0 ,
728- }
736+ {
737+ "tags" : {
738+ "b" : "c" ,
739+ "environment" : "not-fun-env" ,
740+ "release" : "fun-release@1.0.0" ,
741+ "transaction" : "/foo" ,
742+ },
743+ "min" : 1.0 ,
744+ "max" : 1.0 ,
745+ "count" : 1 ,
746+ "sum" : 1.0 ,
747+ },
748+ ]
729749 }
730750
731751
0 commit comments