question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[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:

  1. 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:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
aurelien-wefightcommented, Jul 7, 2022

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

0reactions
rakshith91commented, Jul 7, 2022

@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)

Read more comments on GitHub >

github_iconTop Results From Across the Web

OpenTelemetry gRPC exporter fails because SpanKind is None
Package Name: azure-core-tracing-opentelemetry Package Version: 1.0.0b9 Operating System: Windows ... Exception while exporting Span batch.
Read more >
Source code for opentelemetry.sdk.trace.export - NET
Sequence[Span]) -> "SpanExportResult": """Exports a batch of telemetry data. ... except Exception: logger.exception("Exception while exporting Span.
Read more >
Microsoft OpenTelemetry exporter for Azure Monitor
Custom dependencies are tracked via spans and telemetry is exported to application insights with the AzureMonitorTraceExporter. """ import os ...
Read more >
Error handling in OpenTelemetry
The SDK MUST NOT throw unhandled exceptions for errors in their own operations. For example, an exporter should not throw an exception when...
Read more >
Instrument Python applications with OpenTelemetry - Dynatrace
To learn more about how Dynatrace works with OpenTelemetry, see Send data to ... sampling from opentelemetry.sdk.trace.export import ( BatchSpanProcessor, ) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found