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

Put http.route attribute onto http.server.duration on Play framework request processing #7801

Merged
merged 8 commits into from
Feb 14, 2023

Commits on Feb 11, 2023

  1. Put http_route attribute onto http_server_duration on Play framew…

    …ork request processing
    
    Basically, `akka-http` instrumenter has the responsibility to
    instrument the `http_server_duration`, but the current implementation
    has not marked the `http_route` attribute.
    ref: https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/8e8161cb2e5b27d78b8afb7872df17cfa25a2f74/instrumentation/akka/akka-http-10.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/akkahttp/server/AkkaHttpServerAttributesGetter.java#L59
    
    Actually, it's hard to record that attribute by only the akka-http layer
    because that library's request object doesn't hold the route
    information, e.g. placeholder.
    
    So this patch delegates that job to the `play` instrumenter and when
    that has been able to get the route info, the instrumenter puts
    `http_route` attribute onto `http_server_duration`.
    
    For example, when the routes configuration of the Play is like the
    following:
    
    ```
    GET  /foo/:bar  controllers.HomeController.doSomething(bar: String)
    ```
    
    and when it tries to access that API, then OTEL instruments like so:
    
    ```prometheus
    http_server_duration_count{otel_scope_name="io.opentelemetry.akka-http-10.0",otel_scope_version="1.23.0-alpha-SNAPSHOT",http_flavor="1.1",http_method="GET",http_route="/foo/$bar<[^/]+>",http_scheme="http",http_status_code="200",net_host_name="localhost",net_host_port="9000"} 1.0 1676078079798
    http_server_duration_sum{otel_scope_name="io.opentelemetry.akka-http-10.0",otel_scope_version="1.23.0-alpha-SNAPSHOT",http_flavor="1.1",http_method="GET",http_route="/foo/$bar<[^/]+>",http_scheme="http",http_status_code="200",net_host_name="localhost",net_host_port="9000"} 12183.558843 1676078079798
    http_server_duration_bucket{otel_scope_name="io.opentelemetry.akka-http-10.0",otel_scope_version="1.23.0-alpha-SNAPSHOT",http_flavor="1.1",http_method="GET",http_route="/foo/$bar<[^/]+>",http_scheme="http",http_status_code="200",net_host_name="localhost",net_host_port="9000",le="0.0"} 0.0 1676078079798
    ...
    http_server_duration_bucket{otel_scope_name="io.opentelemetry.akka-http-10.0",otel_scope_version="1.23.0-alpha-SNAPSHOT",http_flavor="1.1",http_method="GET",http_route="/foo/$bar<[^/]+>",http_scheme="http",http_status_code="200",net_host_name="localhost",net_host_port="9000",le="+Inf"} 1.0 1676078079798
    ```
    
    Rel: open-telemetry#1415
    
    Signed-off-by: moznion <[email protected]>
    moznion committed Feb 11, 2023
    Configuration menu
    Copy the full SHA
    451c07b View commit details
    Browse the repository at this point in the history
  2. Leave a note for Play auto instrumentation about http.route attri…

    …bute
    
    Signed-off-by: moznion <[email protected]>
    moznion committed Feb 11, 2023
    Configuration menu
    Copy the full SHA
    dbc69e4 View commit details
    Browse the repository at this point in the history

Commits on Feb 13, 2023

  1. Add a smoke test case to check whether the http.route attribute is …

    …in a server span with Play framework
    
    Signed-off-by: moznion <[email protected]>
    moznion committed Feb 13, 2023
    Configuration menu
    Copy the full SHA
    5151da5 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    871ce5f View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    ff97ca1 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    5be95b8 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    6109ae3 View commit details
    Browse the repository at this point in the history
  6. Tidy up the method names for consistency

    Signed-off-by: moznion <[email protected]>
    moznion committed Feb 13, 2023
    Configuration menu
    Copy the full SHA
    d52b750 View commit details
    Browse the repository at this point in the history