1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
# ------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
import threading
from azure.core.tracing.ext.opentelemetry_span import OpenTelemetrySpan
def test_get_span_from_thread(tracer):
result = []
def get_span_from_thread(output):
current_span = OpenTelemetrySpan.get_current_span()
output.append(current_span)
with tracer.start_as_current_span(name="TestSpan") as span:
thread = threading.Thread(
target=OpenTelemetrySpan.with_current_context(get_span_from_thread),
args=(result,)
)
thread.start()
thread.join()
assert span is result[0]
|