open-telemetry / open-telemetry/opentelemetry-python-contrib
Metric exporter not adding http routes or path to metrics
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
I'm running a Flask application and I tried enabling metrics using "export OTEL_METRICS_EXPORTER=otlp_proto_grpc". This works fine but the output could be more useful if it included the urls being hit. I only see http_host="localhost:5000",http_method="GET" instead of something like localhost:5000/login.
I started a slack question on the topic here:
https://cloud-native.slack.com/archives/C01PD4HUVBL/p1678719030193089
Aaron Abbott wrote "so http.route is "conditionally required". I think we should update the instrumentations to add it if available"
OTel Instrumentations
opentelemetry-instrumentation==0.37b0
opentelemetry-instrumentation-dbapi==0.37b0
opentelemetry-instrumentation-flask==0.37b0
opentelemetry-instrumentation-jinja2==0.37b0
opentelemetry-instrumentation-requests==0.37b0
opentelemetry-instrumentation-sqlite3==0.37b0
opentelemetry-instrumentation-wsgi==0.37b0
Partial Prometheus output
HELP http_server_active_requests measures the number of concurrent HTTP requests that are currently in-flight
TYPE http_server_active_requests gauge
http_server_active_requests{http_flavor="1.1",http_host="localhost:5000",http_method="GET",http_scheme="http",http_server_name="127.0.0.1",job="demo-flask",service_name="demo-flask",telemetry_auto_version="0.37b0",telemetry_sdk_language="python",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="1.16.0"} 0 1678718765640
http_server_active_requests{http_flavor="1.1",http_host="localhost:5000",http_method="POST",http_scheme="http",http_server_name="127.0.0.1",job="demo-flask",service_name="demo-flask",telemetry_auto_version="0.37b0",telemetry_sdk_language="python",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="1.16.0"} 0 1678718765640
HELP http_server_duration measures the duration of the inbound HTTP request
TYPE http_server_duration histogram
http_server_duration_bucket{http_flavor="1.1",http_host="localhost:5000",http_method="GET",http_scheme="http",http_server_name="127.0.0.1",http_status_code="200",job="demo-flask",net_host_port="5000",service_name="demo-flask",telemetry_auto_version="0.37b0",telemetry_sdk_language="python",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="1.16.0",le="0"} 0 1678718765640
http_server_duration_bucket{http_flavor="1.1",http_host="localhost:5000",http_method="GET",http_scheme="http",http_server_name="127.0.0.1",http_status_code="200",job="demo-flask",net_host_port="5000",service_name="demo-flask",telemetry_auto_version="0.37b0",telemetry_sdk_language="python",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="1.16.0",le="5"} 9 1678718765640
http_server_duration_bucket{http_flavor="1.1",http_host="localhost:5000",http_method="GET",http_scheme="http",http_server_name="127.0.0.1",http_status_code="200",job="demo-flask",net_host_port="5000",service_name="demo-flask",telemetry_auto_version="0.37b0",telemetry_sdk_language="python",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="1.16.0",le="10"} 11 1678718765640
http_server_duration_bucket{http_flavor="1.1",http_host="localhost:5000",http_method="GET",http_scheme="http",http_server_name="127.0.0.1",http_status_code="200",job="demo-flask",net_host_port="5000",service_name="demo-flask",telemetry_auto_version="0.37b0",telemetry_sdk_language="python",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="1.16.0",le="25"} 11 1678718765640
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 Flask instrumentation and reproduce the reported metrics using routes such as /login. Compare the generated Prometheus labels with the provided output and verify that the applicable HTTP route or path is included when available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- flask, python
- Domain
- backend, observability
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100