Skip to content

Commit

Permalink
Stop setting attributes on closed spans (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
Guðmundur Björn Birkisson authored May 4, 2023
1 parent 5e37708 commit c16d9b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "troncos"
version = "3.1.1"
version = "3.1.2"
description = "Collection of Python logging, tracing and profiling tools"
authors = [
"Guðmundur Björn Birkisson <[email protected]>",
Expand Down
12 changes: 9 additions & 3 deletions troncos/traces/dd_shim.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(
dd_span: Any,
base_resources: Attributes,
default_resource: Resource,
dd_traces_exported: bool,
ignore_attrs: list[str],
) -> None:
super().__init__(
Expand All @@ -38,6 +39,13 @@ def __init__(
)
self.start(dd_span.start_ns)
self._apply_translation(dd_span, ignore_attrs)
if dd_traces_exported:
self.set_attributes(
{
"dd_trace_id": str(dd_span.trace_id),
"dd_span_id": str(dd_span.span_id),
}
)
self.end(dd_span.start_ns + dd_span.duration_ns)

@staticmethod
Expand Down Expand Up @@ -169,12 +177,10 @@ def on_span_finish(self, dd_span: Any) -> None:
span = _TranslatedSpan(
dd_span,
base_resources=self._base_resources, # type: ignore[arg-type]
dd_traces_exported=self._dd_traces_exported,
default_resource=self._default_resource,
ignore_attrs=self._dd_span_ignore_attr,
)
if self._dd_traces_exported:
span.set_attribute("dd_trace_id", str(dd_span.trace_id))
span.set_attribute("dd_span_id", str(dd_span.span_id))
for p in self._otel_procs:
p.on_end(span)

Expand Down

0 comments on commit c16d9b4

Please sign in to comment.