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 Object implements io.grpc.ServerInterceptor
A ServerInterceptor that intercepts a ServerCall by running server-side RPC handling under a Context that 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 Details

  • Constructor Details

    • OrcaMetricReportingServerInterceptor

      OrcaMetricReportingServerInterceptor(@Nullable io.grpc.services.MetricRecorder metricRecorder)
  • Method Details

    • getInstance

      public static OrcaMetricReportingServerInterceptor getInstance()
    • create

      public static OrcaMetricReportingServerInterceptor create(@Nullable io.grpc.services.MetricRecorder metricRecorder)
      Creates a new OrcaMetricReportingServerInterceptor instance with the given MetricRecorder. When both CallMetricRecorder and MetricRecorder exist, the metrics are merged such that per-request metrics from CallMetricRecorder takes a higher precedence compared to metrics from MetricRecorder.
    • 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:
      interceptCall in interface io.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 given OrcaLoadReport.Builder containing metrics for MetricRecorder such that metrics from the given MetricReport for CallMetricRecorder takes a higher precedence.
    • isReportValueSet

      private static boolean isReportValueSet(double value)