Parent is now always passed in via Context, intead of Span or SpanContext (#1146)

Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
This commit is contained in:
alrex 2020-10-08 08:39:04 -07:00 committed by alrex
parent 9eb4469d83
commit fd65ab29cb
3 changed files with 5 additions and 5 deletions

View File

@ -34,7 +34,7 @@ with tracer.start_as_current_span("foo") as foo:
foo.set_attribute("my_atribbute", True) foo.set_attribute("my_atribbute", True)
foo.add_event("event in foo", {"name": "foo1"}) foo.add_event("event in foo", {"name": "foo1"})
with tracer.start_as_current_span( with tracer.start_as_current_span(
"bar", links=[trace.Link(foo.get_context())] "bar", links=[trace.Link(foo.get_span_context())]
) as bar: ) as bar:
time.sleep(0.2) time.sleep(0.2)
bar.set_attribute("speed", 100.0) bar.set_attribute("speed", 100.0)

View File

@ -192,7 +192,7 @@ def _translate_to_jaeger(spans: Span):
jaeger_spans = [] jaeger_spans = []
for span in spans: for span in spans:
ctx = span.get_context() ctx = span.get_span_context()
trace_id = ctx.trace_id trace_id = ctx.trace_id
span_id = ctx.span_id span_id = ctx.span_id

View File

@ -144,7 +144,7 @@ class TestJaegerSpanExporter(unittest.TestCase):
span_context = trace_api.SpanContext( span_context = trace_api.SpanContext(
trace_id, span_id, is_remote=False trace_id, span_id, is_remote=False
) )
parent_context = trace_api.SpanContext( parent_span_context = trace_api.SpanContext(
trace_id, parent_id, is_remote=False trace_id, parent_id, is_remote=False
) )
other_context = trace_api.SpanContext( other_context = trace_api.SpanContext(
@ -190,13 +190,13 @@ class TestJaegerSpanExporter(unittest.TestCase):
trace._Span( trace._Span(
name=span_names[0], name=span_names[0],
context=span_context, context=span_context,
parent=parent_context, parent=parent_span_context,
events=(event,), events=(event,),
links=(link,), links=(link,),
kind=trace_api.SpanKind.CLIENT, kind=trace_api.SpanKind.CLIENT,
), ),
trace._Span( trace._Span(
name=span_names[1], context=parent_context, parent=None name=span_names[1], context=parent_span_context, parent=None
), ),
trace._Span( trace._Span(
name=span_names[2], context=other_context, parent=None name=span_names[2], context=other_context, parent=None