[
https://issues.apache.org/jira/browse/BEAM-6022?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16680014#comment-16680014
]
Scott Wegner commented on BEAM-6022:
------------------------------------
Can you give more details on how you are calling {{Metrics.counter(..)}}?
According to the
[javadoc|https://beam.apache.org/releases/javadoc/2.8.0/org/apache/beam/sdk/metrics/Metrics.html]:
bq. Reported metrics are implicitly scoped to the transform within the pipeline
that reported them. This allows reporting the same metric name in multiple
places and identifying the value each transform reported, as well as
aggregating the metric across
If you are writing the counter inside multiple PTransforms, you should receive
separate {{MetricResult}} objects for each. You can verify by inspecting the
{{MetricResult}} name and step for each.
/cc [[email protected]] [~pabloem]
> Metrics of the same name and type are created multiple times
> ------------------------------------------------------------
>
> Key: BEAM-6022
> URL: https://issues.apache.org/jira/browse/BEAM-6022
> Project: Beam
> Issue Type: Bug
> Components: sdk-java-core
> Reporter: Lukasz Gajowy
> Assignee: Kenneth Knowles
> Priority: Major
>
> I noticed that when the below (or any other metric type) is called multiple
> times:
> {code:java}
> Metrics.counter("namespace", "name");{code}
> metrics of the same name and type are created. So when such metrics are
> queried by name:
> {code:java}
> MetricQueryResults metrics =
> result
> .metrics()
> .queryMetrics(
> MetricsFilter.builder()
> .addNameFilter(MetricNameFilter.named(namespace, name))
> .build());
> Iterable<MetricResult<Long>> counters = metrics.getCounters();{code}
> there is ambiguity which MetricResult should be chosen.
> Should api users obtain one metric result here?
> Should api users merge the counter results if there are multiple returned?
> I noticed that all of the results contain the same value (not sure if this is
> always the case). Should api users read only one of the multiple results to
> get correct metric?
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)