public static void reportSuccessfulRpcMetrics(@Nullable Context<?> c, RpcMethod method) {
    reportSuccessfulRpcMetrics(c, method, UNKNOWN);
  }
@Test
  public void testReportSuccessfulRpcMetrics() throws Exception {
    // Setup
    TestMetricsContainer testContainer = new TestMetricsContainer();
    MetricsEnvironment.setCurrentContainer(testContainer);
    Context<AppendRowsResponse> c = new Context<AppendRowsResponse>();
    Instant t1 = Instant.now();
    c.setOperationStartTime(t1);
    c.setOperationEndTime(t1.plusMillis(3));

    // Test disabled SupportMetricsDeletion
    BigQuerySinkMetrics.setSupportMetricsDeletion(false);
    BigQuerySinkMetrics.reportSuccessfulRpcMetrics(
        c, BigQuerySinkMetrics.RpcMethod.APPEND_ROWS, "tableId");
    MetricName counterNameDisabledDeletes =
        MetricName.named("BigQuerySink", "RpcRequestsCount*rpc_method:APPEND_ROWS;rpc_status:OK;");
    MetricName histogramName =
        MetricName.named("BigQuerySink", "RpcLatency*rpc_method:APPEND_ROWS;");
    HistogramData.BucketType bucketType = HistogramData.ExponentialBuckets.of(0, 17);
    testContainer.assertPerWorkerCounterValue(counterNameDisabledDeletes, 1L);
    testContainer.assertPerWorkerHistogramValues(histogramName, bucketType, 3.0);

    // Test enable SupportMetricsDeletion.
    BigQuerySinkMetrics.setSupportMetricsDeletion(true);
    testContainer.reset();
    BigQuerySinkMetrics.reportSuccessfulRpcMetrics(
        c, BigQuerySinkMetrics.RpcMethod.APPEND_ROWS, "tableId");
    MetricName counterNameEnabledDeletes =
        MetricName.named(
            "BigQuerySink",
            "RpcRequestsCount*rpc_method:APPEND_ROWS;rpc_status:OK;table_id:tableId;");
    testContainer.assertPerWorkerCounterValue(counterNameEnabledDeletes, 1L);
    testContainer.assertPerWorkerHistogramValues(histogramName, bucketType, 3.0);
  }