New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BEAM-6181] Implemented msec counters support in FnApi world. #7323
Conversation
Run Portable_Python PreCommit |
1 similar comment
Run Portable_Python PreCommit |
...ore-java/src/main/java/org/apache/beam/runners/core/metrics/SpecMonitoringInfoValidator.java
Outdated
Show resolved
Hide resolved
|
||
@Before | ||
public void setUp() throws Exception { | ||
testObject = new SpecMonitoringInfoValidator(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename test object to validator please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is one of approaches to implementing unittests, where you name object you're testing explicitly as testObject. This usually simplifies reading test since you always know what operations are called for tested obect and which are part of setup.
} | ||
|
||
@Test | ||
public void validateReturnsErrorOnInvalidMonitoringInfoType() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this test return an error? Seems like it is successful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just seems like the tests are a bit inverted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SpecMonitoringInfoValidator has only one method "validate", so I skip it in test names.
Test verifies that "validate" method returns error on invalid MonitoringInfo type received.
...ore-java/src/main/java/org/apache/beam/runners/core/metrics/SimpleMonitoringInfoBuilder.java
Show resolved
Hide resolved
|
||
testInput = | ||
MonitoringInfo.newBuilder() | ||
.setUrn("beam:metric:element_count:v1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use the constants please
SimpleMonitoringInfoBuilder.ELEMENT_COUNT_URN
SimpleMonitoringInfoBuilder.USER_COUNTER_PREFIX
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking of this, but since these constants will be declared outside of test body, it will make test less readable.
Do you think it is worth doing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like the shared constants to be used as much has possible. So there is a single place where it is defined, incase it needs to be chagned.
this.specValidator = specMonitoringInfoValidator; | ||
} | ||
|
||
static final String BEAM_METRICS_USER_PREFIX = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is defined in two files now, SimpleMonitoringInfoBuilder. Can we just define it in one place
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see it as this value is defined in one place -- beam_fn_api.proto and both, SimpleMonitoringInfoBuilder and UserMonitoringInfoToCounterUpdateTransformer only define convenient accessor to the field.
I think that creating a structure with these fields separate from proto will only bring more inconvenience to the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then can you use a shared static helper method to access it, so we don't duplicate the 4 getter calls below.
i.e. something like.
static final String BEAM_METRICS_USER_PREFIX = SimpleMonitoringInfo,getUrn(Enum.USER_COUNTER);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Synced offline. BeamUrns extracts value from MonitoringInfoUrns, while UserMonitoringInfoToCounterUpdateTransformer utilizes MonitoringInfoSpecs. Decided to keep this PR as-is and have a separate PR to remove MonitoringInfoUrns enum and utilize MonitoringInfoSpecs as source of truth.
|
||
String urn = monitoringInfo.getUrn(); | ||
if (!urnToCounterNameMapping.keySet().contains(urn)) { | ||
throw new RuntimeException(String.format("Received unexpected counter urn: %s", urn)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please just drop metrics if they are invalid, don't throw an exception. This would be bad for many of our users, who don't care about metrics but just want their pipeline to finish properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This exception doesn't validate MonitoringInfo, instead it checks validity of logic.
If MSecMonitoringInfoToCounterUpdateTransformer receives non-supported counter it is not a problem of counter, but invoking code.
...he/beam/runners/dataflow/worker/fn/control/MSecMonitoringInfoToCounterUpdateTransformer.java
Show resolved
Hide resolved
+ monitoringInfo.toString()); | ||
} | ||
|
||
return Optional.empty(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure on this style of returning a string error. Maybe another reviewer can comment.
...eam/runners/dataflow/worker/fn/control/MSecMonitoringInfoToCounterUpdateTransformerTest.java
Outdated
Show resolved
Hide resolved
|
||
testInput = | ||
MonitoringInfo.newBuilder() | ||
.setUrn("beam:metric:element_count:v1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like the shared constants to be used as much has possible. So there is a single place where it is defined, incase it needs to be chagned.
this.specValidator = specMonitoringInfoValidator; | ||
} | ||
|
||
static final String BEAM_METRICS_USER_PREFIX = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then can you use a shared static helper method to access it, so we don't duplicate the 4 getter calls below.
i.e. something like.
static final String BEAM_METRICS_USER_PREFIX = SimpleMonitoringInfo,getUrn(Enum.USER_COUNTER);
...e/beam/runners/dataflow/worker/fn/control/FnApiMonitoringInfoToCounterUpdateTransformer.java
Show resolved
Hide resolved
|
||
String nameWithNamespace = urn.substring(BEAM_METRICS_USER_PREFIX.length()).replace("^:", ""); | ||
|
||
final int lastColonIndex = nameWithNamespace.lastIndexOf(':'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that I wrote the same parsing code in one my PRs. You can submit yours first, but please add a TODO comment here to use a shared method for parsing the user metric format, and I'll take care of it,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
...-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/WorkItemStatusClient.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/apache/beam/runners/dataflow/worker/fn/control/BeamFnMapTaskExecutor.java
Outdated
Show resolved
Hide resolved
Rebased on top of master. |
Run Java PreCommit |
Run Python PreCommit |
Update on failures: I ran ./gradlew :beam-runners-direct-java:needsRunnerTests locally and it passes. Seem to be flake. Looking on how can I run python tests. Running :pythonPreCommit fails installing docs deps. Checking how can I repro the error. |
Minor refactoring to generalize validation and counter transformation.
Rebased on master. See if this was some merge issue. |
The Java failure is a known-issue failing on master. I believe this is ok to merge. |
Minor refactoring to generalize validation and
counter transformation.
Follow this checklist to help us incorporate your contribution quickly and easily:
[BEAM-XXX] Fixes bug in ApproximateQuantiles
, where you replaceBEAM-XXX
with 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)