Package io.grpc.xds.orca
Class OrcaMetricReportingServerInterceptor
- java.lang.Object
-
- io.grpc.xds.orca.OrcaMetricReportingServerInterceptor
-
- All Implemented Interfaces:
io.grpc.ServerInterceptor
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/9127") public final class OrcaMetricReportingServerInterceptor extends java.lang.Object implements io.grpc.ServerInterceptorAServerInterceptorthat intercepts aServerCallby running server-side RPC handling under aContextthat records custom per-request metrics provided by server applications and sends to client side along with the response in the format of Open Request Cost Aggregation (ORCA).- Since:
- 1.23.0
-
-
Field Summary
Fields Modifier and Type Field Description private static OrcaMetricReportingServerInterceptorINSTANCEprivate io.grpc.services.MetricRecordermetricRecorder(package private) static io.grpc.Metadata.Key<OrcaLoadReport>ORCA_ENDPOINT_LOAD_METRICS_KEY
-
Constructor Summary
Constructors Constructor Description OrcaMetricReportingServerInterceptor(io.grpc.services.MetricRecorder metricRecorder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static OrcaMetricReportingServerInterceptorcreate(io.grpc.services.MetricRecorder metricRecorder)Creates a newOrcaMetricReportingServerInterceptorinstance with the givenMetricRecorder.private static OrcaLoadReport.BuilderfromInternalReport(io.grpc.services.MetricReport internalReport)static OrcaMetricReportingServerInterceptorgetInstance()<ReqT,RespT>
io.grpc.ServerCall.Listener<ReqT>interceptCall(io.grpc.ServerCall<ReqT,RespT> call, io.grpc.Metadata headers, io.grpc.ServerCallHandler<ReqT,RespT> next)private static booleanisReportValueSet(double value)private static voidmergeMetrics(OrcaLoadReport.Builder metricRecorderReportBuilder, io.grpc.services.MetricReport callMetricRecorderReport)Modify the givenOrcaLoadReport.Buildercontaining metrics forMetricRecordersuch that metrics from the givenMetricReportforCallMetricRecordertakes a higher precedence.
-
-
-
Field Detail
-
INSTANCE
private static final OrcaMetricReportingServerInterceptor INSTANCE
-
ORCA_ENDPOINT_LOAD_METRICS_KEY
static final io.grpc.Metadata.Key<OrcaLoadReport> ORCA_ENDPOINT_LOAD_METRICS_KEY
-
metricRecorder
@Nullable private final io.grpc.services.MetricRecorder metricRecorder
-
-
Method Detail
-
getInstance
public static OrcaMetricReportingServerInterceptor getInstance()
-
create
public static OrcaMetricReportingServerInterceptor create(@Nullable io.grpc.services.MetricRecorder metricRecorder)
Creates a newOrcaMetricReportingServerInterceptorinstance with the givenMetricRecorder. When bothCallMetricRecorderandMetricRecorderexist, the metrics are merged such that per-request metrics fromCallMetricRecordertakes a higher precedence compared to metrics fromMetricRecorder.
-
interceptCall
public <ReqT,RespT> io.grpc.ServerCall.Listener<ReqT> interceptCall(io.grpc.ServerCall<ReqT,RespT> call, io.grpc.Metadata headers, io.grpc.ServerCallHandler<ReqT,RespT> next)- Specified by:
interceptCallin interfaceio.grpc.ServerInterceptor
-
fromInternalReport
private static OrcaLoadReport.Builder fromInternalReport(io.grpc.services.MetricReport internalReport)
-
mergeMetrics
private static void mergeMetrics(OrcaLoadReport.Builder metricRecorderReportBuilder, io.grpc.services.MetricReport callMetricRecorderReport)
Modify the givenOrcaLoadReport.Buildercontaining metrics forMetricRecordersuch that metrics from the givenMetricReportforCallMetricRecordertakes a higher precedence.
-
isReportValueSet
private static boolean isReportValueSet(double value)
-
-