[azure-core-tracing-opentelemetry] Exception while exporting Span batch
See original GitHub issue- Package Name: azure-core-tracing-opentelemetry
- Package Version: 1.0.0b9
- Operating System: python:3.9-slim-buster
- Python Version: 3.9.13
Describe the bug I try to implement opentelemetry like in your documentation: https://pypi.org/project/azure-core-tracing-opentelemetry/ But when I run the code, just before exporting spans, I get the error:
Exception while exporting Span batch.
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/opentelemetry/sdk/trace/export/__init__.py", line 367, in _export_batch
self.span_exporter.export(self.spans_list[:idx]) # type: ignore
File "/usr/local/lib/python3.9/site-packages/opentelemetry/exporter/otlp/proto/grpc/trace_exporter/__init__.py", line 291, in export
return self._export(spans)
File "/usr/local/lib/python3.9/site-packages/opentelemetry/exporter/otlp/proto/grpc/exporter.py", line 293, in _export
request=self._translate_data(data),
File "/usr/local/lib/python3.9/site-packages/opentelemetry/exporter/otlp/proto/grpc/trace_exporter/__init__.py", line 277, in _translate_data
f"SPAN_KIND_{sdk_span.kind.name}",
AttributeError: 'NoneType' object has no attribute 'name'
To Reproduce Steps to reproduce the behavior:
- Write python code:
import os
from azure.storage.blob import BlobServiceClient
from azure.core.settings import settings
from azure.core.tracing.ext.opentelemetry_span import OpenTelemetrySpan
settings.tracing_implementation = OpenTelemetrySpan
connect_str = os.getenv("AZURE_STORAGE_CONNECTION_STRING")
_blob_service_client = (
BlobServiceClient.from_connection_string(connect_str) if connect_str else None
)
container = "XXX"
key = "XXX.pkl"
blob_client = _blob_service_client.get_blob_client(container=container, blob=key)
blob_client.download_blob().readall()
Command:
opentelemetry-instrument --metrics_exporter none --logs_exporter none --traces_exporter otlp_proto_grpc --exporter_otlp_traces_insecure true python3 main.py
If I comment settings.tracing_implementation = OpenTelemetrySpan
readall
works well without error- Instrumentation works with another module like Flask.
Expected behavior I wan’t to have spans generated
Screenshots If applicable, add screenshots to help explain your problem.
Additional context My requirements:
azure-core==1.13.0 azure-core-tracing-opentelemetry==1.0.0b9 azure-storage-blob==12.8.1 opentelemetry-api==1.12.0rc2 opentelemetry-distro==0.32b0 opentelemetry-exporter-otlp-proto-grpc==1.12.0rc2 opentelemetry-instrumentation==0.32b0 opentelemetry-instrumentation-urllib==0.32b0 opentelemetry-instrumentation-wsgi==0.32b0 opentelemetry-sdk==1.12.0rc2 opentelemetry-semantic-conventions==0.32b0 opentelemetry-util-http==0.32b0 urllib3==1.26.4
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Hi @xiangyan99 and @rakshith91 ! Thank you for your replies. I didn’t think to check my azure-core version and the latest version 🤦 I confirm that it works now.
Sorry for the inconvenience
@aurelien-wefight Thanks for the issue - like @xiangyan99 mentioned, I believe it should be fixed with the latest azure-core where span kind is internal by default. And yes,
OpenTelemetrySpanKind.INTERNAL if value is None else
should be good (azure-core does that for you now)