Open xiepuhuan opened 1 week ago
Duplicate Metric and Negative Value for http.server.active_requests in io.opentelemetry.servlet-3.0
Create a SpringBoot Web example project with the following controller code:
package example import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.context.request.async.DeferredResult; @RestController public class Server { @GetMapping("/hello") public DeferredResult<String> hello() { DeferredResult<String> deferredResult = new DeferredResult<>(); deferredResult.onTimeout(() -> System.out.println("Request timeout")); deferredResult.onCompletion(() -> System.out.println("Request complete")); new Thread(() -> { try { Thread.sleep(10000); deferredResult.setResult("Hello World!"); } catch (InterruptedException e) { deferredResult.setErrorResult(e); } }).start(); return deferredResult; } }
Build the project and generate the example.jar file.
Execute the following command to run the project with OpenTelemetry instrumentation:
java -javaagent:/path/opentelemetry-javaagent.jar -Dotel.traces.exporter=none -Dotel.logs.exporter=none -Dotel.metrics.exporter=logging-otlp -Dotel.instrumentation.http.server.emit-experimental-telemetry=true -jar example.jar
Send single HTTP requests to the /hello endpoint.
/hello
Observe the metric logs
I would like to report an issue regarding the http.server.active_requests metric, which is present only in a single ScopeMetrics and is expected to have values greater than or equal to 0.
http.server.active_requests
{ "resource": { "attributes": [ { "key": "host.arch", "value": { "stringValue": "aarch64" } }, { "key": "host.name", "value": { "stringValue": "xiepuhuan.local" } }, { "key": "os.description", "value": { "stringValue": "Mac OS X 14.0" } }, { "key": "os.type", "value": { "stringValue": "darwin" } }, { "key": "process.executable.path", "value": { "stringValue": "/Users/xiepuhuan/Library/Java/JavaVirtualMachines/azul-1.8.0_362/Contents/Home/jre/bin/java" } }, { "key": "process.pid", "value": { "intValue": "81312" } }, { "key": "process.runtime.description", "value": { "stringValue": "Azul Systems, Inc. OpenJDK 64-Bit Server VM 25.362-b09" } }, { "key": "process.runtime.name", "value": { "stringValue": "OpenJDK Runtime Environment" } }, { "key": "process.runtime.version", "value": { "stringValue": "1.8.0_362-b09" } }, { "key": "service.instance.id", "value": { "stringValue": "fd4a20ee-3cec-4298-be87-1e832b2ac499" } }, { "key": "service.name", "value": { "stringValue": "zeus-server-test-two" } }, { "key": "telemetry.distro.name", "value": { "stringValue": "opentelemetry-java-instrumentation" } }, { "key": "telemetry.distro.version", "value": { "stringValue": "2.5.0" } }, { "key": "telemetry.sdk.language", "value": { "stringValue": "java" } }, { "key": "telemetry.sdk.name", "value": { "stringValue": "opentelemetry" } }, { "key": "telemetry.sdk.version", "value": { "stringValue": "1.39.0" } } ] }, "scopeMetrics": [ { "scope": { "name": "io.opentelemetry.tomcat-7.0", "version": "2.5.0-alpha", "attributes": [] }, "metrics": [ { "name": "http.server.active_requests", "description": "Number of active HTTP server requests.", "unit": "{requests}", "sum": { "dataPoints": [ { "startTimeUnixNano": "1718776803088000000", "timeUnixNano": "1718776863097000000", "asInt": "1", "exemplars": [ { "timeUnixNano": "1718776818524000000", "asInt": "1", "spanId": "984b6f71dd6996b1", "traceId": "14357b5a17a604b878a4c9785596c9ab", "filteredAttributes": [ { "key": "client.address", "value": { "stringValue": "127.0.0.1" } }, { "key": "server.address", "value": { "stringValue": "127.0.0.1" } }, { "key": "server.port", "value": { "intValue": "8080" } }, { "key": "url.path", "value": { "stringValue": "/hello" } }, { "key": "user_agent.original", "value": { "stringValue": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36" } } ] } ], "attributes": [ { "key": "http.request.method", "value": { "stringValue": "GET" } }, { "key": "url.scheme", "value": { "stringValue": "http" } } ] } ], "aggregationTemporality": 2 } } ] }, { "scope": { "name": "io.opentelemetry.servlet-3.0", "version": "2.5.0-alpha", "attributes": [] }, "metrics": [ { "name": "http.server.request.duration", "description": "Duration of HTTP server requests.", "unit": "s", "histogram": { "dataPoints": [ { "startTimeUnixNano": "1718776803088000000", "timeUnixNano": "1718776863097000000", "count": "1", "sum": 10.250294625, "min": 10.250294625, "max": 10.250294625, "bucketCounts": [ "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "1" ], "explicitBounds": [ 0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1.0, 2.5, 5.0, 7.5, 10.0 ], "exemplars": [ { "timeUnixNano": "1718776828774000000", "asDouble": 10.250294625, "spanId": "984b6f71dd6996b1", "traceId": "14357b5a17a604b878a4c9785596c9ab", "filteredAttributes": [ { "key": "client.address", "value": { "stringValue": "127.0.0.1" } }, { "key": "http.response.body.size", "value": { "intValue": "12" } }, { "key": "network.peer.address", "value": { "stringValue": "127.0.0.1" } }, { "key": "network.peer.port", "value": { "intValue": "53572" } }, { "key": "server.address", "value": { "stringValue": "127.0.0.1" } }, { "key": "server.port", "value": { "intValue": "8080" } }, { "key": "url.path", "value": { "stringValue": "/hello" } }, { "key": "user_agent.original", "value": { "stringValue": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36" } } ] } ], "attributes": [ { "key": "http.request.method", "value": { "stringValue": "GET" } }, { "key": "http.response.status_code", "value": { "intValue": "200" } }, { "key": "http.route", "value": { "stringValue": "/hello" } }, { "key": "network.protocol.version", "value": { "stringValue": "1.1" } }, { "key": "url.scheme", "value": { "stringValue": "http" } } ] } ], "aggregationTemporality": 2 } }, { "name": "http.server.response.size", "description": "Size of HTTP server response bodies.", "unit": "By", "histogram": { "dataPoints": [ { "startTimeUnixNano": "1718776803088000000", "timeUnixNano": "1718776863097000000", "count": "1", "sum": 12.0, "min": 12.0, "max": 12.0, "bucketCounts": [ "0", "0", "0", "1", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" ], "explicitBounds": [ 0.0, 5.0, 10.0, 25.0, 50.0, 75.0, 100.0, 250.0, 500.0, 750.0, 1000.0, 2500.0, 5000.0, 7500.0, 10000.0 ], "exemplars": [ { "timeUnixNano": "1718776828773000000", "asDouble": 12.0, "spanId": "984b6f71dd6996b1", "traceId": "14357b5a17a604b878a4c9785596c9ab", "filteredAttributes": [ { "key": "client.address", "value": { "stringValue": "127.0.0.1" } }, { "key": "http.response.body.size", "value": { "intValue": "12" } }, { "key": "network.peer.address", "value": { "stringValue": "127.0.0.1" } }, { "key": "network.peer.port", "value": { "intValue": "53572" } }, { "key": "server.address", "value": { "stringValue": "127.0.0.1" } }, { "key": "server.port", "value": { "intValue": "8080" } }, { "key": "url.path", "value": { "stringValue": "/hello" } }, { "key": "user_agent.original", "value": { "stringValue": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36" } } ] } ], "attributes": [ { "key": "http.request.method", "value": { "stringValue": "GET" } }, { "key": "http.response.status_code", "value": { "intValue": "200" } }, { "key": "http.route", "value": { "stringValue": "/hello" } }, { "key": "network.protocol.version", "value": { "stringValue": "1.1" } }, { "key": "url.scheme", "value": { "stringValue": "http" } } ] } ], "aggregationTemporality": 2 } }, { "name": "http.server.active_requests", "description": "Number of active HTTP server requests.", "unit": "{requests}", "sum": { "dataPoints": [ { "startTimeUnixNano": "1718776803088000000", "timeUnixNano": "1718776863097000000", "asInt": "-1", "exemplars": [ { "timeUnixNano": "1718776828773000000", "asInt": "-1", "spanId": "984b6f71dd6996b1", "traceId": "14357b5a17a604b878a4c9785596c9ab", "filteredAttributes": [ { "key": "client.address", "value": { "stringValue": "127.0.0.1" } }, { "key": "server.address", "value": { "stringValue": "127.0.0.1" } }, { "key": "server.port", "value": { "intValue": "8080" } }, { "key": "url.path", "value": { "stringValue": "/hello" } }, { "key": "user_agent.original", "value": { "stringValue": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36" } } ] } ], "attributes": [ { "key": "http.request.method", "value": { "stringValue": "GET" } }, { "key": "url.scheme", "value": { "stringValue": "http" } } ] } ], "aggregationTemporality": 2 } } ] } ], "schemaUrl": "https://opentelemetry.io/schemas/1.24.0" }
v2.5.0
JDK: Azul Systems, Inc. OpenJDK 64-Bit Server VM 25.362-b09 OS: Mac OS X 14.0 SpringBoot: 2.7.14
No response
Describe the bug
Duplicate Metric and Negative Value for http.server.active_requests in io.opentelemetry.servlet-3.0
Steps to reproduce
Create a SpringBoot Web example project with the following controller code:
Build the project and generate the example.jar file.
Execute the following command to run the project with OpenTelemetry instrumentation:
Send single HTTP requests to the
/hello
endpoint.Observe the metric logs
Expected behavior
I would like to report an issue regarding the
http.server.active_requests
metric, which is present only in a single ScopeMetrics and is expected to have values greater than or equal to 0.Actual behavior
Javaagent or library instrumentation version
v2.5.0
Environment
JDK: Azul Systems, Inc. OpenJDK 64-Bit Server VM 25.362-b09 OS: Mac OS X 14.0 SpringBoot: 2.7.14
Additional context
No response