44import  pytest 
55
66import  sentry_sdk 
7- from  sentry_sdk  import  _metrics 
87from  sentry_sdk  import  get_client 
98from  sentry_sdk .envelope  import  Envelope 
109from  sentry_sdk .types  import  Metric 
@@ -39,9 +38,9 @@ def test_metrics_disabled_by_default(sentry_init, capture_envelopes):
3938
4039    envelopes  =  capture_envelopes ()
4140
42-     _metrics .count ("test.counter" , 1 )
43-     _metrics .gauge ("test.gauge" , 42 )
44-     _metrics .distribution ("test.distribution" , 200 )
41+     sentry_sdk . metrics .count ("test.counter" , 1 )
42+     sentry_sdk . metrics .gauge ("test.gauge" , 42 )
43+     sentry_sdk . metrics .distribution ("test.distribution" , 200 )
4544
4645    assert  len (envelopes ) ==  0 
4746
@@ -50,9 +49,9 @@ def test_metrics_basics(sentry_init, capture_envelopes):
5049    sentry_init (_experiments = {"enable_metrics" : True })
5150    envelopes  =  capture_envelopes ()
5251
53-     _metrics .count ("test.counter" , 1 )
54-     _metrics .gauge ("test.gauge" , 42 , unit = "millisecond" )
55-     _metrics .distribution ("test.distribution" , 200 , unit = "second" )
52+     sentry_sdk . metrics .count ("test.counter" , 1 )
53+     sentry_sdk . metrics .gauge ("test.gauge" , 42 , unit = "millisecond" )
54+     sentry_sdk . metrics .distribution ("test.distribution" , 200 , unit = "second" )
5655
5756    get_client ().flush ()
5857    metrics  =  envelopes_to_metrics (envelopes )
@@ -81,7 +80,7 @@ def test_metrics_experimental_option(sentry_init, capture_envelopes):
8180    sentry_init (_experiments = {"enable_metrics" : True })
8281    envelopes  =  capture_envelopes ()
8382
84-     _metrics .count ("test.counter" , 5 )
83+     sentry_sdk . metrics .count ("test.counter" , 5 )
8584
8685    get_client ().flush ()
8786
@@ -99,7 +98,7 @@ def test_metrics_with_attributes(sentry_init, capture_envelopes):
9998    )
10099    envelopes  =  capture_envelopes ()
101100
102-     _metrics .count (
101+     sentry_sdk . metrics .count (
103102        "test.counter" , 1 , attributes = {"endpoint" : "/api/test" , "status" : "success" }
104103    )
105104
@@ -121,7 +120,7 @@ def test_metrics_with_user(sentry_init, capture_envelopes):
121120    sentry_sdk .set_user (
122121        {
"id" : 
"user-123" , 
"email" : 
"[email protected] " , 
"username" : 
"testuser" }
123122    )
124-     _metrics .count ("test.user.counter" , 1 )
123+     sentry_sdk . metrics .count ("test.user.counter" , 1 )
125124
126125    get_client ().flush ()
127126
@@ -138,7 +137,7 @@ def test_metrics_with_span(sentry_init, capture_envelopes):
138137    envelopes  =  capture_envelopes ()
139138
140139    with  sentry_sdk .start_transaction (op = "test" , name = "test-span" ):
141-         _metrics .count ("test.span.counter" , 1 )
140+         sentry_sdk . metrics .count ("test.span.counter" , 1 )
142141
143142    get_client ().flush ()
144143
@@ -154,7 +153,7 @@ def test_metrics_tracing_without_performance(sentry_init, capture_envelopes):
154153    sentry_init (_experiments = {"enable_metrics" : True })
155154    envelopes  =  capture_envelopes ()
156155
157-     _metrics .count ("test.span.counter" , 1 )
156+     sentry_sdk . metrics .count ("test.span.counter" , 1 )
158157
159158    get_client ().flush ()
160159
@@ -197,8 +196,8 @@ def _before_metric(record, hint):
197196    )
198197    envelopes  =  capture_envelopes ()
199198
200-     _metrics .count ("test.skip" , 1 )
201-     _metrics .count ("test.keep" , 1 )
199+     sentry_sdk . metrics .count ("test.skip" , 1 )
200+     sentry_sdk . metrics .count ("test.keep" , 1 )
202201
203202    get_client ().flush ()
204203
0 commit comments