File tree Expand file tree Collapse file tree 4 files changed +27
-0
lines changed Expand file tree Collapse file tree 4 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 36
36
" OTLP" ,
37
37
" postprocessors" ,
38
38
" pydantic" ,
39
+ " pyment" ,
39
40
" Quantile" ,
40
41
" quickstart" ,
41
42
" referer" ,
Original file line number Diff line number Diff line change
1
+ first_line = false
2
+ quotes = """
3
+ output_style = google
4
+ input_style = auto
5
+ init2class = false
6
+ indent = 4
Original file line number Diff line number Diff line change @@ -206,6 +206,7 @@ dependencies = [
206
206
[tool .hatch .envs .docs ]
207
207
detached = true
208
208
dependencies = [
209
+ " pyment" ,
209
210
" interrogate" ,
210
211
]
211
212
Original file line number Diff line number Diff line change 12
12
13
13
14
14
class SpanModifier :
15
+ """
16
+ A class that modifies spans with the specified resource attributes.
17
+ """
18
+
15
19
__slots__ = ("_resource" ,)
16
20
17
21
def __init__ (self , resource : Resource ) -> None :
18
22
self ._resource = resource
19
23
20
24
def modify_resource (self , span : ReadableSpan ) -> None :
25
+ """
26
+ Takes a span and merges in the resource attributes specified in the constructor.
27
+
28
+ Args:
29
+ span: ReadableSpan: the span to modify
30
+ """
21
31
if (ctx := span ._context ) is None or ctx .span_id == INVALID_TRACE_ID :
22
32
return
23
33
span ._resource = span ._resource .merge (self ._resource )
@@ -59,6 +69,15 @@ def _monkey_patch_span_init() -> Iterator[None]:
59
69
60
70
@contextmanager
61
71
def capture_spans (resource : Resource ) -> Iterator [SpanModifier ]:
72
+ """
73
+ A context manager that captures spans and modifies them with the specified resources.
74
+
75
+ Args:
76
+ resource: Resource: The resource to merge into the spans created within the context.
77
+
78
+ Returns:
79
+ modifier: Iterator[SpanModifier]: The span modifier that is active within the context.
80
+ """
62
81
modifier = SpanModifier (resource )
63
82
with _monkey_patch_span_init ():
64
83
token = _ACTIVE_MODIFIER .set (modifier )
You can’t perform that action at this time.
0 commit comments