open-telemetry / open-telemetry/opentelemetry-python-contrib
Illegal access to span.kind
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
Describe your environment
No response
What happened?
Several instrumentation modules seem to access a kind property of Span objects, even though no such property exists in the Span ABC. The implementations seem to assume that opentelemetry-sdk is active, which uses its own Span class deriving from ReadableSpan, which in turn provides a kind property.
Here is an overview of modules making that erroneous assumption:
$ ag '\.kind\b' $(ag -l '\.kind\b' instrumentation/opentelemetry-instrumentation-* | grep -v '/tests/')
instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py
714: if current_span.kind == trace.SpanKind.SERVER:
870: and server_span.kind == trace.SpanKind.SERVER
instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/middleware/otel_middleware.py
259: if span.is_recording() and span.kind == SpanKind.SERVER:
275: if span.is_recording() and span.kind == SpanKind.SERVER:
369: if span.is_recording() and span.kind == SpanKind.SERVER:
396: if span.is_recording() and span.kind == SpanKind.SERVER:
instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py
356: if span.is_recording() and span.kind == trace.SpanKind.SERVER:
488: if span.is_recording() and span.kind == trace.SpanKind.SERVER:
instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py
374: and span.kind == trace.SpanKind.SERVER
461: if span.is_recording() and span.kind == trace.SpanKind.SERVER:
instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/callbacks.py
115: if span.kind == trace.SpanKind.SERVER:
236: if span.is_recording() and span.kind == trace.SpanKind.SERVER:
instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/__init__.py
504: if span.is_recording() and span.kind == trace.SpanKind.SERVER:
564: if ctx.span.is_recording() and ctx.span.kind == trace.SpanKind.SERVER:
instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py
611: if span.is_recording() and span.kind == trace.SpanKind.SERVER:
647: if span.is_recording() and span.kind == trace.SpanKind.SERVER:
Steps to Reproduce
Expected Result
Actual Result
Additional context
No response
Would you like to implement a fix?
None
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Span ABC in opentelemetry-api/src/opentelemetry/trace/span.py and compare it with the SDK Span and ReadableSpan definitions referenced in the issue. Review each listed instrumentation file for accesses to span.kind, then verify that all affected modules work against the API Span interface rather than assuming the SDK implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100