open-telemetry / open-telemetry/opentelemetry-python-contrib
WSGI request spans don't have both `http.target` and `http.url` attributes
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
Steps to reproduce
Example code:
from flask import Flask
from opentelemetry.instrumentation.flask import FlaskInstrumentor
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor
from opentelemetry.semconv.trace import SpanAttributes
tracer_provider = TracerProvider()
processor = SimpleSpanProcessor(
ConsoleSpanExporter(
formatter=lambda span: str(
(
span.attributes.get(SpanAttributes.HTTP_TARGET),
span.attributes.get(SpanAttributes.HTTP_URL),
)
)
)
)
tracer_provider.add_span_processor(processor)
app = Flask(__name__)
FlaskInstrumentor().instrument_app(app, tracer_provider=tracer_provider)
@app.route('/hello')
def hello():
return 'hello'
app.run()
Then visit http://localhost:5000/hello
What is the expected behavior?
('/hello', 'http://localhost:5000/hello')
What is the actual behavior?
('/hello', None)
Additional context
The current code looks like this:
The first commit of the file shows essentially the same:
I don't know under what circumstances the target is missing and the full URL is present instead, but I don't understand why only one or the other is included instead of both.
By comparison, the ASGI instrumentation happily includes both:
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
Read instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/init.py at the linked lines, then compare the corresponding ASGI instrumentation. Run the Flask reproduction to inspect both attributes; done means the WSGI span reports http.target as /hello and http.url as the full URL.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- flask, python
- Domain
- observability-sre
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100