Class NoOpMetricsRecorder
java.lang.Object
org.apache.juneau.rest.server.metrics.NoOpMetricsRecorder
- All Implemented Interfaces:
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final NoOpMetricsRecorderProcess-wide singleton instance. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.juneau.rest.server.metrics.MetricsRecorder
record
-
Field Details
-
INSTANCE
Process-wide singleton instance.
-
-
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:MetricsRecorderRecords one per-request metric event.- Specified by:
recordin interfaceMetricsRecorder- Parameters:
opName- The fully-qualified@RestOpmethod name (e.g."com.example.OrderResource.create(java.lang.String,com.example.Order)"). Nevernull ; never blank.httpMethod- The uppercased HTTP method of the request (e.g."GET","POST"). Nevernull ; never blank.uriTemplate- The@RestOppath template (e.g."/users/{id}"), not the raw concrete URI. Bridges should use this as theuritag to keep cardinality bounded. May be empty for resource-level operations that match/*; nevernull .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 (typically500for an unmapped exception, or the exception's status for aBasicHttpException).elapsed- Wall-clock duration of the@RestOpinvocation. Nevernull ; never negative.error- The exception thrown by the handler, ornull if the call completed normally. Bridges typically derive anexceptiontag from the throwable's simple class name, or"None"when null (mirrors Spring Boot'sWebMvcMetricsFilterconvention).metricName- Per-op metric name override fromRestOp.metricName(). Empty string (default) means the implementation should use its own default name derivation. Nevernull .metricTags- Per-op additional metric tags fromRestOp.metricTags(). Format: comma-separatedkey=valuepairs (e.g."team=payments,region=us-east"). Empty string (default) means no additional tags. Nevernull .
-