Class NoOpMetricsRecorder

java.lang.Object
org.apache.juneau.rest.server.metrics.NoOpMetricsRecorder
All Implemented Interfaces:
MetricsRecorder

public final class NoOpMetricsRecorder extends Object implements MetricsRecorder
Default MetricsRecorder implementation that drops every event on the floor.

Used whenever no consumer-provided MetricsRecorder bean is reachable from the RestContext's bean store. Ensures the MetricsRecorder contract is always satisfied — the framework can call record(...) unconditionally without a null-check.

The implementation is a single static-field constant (INSTANCE); the record(...) method does nothing, allocates nothing, and JIT-inlines to an empty method body, so the off-by-default path has no observable runtime cost.

Since:
10.0.0
  • Field Details

  • Method Details

    • record

      public void record(String opName, String httpMethod, String uriTemplate, int statusCode, Duration elapsed, Throwable error, String metricName, String metricTags)
      Description copied from interface: MetricsRecorder
      Records one per-request metric event.
      Specified by:
      record in interface MetricsRecorder
      Parameters:
      opName - The fully-qualified @RestOp method name (e.g. "com.example.OrderResource.create(java.lang.String,com.example.Order)"). Never null; never blank.
      httpMethod - The uppercased HTTP method of the request (e.g. "GET", "POST"). Never null; never blank.
      uriTemplate - The @RestOp path template (e.g. "/users/{id}"), not the raw concrete URI. Bridges should use this as the uri tag to keep cardinality bounded. May be empty for resource-level operations that match /*; never null.
      statusCode - The HTTP response status code (e.g. 200, 404, 500). If the handler threw before the status was set, this is the framework's inferred status (typically 500 for an unmapped exception, or the exception's status for a BasicHttpException).
      elapsed - Wall-clock duration of the @RestOp invocation. Never null; never negative.
      error - The exception thrown by the handler, or null if the call completed normally. Bridges typically derive an exception tag from the throwable's simple class name, or "None" when null (mirrors Spring Boot's WebMvcMetricsFilter convention).
      metricName - Per-op metric name override from RestOp.metricName(). Empty string (default) means the implementation should use its own default name derivation. Never null.
      metricTags - Per-op additional metric tags from RestOp.metricTags(). Format: comma-separated key=value pairs (e.g. "team=payments,region=us-east"). Empty string (default) means no additional tags. Never null.