Repository navigation
Use MonitoringInfo data model in Java SDK metrics - #7915
ryan-williams wants to merge 4 commits into
Conversation
b3b6bfe to
c8d8651
Compare
| MetricsContainer metricsContainer = getMetricsContainer(stepName); | ||
| monitoringInfos.forEach( | ||
| monitoringInfo -> { | ||
| if (monitoringInfo.hasMetric()) { |
There was a problem hiding this comment.
A lot of the Flink-related changes here have since been factored out to #7971, I'll try to get that merged, and in the meantime set up a view of this PR rebased on top of that.
Ardagan
left a comment
There was a problem hiding this comment.
Ryan says that he'll split this PR into smaller ones. I'll get back to it once split happens.
| } | ||
| // If it is not a user counter, just use the first part of the URN, i.e. 'beam' | ||
| List<String> pieces = Splitter.on(':').splitToList(urn); | ||
| if (pieces.size() != 2) { |
There was a problem hiding this comment.
@ajamato
I believe we allow to have colons in namespace.
There was a problem hiding this comment.
Yes this might be possible. Use the last part of the split as the name, then combine everything else.
Ryan is going to move this to the labels later on, getting rid of all this parsing code anyways though
There was a problem hiding this comment.
Cool, I changed my handling to match DF, as I mentioned above, thanks.
| return false; | ||
| } | ||
| // If it is not a user counter, just use the first part of the URN, i.e. 'beam' | ||
| List<String> pieces = Splitter.on(':').splitToList(urn); |
There was a problem hiding this comment.
We got duplication of this logic:
in this PR: MetricUrns.java L66
and in DF runner
can be more.
There was a problem hiding this comment.
Thanks for flagging this!
I've changed this code (and MetricUrns.parseUrn) to match the semantics there ("namespace is everything up to the last :, with internal : deleted"), and changed that site to call MetricUrns.parseUrn.
Combining this with MetricUrns.parseUrn would also be nice, but they're pretty different contexts and I don't see an easy way to atm.
That change is just the last commit, adc7872.
ryan-williams
left a comment
There was a problem hiding this comment.
Thanks for the comments, I believe I addressed everything.
"Ryan says that he'll split this PR into smaller ones" is probably overstating it, unfortunately.
I'll if I can take the Flink stuff (from #7971) out of this one in the meantime though.
It's a small part of this PR, though, and I don't have plans to factor anything else out atm.
| return false; | ||
| } | ||
| // If it is not a user counter, just use the first part of the URN, i.e. 'beam' | ||
| List<String> pieces = Splitter.on(':').splitToList(urn); |
There was a problem hiding this comment.
Thanks for flagging this!
I've changed this code (and MetricUrns.parseUrn) to match the semantics there ("namespace is everything up to the last :, with internal : deleted"), and changed that site to call MetricUrns.parseUrn.
Combining this with MetricUrns.parseUrn would also be nice, but they're pretty different contexts and I don't see an easy way to atm.
That change is just the last commit, adc7872.
| } | ||
| // If it is not a user counter, just use the first part of the URN, i.e. 'beam' | ||
| List<String> pieces = Splitter.on(':').splitToList(urn); | ||
| if (pieces.size() != 2) { |
There was a problem hiding this comment.
Cool, I changed my handling to match DF, as I mentioned above, thanks.
|
Run Java PreCommit |
|
R: @pabloem |
pabloem
left a comment
There was a problem hiding this comment.
My only serious comment is that we may have a bug because MetricLabels doesn't seem to implement hashcode or equals, so we probably cant retrieve containers properly? I may be wrong.
Other than that, it looks fine. thanks!
| import org.apache.beam.model.pipeline.v1.RunnerApi.ReadPayload; | ||
| import org.apache.beam.model.pipeline.v1.RunnerApi.StandardEnvironments; | ||
| import org.apache.beam.model.pipeline.v1.RunnerApi.WindowIntoPayload; | ||
| import org.apache.beam.sdk.metrics.BeamUrns; |
There was a problem hiding this comment.
How come this file was fine before without importing this? : s
| if (!metricsContainers.containsKey(stepName)) { | ||
| metricsContainers.put(stepName, new MetricsContainerImpl(stepName)); | ||
| public MetricsContainerImpl getContainer(MetricLabels labels) { | ||
| if (!metricsContainers.containsKey(labels)) { |
There was a problem hiding this comment.
It doesnt seem like MetricLabels implements a hashCode or an equals function. I may be missing something, but perhaps we need a test that checks that getContainer(MetricLabels.ptransform("A")) will work (creating a new metriclabels), and that MetricLabels.ptransform("A").equals(MetricLabels.ptransform("A"))?
| MetricKey key = MetricKey.create(monitoringInfo.getUrn(), monitoringInfo.getLabelsMap()); | ||
| MetricName metricName = key.metricName(); | ||
|
|
||
| MetricsContainer container = getMetricsContainer(key.labels()); |
There was a problem hiding this comment.
For my clarification: Does this mean that a user metric can only have as label its PTransform?
|
I don't think this is the approach we're intending to go with. I'm putting more details in a ML post shortly. |
MonitoringInfoMetricNameintoMetricKey({URN, labels})MetricKey.stepNameis expanded to aMetricLabelsmapMetricContainerStepMapis now keyed offMetricLabelsPTRANSFORMentry with thestepName)MetricNameis basically a MonitoringInfo URNMetricResultis like a fullMonitoringInfo({key, metric value})R: @ajamato, @Ardagan, @robertwb
java/core → model-fn-execution dependency
I waffled on #7867 due to making java/core depend on the
model-fn-executionproto module. However, talking with @ajamato, it seems like we're ok with that.It may be possible to pull more java/core metrics classes (Metric{Key,Name,Labels,Container*}, {Counter,Distribution,Gauge}Cell, and maybe more) into runners-core/java, which already depends on the model-fn-execution protos module, and save adding the dep to java/core. Let me know if I should look into that.
If not, someone should sign off on in particular on needing to add
org.apache.beam.modeland vendored gRPC to this GCP module API surface test.Post-Commit Tests Status (on master branch)
See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.