public BeamFnApi.InstructionResponse.Builder harnessMonitoringInfos(
      BeamFnApi.InstructionRequest request) {
    BeamFnApi.HarnessMonitoringInfosResponse.Builder response =
        BeamFnApi.HarnessMonitoringInfosResponse.newBuilder();
    MetricsContainer container = MetricsEnvironment.getProcessWideContainer();
    if (container != null && container instanceof MetricsContainerImpl) {
      response.putAllMonitoringData(
          ((MetricsContainerImpl) container).getMonitoringData(this.metricsShortIds));
    }
    return BeamFnApi.InstructionResponse.newBuilder().setHarnessMonitoringInfos(response);
  }
@Test
  public void testReturnsProcessWideMonitoringInfos() {
    MetricsEnvironment.setProcessWideContainer(MetricsContainerImpl.createProcessWideContainer());

    HashMap<String, String> labels = new HashMap<String, String>();
    labels.put(MonitoringInfoConstants.Labels.SERVICE, "service");
    labels.put(MonitoringInfoConstants.Labels.METHOD, "method");
    labels.put(MonitoringInfoConstants.Labels.RESOURCE, "resource");
    labels.put(MonitoringInfoConstants.Labels.PTRANSFORM, "transform");
    labels.put(MonitoringInfoConstants.Labels.STATUS, "ok");
    MonitoringInfoMetricName name =
        MonitoringInfoMetricName.named(MonitoringInfoConstants.Urns.API_REQUEST_COUNT, labels);
    Counter counter = LabeledMetrics.counter(name, true);
    counter.inc(7);

    ShortIdMap metricsShortIds = new ShortIdMap();
    HarnessMonitoringInfosInstructionHandler testObject =
        new HarnessMonitoringInfosInstructionHandler(metricsShortIds);

    BeamFnApi.InstructionRequest.Builder builder = BeamFnApi.InstructionRequest.newBuilder();
    BeamFnApi.InstructionResponse.Builder responseBuilder =
        testObject.harnessMonitoringInfos(builder.build());

    BeamFnApi.InstructionResponse response = responseBuilder.build();
    assertEquals(1, response.getHarnessMonitoringInfos().getMonitoringDataMap().size());

    // Expect a payload to be set for "metric0".
    assertTrue(
        !response.getHarnessMonitoringInfos().getMonitoringDataMap().get("metric0").isEmpty());
  }