Repository navigation
[BEAM-4775] key MetricResult by a MetricKey - #7867
Conversation
|
Run Java PreCommit |
|
Run Java PreCommit |
|
One thing I don't like about MetricKey, is that its only applicable to user metrics. Which are identified with the following fields:
MonitoringInfos are defined by
MetricKey is insufficient today to describe any metric which isn't defined by (step, namespace, metric name). Take a look at MonitoringInfoMetricName (extends MetricName), which I added. This can contain a URN and an arbitrary set of key value pair labels. I think this is the more generalized way to key a Metric and I would like to land on this in the future. I think we don't really need two separte classed MetricName and MetricKey either. We could just have one class in the end similar to which represents the MetricKey. The challenge I see with this though, is that querying the metrics and storing the metrics internally use the same classes today (MetricKey). It would be better to keep the user facing API more similar to how the user defines a metric (explicitly being able to access the name and namespace fields). In the end we might have an internal MonitoringInfoMetricKey separate from a (User)MetricKey the user can us in the querying API. If this change unblocks your work now, then I think its fine to proceed. But I wanted to give a bit more context here on how I think this could be simplified in the end. I think we have too many classes right now, for identifying metrics. |
| .appendText("inNamespace: ") | ||
| .appendValue(namespace) | ||
| .appendText("inKey: ") | ||
| .appendValue(key) |
There was a problem hiding this comment.
Please check if tostring is implemented in MonitoringInfoMetricKey and MetricKey
| /** | ||
| * An adapter between the {@link MetricsContainerStepMap} and Codahale's {@link Metric} interface. | ||
| */ | ||
| class SparkBeamMetric implements Metric { |
There was a problem hiding this comment.
I also notice the Metric class will only handle User Metrics (Name, Namespace). If spark only cares about UserMetrics that's okay I suppose. but won't handle more generlized MonitoringInfos
There was a problem hiding this comment.
Agreed. Most of what I've done so far (in #7823) is [expanding the Java SDK metrics classes to support the wider MonitoringInfo data model] while [preserving semantics of existing code that assumes / requires user-metrics].
In this case, I end up adapting this to use a MetricLabels.value() API that assumes there is exactly one label set on the MonitoringInfo (PTRANSFORM xor PCOLLECTION) and uses that, so it should be reasonably "future-proofed"
| import org.apache.beam.sdk.metrics.MetricResult; | ||
| import org.apache.beam.sdk.metrics.MetricsOptions; | ||
| import org.apache.beam.sdk.metrics.MetricsSink; | ||
|
|
There was a problem hiding this comment.
Do you have any more details for this class? Link to doc? Explaination of how to use it. Example code of handling the Post request, etc.? What is the wire format used? Can it be included in this header?
There was a problem hiding this comment.
Yea, those would be nice to have 😀 I don't really know anything about it, and just made these changes to preserve the existing format.
I'll do some digging and try to formalize / document it better, though I assume that [not rocking the wire-format boat with whatever is going on here] is going to be what we want to do, in the short term at least.
|
Thanks Alex. The good news is I think we agree about everything you've said. In #7823 I basically turn the existing Java SDK metrics classes into wrappers for corresponding MonitoringInfo structures:
So that is the larger vision, which this PR is a small step toward. LMK if that sounds off to you. I'm in a constant process of pulling stuff out of #7823 so that the real work will be in clearer relief there. A different question that came up with @mxm on #7866 is around what packages things should live in. I don't think it's too bad if Hopefully we can push on other parts of this (and related PRs) while I think more about that question. Ofc any thoughts are welcome. |
|
hm, I see a bunch of in the scan for |
|
Run Portable_Python PreCommit |
(factored out of #7823)
MetricResultpreviously hadMetricKey's fields inlined, possibly due to living in java/core whileMetricKeyis in runners/core.Having callers use a
MetricKeysimplifies call-sites and prepares for expanding Java SDK metrics to support (ptransform- and pcollection-scoped) system metrics in addition to (ptransform-scoped) user metrics, which #7823 implements.This change also moves
MetricKeyandMetricFilteringinto java/core, which is basically necessary / logical based on the intra-metrics-class dependencies.R: @robertwb, @ajamato
Post-Commit Tests Status (on master branch)
See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.