use of com.google.api.services.dataflow.model.MetricStructuredName in project beam by apache.
the class WorkItemStatusClient method populateMetricUpdates.
@VisibleForTesting
synchronized void populateMetricUpdates(WorkItemStatus status) {
List<MetricUpdate> updates = new ArrayList<>();
if (executionContext != null && executionContext.getExecutionStateTracker() != null) {
ExecutionStateTracker tracker = executionContext.getExecutionStateTracker();
MetricUpdate update = new MetricUpdate();
update.setKind("internal");
MetricStructuredName name = new MetricStructuredName();
name.setName("state-sampler");
update.setName(name);
Map<String, Object> metric = new HashMap<>();
ExecutionState state = tracker.getCurrentState();
if (state != null) {
metric.put("last-state-name", state.getDescription());
}
metric.put("num-transitions", tracker.getNumTransitions());
metric.put("last-state-duration-ms", tracker.getMillisSinceLastTransition());
update.setInternal(metric);
updates.add(update);
}
status.setMetricUpdates(updates);
}
use of com.google.api.services.dataflow.model.MetricStructuredName in project beam by apache.
the class DataflowMetricsTest method setStructuredName.
private MetricUpdate setStructuredName(MetricUpdate update, String name, String namespace, String step, boolean tentative) {
MetricStructuredName structuredName = new MetricStructuredName();
structuredName.setName(name);
structuredName.setOrigin("user");
ImmutableMap.Builder contextBuilder = new ImmutableMap.Builder<>();
contextBuilder.put("step", step).put("namespace", namespace);
if (tentative) {
contextBuilder.put("tentative", "true");
}
structuredName.setContext(contextBuilder.build());
update.setName(structuredName);
return update;
}
use of com.google.api.services.dataflow.model.MetricStructuredName in project beam by apache.
the class TestDataflowRunnerTest method generateMockStreamingMetrics.
private List<MetricUpdate> generateMockStreamingMetrics(Map<String, BigDecimal> metricMap) {
List<MetricUpdate> metrics = Lists.newArrayList();
for (Map.Entry<String, BigDecimal> entry : metricMap.entrySet()) {
MetricStructuredName name = new MetricStructuredName();
name.setName(entry.getKey());
MetricUpdate metric = new MetricUpdate();
metric.setName(name);
metric.setScalar(entry.getValue());
metrics.add(metric);
}
return metrics;
}
use of com.google.api.services.dataflow.model.MetricStructuredName in project beam by apache.
the class TestDataflowRunnerTest method generateMockMetrics.
private List<MetricUpdate> generateMockMetrics(boolean success, boolean tentative) {
MetricStructuredName name = new MetricStructuredName();
name.setName(success ? "PAssertSuccess" : "PAssertFailure");
name.setContext(tentative ? ImmutableMap.of("tentative", "") : ImmutableMap.of());
MetricUpdate metric = new MetricUpdate();
metric.setName(name);
metric.setScalar(BigDecimal.ONE);
return Lists.newArrayList(metric);
}
Aggregations