use of org.apache.beam.runners.core.metrics.MonitoringInfoMetricName in project beam by apache.
the class GcsUtilTest method verifyMetricWasSet.
private void verifyMetricWasSet(String projectId, String bucketId, String method, String status, long count) {
// Verify the metric as reported.
HashMap<String, String> labels = new HashMap<>();
labels.put(MonitoringInfoConstants.Labels.PTRANSFORM, "");
labels.put(MonitoringInfoConstants.Labels.SERVICE, "Storage");
labels.put(MonitoringInfoConstants.Labels.METHOD, method);
labels.put(MonitoringInfoConstants.Labels.GCS_PROJECT_ID, projectId);
labels.put(MonitoringInfoConstants.Labels.GCS_BUCKET, bucketId);
labels.put(MonitoringInfoConstants.Labels.RESOURCE, GcpResourceIdentifiers.cloudStorageBucket(bucketId));
labels.put(MonitoringInfoConstants.Labels.STATUS, status);
MonitoringInfoMetricName name = MonitoringInfoMetricName.named(MonitoringInfoConstants.Urns.API_REQUEST_COUNT, labels);
MetricsContainerImpl container = (MetricsContainerImpl) MetricsEnvironment.getProcessWideContainer();
assertEquals(count, (long) container.getCounter(name).getCumulative());
}
use of org.apache.beam.runners.core.metrics.MonitoringInfoMetricName in project beam by apache.
the class HarnessMonitoringInfosInstructionHandlerTest method testReturnsProcessWideMonitoringInfos.
@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());
}
use of org.apache.beam.runners.core.metrics.MonitoringInfoMetricName in project beam by apache.
the class DatastoreV1Test method verifyMetricWasSet.
private void verifyMetricWasSet(String method, String status, String namespace, long count) {
// Verify the metric as reported.
HashMap<String, String> labels = new HashMap<>();
labels.put(MonitoringInfoConstants.Labels.PTRANSFORM, "");
labels.put(MonitoringInfoConstants.Labels.SERVICE, "Datastore");
labels.put(MonitoringInfoConstants.Labels.METHOD, method);
labels.put(MonitoringInfoConstants.Labels.RESOURCE, "//bigtable.googleapis.com/projects/" + PROJECT_ID + "/namespaces/" + namespace);
labels.put(MonitoringInfoConstants.Labels.DATASTORE_PROJECT, PROJECT_ID);
labels.put(MonitoringInfoConstants.Labels.DATASTORE_NAMESPACE, namespace);
labels.put(MonitoringInfoConstants.Labels.STATUS, status);
MonitoringInfoMetricName name = MonitoringInfoMetricName.named(MonitoringInfoConstants.Urns.API_REQUEST_COUNT, labels);
MetricsContainerImpl container = (MetricsContainerImpl) MetricsEnvironment.getProcessWideContainer();
assertEquals(count, (long) container.getCounter(name).getCumulative());
}
use of org.apache.beam.runners.core.metrics.MonitoringInfoMetricName in project beam by apache.
the class BigtableServiceImplTest method verifyMetricWasSet.
private void verifyMetricWasSet(String method, String status, long count) {
// Verify the metric as reported.
HashMap<String, String> labels = new HashMap<>();
labels.put(MonitoringInfoConstants.Labels.PTRANSFORM, "");
labels.put(MonitoringInfoConstants.Labels.SERVICE, "BigTable");
labels.put(MonitoringInfoConstants.Labels.METHOD, method);
labels.put(MonitoringInfoConstants.Labels.RESOURCE, GcpResourceIdentifiers.bigtableResource(PROJECT_ID, INSTANCE_ID, TABLE_ID));
labels.put(MonitoringInfoConstants.Labels.BIGTABLE_PROJECT_ID, PROJECT_ID);
labels.put(MonitoringInfoConstants.Labels.INSTANCE_ID, INSTANCE_ID);
labels.put(MonitoringInfoConstants.Labels.TABLE_ID, GcpResourceIdentifiers.bigtableTableID(PROJECT_ID, INSTANCE_ID, TABLE_ID));
labels.put(MonitoringInfoConstants.Labels.STATUS, status);
MonitoringInfoMetricName name = MonitoringInfoMetricName.named(MonitoringInfoConstants.Urns.API_REQUEST_COUNT, labels);
MetricsContainerImpl container = (MetricsContainerImpl) MetricsEnvironment.getProcessWideContainer();
assertEquals(count, (long) container.getCounter(name).getCumulative());
}
use of org.apache.beam.runners.core.metrics.MonitoringInfoMetricName in project beam by apache.
the class SpannerIOWriteTest method verifyMetricWasSet.
private void verifyMetricWasSet(String projectId, String databaseId, String tableId, String method, String status, long count) {
// Verify the metric was reported.
HashMap<String, String> labels = new HashMap<>();
labels.put(MonitoringInfoConstants.Labels.PTRANSFORM, "");
labels.put(MonitoringInfoConstants.Labels.SERVICE, "Spanner");
labels.put(MonitoringInfoConstants.Labels.METHOD, method);
labels.put(MonitoringInfoConstants.Labels.RESOURCE, GcpResourceIdentifiers.spannerTable(projectId, databaseId, tableId));
labels.put(MonitoringInfoConstants.Labels.SPANNER_PROJECT_ID, projectId);
labels.put(MonitoringInfoConstants.Labels.SPANNER_DATABASE_ID, databaseId);
labels.put(MonitoringInfoConstants.Labels.SPANNER_INSTANCE_ID, tableId);
labels.put(MonitoringInfoConstants.Labels.STATUS, status);
MonitoringInfoMetricName name = MonitoringInfoMetricName.named(MonitoringInfoConstants.Urns.API_REQUEST_COUNT, labels);
MetricsContainerImpl container = (MetricsContainerImpl) MetricsEnvironment.getProcessWideContainer();
assertEquals(count, (long) container.getCounter(name).getCumulative());
}
Aggregations