Skip to content

Commit c70e0f1

Browse files
committed
Rework trace_id
1 parent c21ad0d commit c70e0f1

File tree

8 files changed

+208
-108
lines changed

8 files changed

+208
-108
lines changed

graphsignal/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from graphsignal.version import __version__
77
from graphsignal.tracer import Tracer
8-
from graphsignal.spans import Span
8+
from graphsignal.spans import Span, SpanContext
99

1010
logger = logging.getLogger('graphsignal')
1111

@@ -210,6 +210,7 @@ def shutdown() -> None:
210210
'shutdown',
211211
'trace',
212212
'function_trace',
213+
'SpanContext',
213214
'Span',
214215
'score',
215216
'set_tag',

graphsignal/client/models/span.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Span(BaseModel):
3232
Span
3333
""" # noqa: E501
3434
span_id: StrictStr = Field(description="Unique identifier for the span.")
35-
root_span_id: Optional[StrictStr] = Field(default=None, description="Identifier of the root span, if this is a child span.")
35+
trace_id: Optional[StrictStr] = Field(default=None, description="Identifier of the trace.")
3636
parent_span_id: Optional[StrictStr] = Field(default=None, description="Identifier of the parent span, if this is a nested span.")
3737
linked_span_ids: Optional[List[StrictStr]] = Field(default=None, description="List of linked span identifiers.")
3838
start_us: StrictInt = Field(description="Start time of the span in microseconds.")
@@ -42,7 +42,7 @@ class Span(BaseModel):
4242
params: Optional[List[Param]] = Field(default=None, description="List of parameters associated with the span.")
4343
counters: Optional[List[Counter]] = Field(default=None, description="Counters associated with the span.")
4444
profiles: Optional[List[Profile]] = Field(default=None, description="List of profiles related to the span.")
45-
__properties: ClassVar[List[str]] = ["span_id", "root_span_id", "parent_span_id", "linked_span_ids", "start_us", "end_us", "tags", "exceptions", "params", "counters", "profiles"]
45+
__properties: ClassVar[List[str]] = ["span_id", "trace_id", "parent_span_id", "linked_span_ids", "start_us", "end_us", "tags", "exceptions", "params", "counters", "profiles"]
4646

4747
model_config = ConfigDict(
4848
populate_by_name=True,
@@ -131,7 +131,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
131131

132132
_obj = cls.model_validate({
133133
"span_id": obj.get("span_id"),
134-
"root_span_id": obj.get("root_span_id"),
134+
"trace_id": obj.get("trace_id"),
135135
"parent_span_id": obj.get("parent_span_id"),
136136
"linked_span_ids": obj.get("linked_span_ids"),
137137
"start_us": obj.get("start_us"),

graphsignal/recorders/pytorch_recorder.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import logging
22
import os
3-
import random
43
import json
54
import time
65
import torch
@@ -26,7 +25,7 @@ def on_span_start(self, span, context):
2625
# profiler active, skip
2726
# only one profiler is allowed per process, so we don't need global locks
2827
return
29-
if random.random() > graphsignal._tracer.profiling_rate:
28+
if not span.profiled():
3029
return
3130

3231
if not self._torch_prof:

0 commit comments

Comments
 (0)