Skip to content

Commit

Permalink
add code to paste attribute from child back to parent
Browse files Browse the repository at this point in the history
  • Loading branch information
linglp committed Jan 16, 2025
1 parent d9d1ed5 commit 2d7caa6
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions schematic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,21 @@ def on_start(self, span: Span, parent_context: SpanContext) -> None:
if parent_span is not None and parent_span.is_recording():
for attribute in self.attributes_to_propagate:
# Check if the attribute exists in the parent span's attributes
value = parent_span.attributes.get(attribute)
if value:
attribute_val = parent_span.attributes.get(attribute)
if attribute_val:
# Propagate the attribute to the current span
span.set_attribute(attribute, value)
span.set_attribute(attribute, attribute_val)

def on_end(self, span: Span) -> None:
"""No-op method that does nothing when the span ends."""
pass
"""Propagates attributes from the child span back to the parent span"""
parent_span = get_current_span()
if parent_span is not None and parent_span.is_recording():
for attribute in self.attributes_to_propagate:
child_val = span.attributes.get(attribute)
parent_val = parent_span.attributes.get(attribute)
if child_val and not parent_val:
# Propagate the attribute back to parent span
parent_span.set_attribute(attribute, child_val)

def shutdown(self) -> None:
"""No-op method that does nothing when the span processor is shut down."""
Expand Down

0 comments on commit 2d7caa6

Please sign in to comment.