-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Closed
Labels
Azure.CoreClientThis issue points to a problem in the data-plane of the library.This issue points to a problem in the data-plane of the library.bugThis issue requires a change to an existing behavior in the product in order to be resolved.This issue requires a change to an existing behavior in the product in order to be resolved.
Milestone
Description
- azure-core-tracing-opentelemetry:
- 1.0.0b4:
- Windows:
- 3.7.4:
Describe the bug
When configuring a tracer - any SDK calls made in-between configuring the Core tracing settings and building a tracer will fail with an AttributeError.
This issue can be worked around if the tracer is configured before any other SDK calls are made.
To Reproduce
# Import and set core tracing configuration
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import ConsoleSpanExporter
from opentelemetry.sdk.trace.export import SimpleExportSpanProcessor
from azure.core.settings import settings
from azure.core.tracing.ext.opentelemetry_span import OpenTelemetrySpan
settings.tracing_implementation = OpenTelemetrySpan
# Create cosmos container (could be any operation)
container = client.create_container(name)
# Create tracer
trace.set_tracer_provider(TracerProvider())
trace.get_tracer_provider().add_span_processor(
SimpleExportSpanProcessor(ConsoleSpanExporter())
)
tracer = trace.get_tracer(__name__)
# Use tracer span with operation
with tracer.start_as_current_span('MyApplication'):
for i in range(3):
document_definition = {'pk': 'pk', 'id': 'myId' + str(uuid.uuid4())}
container.create_item(document_definition)Observed behavior
Stacktrace:
> container = client.create_container(name)
test\test_telemetry.py:81:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test\test_config.py:118: in create_multi_partition_collection_with_custom_pk_if_not_exist
cls.THROUGHPUT_FOR_5_PARTITIONS, True)
test\test_config.py:141: in create_collection_with_required_throughput
offer_throughput=throughput)
..\..\..\env_cosmos\lib\site-packages\azure\core\tracing\decorator.py:91: in wrapper_use_tracer
with span_impl_type(name=name) as span:
..\..\..\env_cosmos\lib\site-packages\azure\core\tracing\ext\opentelemetry_span\__init__.py:126: in __enter__
self.start()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <azure.core.tracing.ext.opentelemetry_span.OpenTelemetrySpan object at 0x0000022D3CBA3A08>
def start(self):
# type: () -> None
"""Set the start time for a span."""
> self.span_instance.start()
E AttributeError: 'DefaultSpan' object has no attribute 'start'
Expected behavior
Tracing is only applied to the statements within the context manager.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Azure.CoreClientThis issue points to a problem in the data-plane of the library.This issue points to a problem in the data-plane of the library.bugThis issue requires a change to an existing behavior in the product in order to be resolved.This issue requires a change to an existing behavior in the product in order to be resolved.