Skip to content

Attribute http_route is not recorded by server metric when using servlet 2.0/3.0. #12353

@k3v1n1k88

Description

@k3v1n1k88

Describe the bug

While using the OpenTelemetry Java agent on an application that uses Servlet 2.0/3.0, the http_route attribute is not recorded by the server metrics. It appears as follows:

http_server_request_duration_seconds_count{http_request_method="POST",http_response_status_code="200",network_protocol_version="1.1",otel_scope_name="io.opentelemetry.jetty-8.0",otel_scope_version="2.8.0-alpha",url_scheme="http"}

Steps to reproduce

Here's a clearer and more structured version of your steps:

  1. Build HTTP Server Using Jetty Embedded 9.3 (Servlet 3.0)

    • Create an HTTP server using Jetty embedded 9.3, which supports Servlet 3.0.
  2. Run Java Agent with Prometheus Exporter Enabled on Port 9464

    • Start the application with the OpenTelemetry Java agent and enable the Prometheus exporter on port 9464:
    java -javaagent:opentelemetry-javaagent.jar -Dotel.metrics.exporter=prometheus -Dotel.exporter.prometheus.port=9464 -jar myapp.jar
  3. Send a Request to the Application

    • Make a request to the running application to trigger the server-side metrics:
    curl http://localhost:8080/your-endpoint
  4. Load Metrics via Prometheus

    • Retrieve the metrics exposed by the Prometheus exporter:
    curl http://localhost:9464/metrics
  5. Find the http_server_request_duration_seconds_count Metric

    • Look for the http_server_request_duration_seconds_count metric in the Prometheus output to check the recorded server request duration.

Expected behavior

The metric http_server_request_duration_seconds_count should contain the http_route attribute

http_server_request_duration_seconds_count{http_request_method="POST",http_response_status_code="200",http_route="/api/hello",network_protocol_version="1.1",otel_scope_name="io.opentelemetry.jetty-8.0",otel_scope_version="2.8.0-alpha",url_scheme="http"} 1

Actual behavior

The metric http_server_request_duration_seconds_count does not contain the http_route attribute.
http_server_request_duration_seconds_count{http_request_method="POST",http_response_status_code="200",network_protocol_version="1.1",otel_scope_name="io.opentelemetry.jetty-8.0",otel_scope_version="2.8.0-alpha",url_scheme="http"} 1`

Javaagent or library instrumentation version

2.8.0

Environment

JDK: OpenJDK 11.0.23
OS: Ubuntu 20.04
Jetty Embedded 9.3, Servlet 3

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds author feedbackWaiting for additional feedback from the authorneeds triageNew issue that requires triagestale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions