Class MetricLabels

java.lang.Object
org.mockserver.metrics.MetricLabels

public final class MetricLabels extends Object
Small static helpers for deriving low-cardinality metric label values from load-scenario traffic.

The route label must stay low-cardinality (one Prometheus time series per distinct value), so a raw request path like /api/orders/12345 cannot be used directly — it would create a new series per id. routeOf(String) templatises the path by collapsing any segment that is all digits or looks like a UUID/hex id to the literal token {id}. So:

  • /api/orders/12345/api/orders/{id}
  • /users/9f1c8e0a-1b2c-4d3e-8f90-abcdef012345/users/{id}
  • /v2/items/deadbeefcafebabe/v2/items/{id} (16+ hex chars)
  • /api/orders/api/orders (unchanged — no id segment)

A scenario step may override this entirely by giving the step an explicit name, in which case the orchestrator uses the step name as the route label (see LoadScenarioOrchestrator).

  • Method Details

    • routeOf

      public static String routeOf(String path)
      Templatise a request path into a low-cardinality route label by replacing id-shaped segments with {id}. A null/blank path returns "/"; the query string (anything after ?) is dropped.
      Parameters:
      path - the raw request path (may include a query string)
      Returns:
      the templatised route label