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

Duplicate Metric and Negative Value for http.server.active_requests in io.opentelemetry.servlet-3.0 #11625

Closed
xiepuhuan opened this issue Jun 19, 2024 · 0 comments · Fixed by #11638
Labels
bug Something isn't working needs triage New issue that requires triage

Comments

@xiepuhuan
Copy link

xiepuhuan commented Jun 19, 2024

Describe the bug

Duplicate Metric and Negative Value for http.server.active_requests in io.opentelemetry.servlet-3.0

Steps to reproduce

  1. 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;
      }
    }
  2. Build the project and generate the example.jar file.

  3. 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
  4. Send single HTTP requests to the /hello endpoint.

  5. 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

{
  "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"
}

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

@xiepuhuan xiepuhuan added bug Something isn't working needs triage New issue that requires triage labels Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage New issue that requires triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant