Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[azure-core-tracing-opentelemetry] Exception while exporting Span batch #25112

Closed
aurelien-wefight opened this issue Jul 6, 2022 · 5 comments
Assignees
Labels
Azure.Core customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team OpenTelemetry OpenTelemetry instrumentation (not Monitor-specific) question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@aurelien-wefight
Copy link

  • 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

@ghost ghost added customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Jul 6, 2022
@mccoyp
Copy link
Member

mccoyp commented Jul 6, 2022

Hi @aurelien-wefight, thank you for opening an issue! I'll tag the appropriate folks so we can look into this as soon as possible.

@mccoyp mccoyp added the OpenTelemetry OpenTelemetry instrumentation (not Monitor-specific) label Jul 6, 2022
@ghost ghost added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Jul 6, 2022
@aurelien-wefight
Copy link
Author

aurelien-wefight commented Jul 6, 2022

Hi @mccoyp ,

If it can help you, I add OpenTelemetrySpanKind.INTERNAL if value is None else inside the init function of OpenTelemetrySpan class, and now it works... But I don't know if it's the best idea !

@xiangyan99
Copy link
Member

@aurelien-wefight Thanks for the information. Could you help to try latest azure-core?

It looks to me #24492 could be the fix.

@rakshith91
Copy link
Contributor

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

@aurelien-wefight
Copy link
Author

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

@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Azure.Core customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team OpenTelemetry OpenTelemetry instrumentation (not Monitor-specific) question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

4 participants