Skip to content

The http.route in metric#http_server_request_duration_seconds_bucket shows the {jobName} placeholder instead of the actual job name. #15345

@vijaybtech13

Description

@vijaybtech13

Describe the bug

The SpringBoot application has been instrumented with the OpenTelemetry Java agent. A custom actuator endpoint, /actuator/jobs/DAILY_JOB, has been implemented. However, the generated metric lacks the actual job name in the http.route field.

Metric:
http_server_request_duration_seconds_bucket{
http_route="/actuator/jobs/{jobName}",
http_request_method="POST",

}

Steps to reproduce

Access the custom actuator endpoint /actuator/jobs/DAILY_JOB.
Review the generated metric.

Expected behavior

There are multiple actuator jobs in the application, making it essential to include the job name in the metric to differentiate between them. How can I obtain the job name in the metric?

Metric:
http_server_request_duration_seconds_bucket{
http_route="/actuator/jobs/DAILY_JOB",
http_request_method="POST",
job_name="DAILY_JOB"

}

Actual behavior

The generated metric lacks the actual job name in the http.route field.

Metric:
http_server_request_duration_seconds_bucket{
http_route="/actuator/jobs/{jobName}",
http_request_method="POST",

}

Javaagent or library instrumentation version

Paketo Buildpack for OpenTelemetry 2.17.0 , OpenTelemetry Java Agent 2.21.0

Environment

SpringBoot - 3.4.10
JDK - 21
Server Information - OS: Ubuntu focal (20.04), Kernel: 5.15.0-1077-aws, Platform: Amazon EC2

Additional context

Tried approach:
I attempted the following steps to display the actual job name in the metric, but did not achieve the expected result.

Step 1 - Set span attribute in the controller
@component
@endpoint(id = "jobs")
public class JobsEndpoint {

@ReadOperation
public String runJob(@Selector String jobName) {

    Span span = Span.current();
    span.setAttribute("job.name", jobName);
span.setAttribute("http.route", "/actuator/jobs/" + jobName);

    return "Job " + jobName + " executed";
}

}

Step 2 - Added the following otel env variables
OTEL_JAVAAGENT_ENABLED: "true"
OTEL_METRICS_EXPORTER: otlp
OTEL_ATTRIBUTE_FILTER: metrics:job.name
OTEL_SEMCONV_STABILITY_OPT_IN: http
OTEL_JAVAAGENT_EXPERIMENTAL_SPAN_METRICS_ENABLED: true

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs author feedbackWaiting for additional feedback from the author

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions