Skip to content

Commit 93469a9

Browse files
chore: add pyment config (#3648)
* chore: add pyment * pyment config * add docs to tracing * fix strings * Update pyment.conf Co-authored-by: Xander Song <[email protected]> --------- Co-authored-by: Xander Song <[email protected]>
1 parent 76439cf commit 93469a9

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"OTLP",
3737
"postprocessors",
3838
"pydantic",
39+
"pyment",
3940
"Quantile",
4041
"quickstart",
4142
"referer",

pyment.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
first_line = false
2+
quotes = """
3+
output_style = google
4+
input_style = auto
5+
init2class = false
6+
indent = 4

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ dependencies = [
206206
[tool.hatch.envs.docs]
207207
detached = true
208208
dependencies = [
209+
"pyment",
209210
"interrogate",
210211
]
211212

src/phoenix/datasets/tracing.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,22 @@
1212

1313

1414
class SpanModifier:
15+
"""
16+
A class that modifies spans with the specified resource attributes.
17+
"""
18+
1519
__slots__ = ("_resource",)
1620

1721
def __init__(self, resource: Resource) -> None:
1822
self._resource = resource
1923

2024
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+
"""
2131
if (ctx := span._context) is None or ctx.span_id == INVALID_TRACE_ID:
2232
return
2333
span._resource = span._resource.merge(self._resource)
@@ -59,6 +69,15 @@ def _monkey_patch_span_init() -> Iterator[None]:
5969

6070
@contextmanager
6171
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+
"""
6281
modifier = SpanModifier(resource)
6382
with _monkey_patch_span_init():
6483
token = _ACTIVE_MODIFIER.set(modifier)

0 commit comments

Comments
 (0)