-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
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.