Skip to content
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

Merged
merged 3 commits into from Jan 23, 2019

Conversation

Ardagan
Copy link
Contributor

@Ardagan Ardagan commented Dec 19, 2018

Minor refactoring to generalize validation and
counter transformation.


Follow this checklist to help us incorporate your contribution quickly and easily:

  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

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)

Lang SDK Apex Dataflow Flink Gearpump Samza Spark
Go Build Status --- --- --- --- --- ---
Java Build Status Build Status Build Status Build Status Build Status Build Status Build Status Build Status
Python Build Status --- Build Status
Build Status
Build Status --- --- ---

@Ardagan
Copy link
Contributor Author

Ardagan commented Dec 19, 2018

@ajamato

@Ardagan
Copy link
Contributor Author

Ardagan commented Dec 20, 2018

Run Portable_Python PreCommit

1 similar comment
@Ardagan
Copy link
Contributor Author

Ardagan commented Dec 20, 2018

Run Portable_Python PreCommit


@Before
public void setUp() throws Exception {
testObject = new SpecMonitoringInfoValidator();
Copy link

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

Copy link
Contributor Author

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() {
Copy link

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

Copy link

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.

Copy link
Contributor Author

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.


testInput =
MonitoringInfo.newBuilder()
.setUrn("beam:metric:element_count:v1")
Copy link

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

Copy link
Contributor Author

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?

Copy link

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 =
Copy link

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

Copy link
Contributor Author

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.

Copy link

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);

Copy link
Contributor Author

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));
Copy link

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.

Copy link
Contributor Author

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.

+ monitoringInfo.toString());
}

return Optional.empty();
Copy link

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.


testInput =
MonitoringInfo.newBuilder()
.setUrn("beam:metric:element_count:v1")
Copy link

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 =
Copy link

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);


String nameWithNamespace = urn.substring(BEAM_METRICS_USER_PREFIX.length()).replace("^:", "");

final int lastColonIndex = nameWithNamespace.lastIndexOf(':');
Copy link

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,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

@Ardagan
Copy link
Contributor Author

Ardagan commented Jan 17, 2019

Rebased on top of master.
+committer: @swegner

@swegner
Copy link
Contributor

swegner commented Jan 22, 2019

Run Java PreCommit

@Ardagan
Copy link
Contributor Author

Ardagan commented Jan 22, 2019

Run Python PreCommit

@Ardagan
Copy link
Contributor Author

Ardagan commented Jan 22, 2019

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.

Mikhail Gryzykhin added 3 commits January 22, 2019 14:44
Minor refactoring to generalize validation and
counter transformation.
@Ardagan
Copy link
Contributor Author

Ardagan commented Jan 22, 2019

Rebased on master. See if this was some merge issue.

@swegner
Copy link
Contributor

swegner commented Jan 23, 2019

The Java failure is a known-issue failing on master. I believe this is ok to merge.

@swegner swegner merged commit 8b4898e into apache:master Jan 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants