Repository navigation
[BEAM-6138] Set the PTransform name on Java SDK User counters - #7624
Conversation
|
@ryan-williams @Ardagan I'll add those soon, but wanted to share it in advance. PTAL and let me know if there are specific unit tests you think that I should try to add as well. |
ryan-williams
left a comment
There was a problem hiding this comment.
one quick nit from rebasing my work onto this branch
|
|
||
| /** | ||
| * Key class to lookup the metric container for a step or unbound to any step. This is preferable | ||
| * to using null(which can't be used as a key). Additonally, this class could be extended to allow |
There was a problem hiding this comment.
Github doesn't seem to support a single "suggestion" block spanning multiple lines, but this causes a line-wrap so it's two "suggestion"s:
| * to using null(which can't be used as a key). Additonally, this class could be extended to allow | |
| * to using null (which can't be used as a key). Additionally, this class could be extended to |
| /** | ||
| * Key class to lookup the metric container for a step or unbound to any step. This is preferable | ||
| * to using null(which can't be used as a key). Additonally, this class could be extended to allow | ||
| * containers for other non pTransform contexts. |
There was a problem hiding this comment.
| * containers for other non pTransform contexts. | |
| * allow containers for other non pTransform contexts. |
|
I think ajamato#1 fixes the Java PreCommit failures, fwiw |
1caad4b to
f5bc350
Compare
|
Applied the suggestions here, added some unit tests. Please see the style of ElementCountFnDataReceiverTest, PTransformFunctionRegistryTest, PCollectionConsumerRegistry test Basically there are two ways to test the side effects in these tests: I went with #1 which, though #2 might be more resistant to implemetnation internal changes. I was curious what others thoughts were on this. |
|
I also removed the MetricContainerKey because I realized that for every element we were allocating the key, which I think would be problematic for performance and wanted to avoid |
|
Run Python PreCommit |
Do we have a standard way to test this kind of performance regression? |
Not yet, Beam needs more microbenchmark tests, java too. We should probably start writing some in Q2. |
8d37535 to
73f6cb1
Compare
|
Success, precommit is passing now. Let's finish up this review |
ryan-williams
left a comment
There was a problem hiding this comment.
lgtm modulo a couple questions
| if (metricUpdate.getKey().stepName() != null) { | ||
| stepName = metricUpdate.getKey().stepName(); | ||
| } | ||
| builder.setPTransformLabel(stepName); |
There was a problem hiding this comment.
Isn't a step-name of null a sentinel that indicates omitting the PTransformLabel altogether?
Seems like you are going out of your way to set it to "" here, but I was thinking the contract was null ⟺ [PCollection-scoped metric]
There was a problem hiding this comment.
You can't actually set the proto value to null, it will crash the program. This is an invalid input case though, since all user counters must be scoped to their step. I removed the test case which caused me to add this in the first place. If this occurs, we should drop the metric. I'll add a test for that too
|
|
||
| builder = new SimpleMonitoringInfoBuilder(); | ||
| builder.setUrnForUserMetric("ns", "name2"); | ||
| builder.setPTransformLabel(""); |
There was a problem hiding this comment.
same question as above about null vs "" here
There was a problem hiding this comment.
Reworked this test to use a non user counter on the unbounded container
|
|
||
| @DoFn.FinishBundle | ||
| public void finishBundle() throws InterruptedException { | ||
| // Thread.sleep(2000); // TODO smarter test without sleeps??? |
There was a problem hiding this comment.
should this still be here?
| MonitoringInfoMetricName metricName = | ||
| MonitoringInfoMetricName.named(SimpleMonitoringInfoBuilder.ELEMENT_COUNT_URN, labels); | ||
| this.counter = LabeledMetrics.counter(metricName); | ||
| // Place it in a metric container which is not bound to the step name. |
There was a problem hiding this comment.
I'm having trouble parsing this comment. What is "it"? "not likely" below is a bit cryptic… can it ever happen?
If you are moved to elaborate, that would be great, but not essential 😀
| c1.inc(5); | ||
|
|
||
| List<MonitoringInfo> expected = new ArrayList<MonitoringInfo>(); | ||
| // ArrayList<MonitoringInfo> actual = testObject.getMonitoringInfos(); |
| } | ||
|
|
||
| /** @return a MetricName for a specific urn and labels map. */ | ||
| /** @return a MonitoringInfoMetricName for a specific urn and labels map. */ |
There was a problem hiding this comment.
Unless it is forced by linter, this comment is obsolete, since it repeats method signature without adding extra information.
Method can be renamed to generateMetricName for readability.
| /** @return a MonitoringInfoMetricName for a specific urn and labels map. */ |
Please add a meaningful description for your change here
Set the PTransform name on Java SDK User counters
Follow this checklist to help us incorporate your contribution quickly and easily:
[BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replaceBEAM-XXXwith the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.It will help us expedite review of your Pull Request if you tag someone (e.g.
@username) to look at it.Post-Commit Tests Status (on master branch)