Skip to content

Commit d8dd0ff

Browse files
committed
imports
1 parent f6bed30 commit d8dd0ff

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

sentry_sdk/_metrics.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
import time
77
from typing import Any, Optional, TYPE_CHECKING
88

9+
import sentry_sdk
10+
from sentry_sdk.utils import safe_repr
11+
912
if TYPE_CHECKING:
1013
from sentry_sdk._types import Metric
1114

@@ -18,10 +21,8 @@ def _capture_metric(
1821
attributes=None, # type: Optional[dict[str, Any]]
1922
):
2023
# type: (...) -> None
21-
from sentry_sdk.api import get_client, get_current_scope, get_current_span
22-
from sentry_sdk.utils import safe_repr
2324

24-
client = get_client()
25+
client = sentry_sdk.get_client()
2526

2627
attrs = {} # type: dict[str, Union[str, bool, float, int]
2728
if attributes:
@@ -37,7 +38,7 @@ def _capture_metric(
3738
else safe_repr(v)
3839
)
3940

40-
span = get_current_span()
41+
span = sentry_sdk.get_current_span()
4142
trace_id = "00000000-0000-0000-0000-000000000000"
4243
span_id = None
4344

@@ -46,11 +47,11 @@ def _capture_metric(
4647
trace_id = trace_context.get("trace_id", trace_id)
4748
span_id = trace_context.get("span_id")
4849
else:
49-
scope = get_current_scope()
50+
scope = sentry_sdk.get_current_scope()
5051
if scope:
5152
propagation_context = scope._propagation_context
5253
if propagation_context:
53-
trace_id = propagation_context.get("trace_id", trace_id)
54+
trace_id = propagation_context.trace_id or trace_id
5455

5556
metric = {
5657
"timestamp": time.time(),

0 commit comments

Comments
 (0)