Skip to content

[BEAM-4775] MonitoringInfo URN tweaks - #7868

Closed
ryan-williams wants to merge 7 commits into
apache:masterfrom
ryan-williams:mis
Closed

ryan-williams wants to merge 7 commits into
apache:masterfrom
ryan-williams:mis

Conversation

@ryan-williams

@ryan-williams ryan-williams commented Feb 17, 2019 •

Copy link
Copy Markdown
Contributor

rename a couple of proto URNs and specs, and perform a few other improvements to the Java SDK's handling of MonitoringInfos

R: @robertwb, @ajamato

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 Build Status
Python Build Status --- Build Status
Build Status
Build Status --- --- ---

See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.

@ryan-williams

Copy link
Copy Markdown
Contributor Author

Run Java PreCommit

// TODO(ajamato): Add the PTRANSFORM name as a required label after
// upgrading the python SDK.
USER_COUNTER = 0 [(monitoring_info_spec) = {
USER_METRIC = 0 [(monitoring_info_spec) = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

beam:metric:user: is a prefix, not a full URN, and probably shouldn't be in this table.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Currently, metrics are either of "user" type (defined by {ptransform, namespace, name}), or they're one of the 5 "system"-metric types below.

It's true that the "user" category is not a "specific URN", so there is tension with e.g. this docstring above.

I think of this table as enumerating the possible metrics-URN categories (indeed, that's what it does, and what our design calls for, as opposed to e.g. enumerating all allowed "user"-metric URNs here). The 5 "system" categories are each inhabited by exactly one URN, so they are particularly easy to deal with in SDKs, while the user-metric category requires special treatment (which, conveniently, the SDKs already implement).

In this PR, I am laying some groundwork toward supporting more "types" of metrics (both "user" and "system"). "User" metrics should be able to take on the three types listed here (counter, distribution, gauge).

With that context, there's a few directions I can see taking your comment:

  • split the "user" category into 3 type-specific user-categories
  • leave as-is, but make the docs more clear about the special status of USER_METRIC's "spec"
  • some larger overhaul involving removing user metrics from this table.

Let me know what you think!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The "user metric" prefix should not be in this table. (We also shouldn't be restricting user metrics here, any valid metric type is a valid user metric type.)

@ajamato

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK. Should USER_METRIC_URN_PREFIX (aka USER_COUNTER_URN_PREFIX) also not be in MonitoringInfoUrns.Enum, or is the issue just with this MonitoringInfoSpecs table?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just an issue with the table, which should be listing specific metrics.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK, so:

sgty?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@Ardagan and I have discussed that its not really the best idea to make the URN a prefix for the user metric. As this has led to writing a lot of code to parse the URN to obtain those fields out. And being this weird exception makes all the code have to special case it.

It would be better to package the namespace and name as a label on the MonitoringInfo.
Then we could use the same URN everywhere, no parsing, no special casing.

Given this, then there are two choices i.e.
(1) Use a different URN for user gauge, counter and distribution

  • "beam:metric:user:counter:v1"
  • "beam:metric:user:gauge:v1"
  • "beam:metric:user:distribution:v1"
    Then change the MonitoringInfoSpec:
    required_labels: [ "PTRANSFORM", "NAMESPACE", "NAME" ],
    and each will have a separate type_urn in their spec.
    type_urn:

(2) Use a single URN "beam:metric:user:v1" for user gauge, counter, distribution
Then change the MonitoringInfoSpec as well:
required_labels: [ "PTRANSFORM", "NAMESPACE", "NAME" ],
and we will NOT enforce the type_urn in the spec.

I prefer #1, as this will better describe each one, and if we add new user metric styles we can add a spec for them

@ryan-williams
ryan-williams force-pushed the mis branch 4 times, most recently from 81f77f9 to 53c54f0 Compare February 19, 2019 05:11
@ryan-williams

Copy link
Copy Markdown
Contributor Author

Run Java PreCommit

@ajamato ajamato left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Just curious, what were you hoping to get out of this change in particular? This is largely a bunch of renamings, was it too confusing before?

ELEMENT_COUNT = 0 [(monitoring_info_spec) = {
urn: "beam:metric:element_count:v1",
type_urn: "beam:metrics:sum_int_64",
// TODO(ryan): we currently also generate this metric with ["PTRANSFORM"] labels, but it fails validation in

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That's in python @Ardagan is fixing that implementation to emit the PCollection name. This is the one spec runners should support.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK. I'll leave this for now, perhaps I can remove it before this gets merged, if @Ardagan fixes it first, or lmk what you suggest!

// MonitoringInfo protos.
message MonitoringInfoSpecs {
enum Enum {
// TODO(ajamato): Add the PTRANSFORM name as a required label after

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Let's keep this one in please. @Ardagan's validation is going to pull in these strings soon. We are hoping to remove the MonitoringInfoUrns section and just have MonitoringInfoSpecs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The problem is that "beam:metric:user:" isn't actually a counter, nor does it have a specific type, so putting it in this list seems wrong. It's just a prefix that we assert will not be used for any runner-generated counters.

[If we do remove it, no need to renumber everything else.]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

[If we do remove it, no need to renumber everything else.]

generateProto fails without the renumbering:

Execution failed for task ':beam-model-fn-execution:generateProto'.
> protoc: stdout: . stderr: beam_fn_api.proto: The first enum value must be zero in proto3.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

(update: it seems if I only renumber the first entry to 0, I can skip 1 and leave the others untouched. Given that these aren't really used yet, it feels cleaner to just renumber them all now)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My take on this:

  1. It is better ot keep this spec present. It defines what fields user counter needs.
  2. We can rename this element to something like USER_COUNTER_PREFIX for clarity.
  3. It is ok to move it away from this list, but we should still keep it somewhere for generic validation and specification. However in this case we might want to move it away from MonitoringInfoUrns as well.
  4. Currently, we have urns defined in this list and in MonitoringInfoUrns. I was thinking of removing MonitoringInfoUrns completely and keep only MonitoringInfoSpecs as explicit source of truth.

if (urn.startsWith(USER_METRIC_URN_PREFIX)) {
urn = urn.substring(USER_METRIC_URN_PREFIX.length());
} else {
return null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Did you encounter this somewhere? Hopefully this isn't called if the metric isn't actually starting with USER_METRIC_URN_PREFIX

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As of this PR, this helper is called in two places:

  • MonitoringInfoMetricName.parseUrn:
    • use the parsed user-MetricName, if possible
    • throw if it's not a user-metric (signaled by null return here)
  • FlinkMetricContainer.updateMetrics:
    • use the parsed user-MetricName, if possible
    • skip the metric if it's not a user-metric (again, signaled by null return)
      • in later PRs I make Flink support system-metrics as well.

This was the most direct way to support those uses. The Flink metrics do actually see system metrics, and should gracefully skip them instead of throwing (for now).

@ryan-williams

ryan-williams commented Feb 19, 2019 •

Copy link
Copy Markdown
Contributor Author

Just curious, what were you hoping to get out of this change in particular? This is largely a bunch of renamings, was it too confusing before?

There are 2 renamings:

  • 0022bf9: MonitoringInfoLabels.{TRANSFORM → PTRANSFORM}, per this TODO(ajamato) 😄
  • 0715c19: USER_COUNTER_URN_PREFIX → USER_METRIC_URN_PREFIX
    • (in SimpleMonitoringInfoBuilder and MonitoringInfoUrns.Enum)
    • we need either this change, or to add new user-URN-prefixes for distributions/gauges, afaict.

There are also 6 other commits here that each constitute minor forward progress, I think:

Sorry if it just feels like dust. I thought these were all thematically similar and a reasonable chunk to pull out of #7823 and reckon with independently.

@ryan-williams
ryan-williams force-pushed the mis branch 2 times, most recently from dac2905 to 0715c19 Compare February 20, 2019 04:42
@ryan-williams

Copy link
Copy Markdown
Contributor Author

Run Java PreCommit

@ryan-williams

Copy link
Copy Markdown
Contributor Author
:beam-sdks-java-io-cassandra:test FAILED
--
 
org.apache.beam.sdk.io.cassandra.CassandraIOTest > classMethod FAILED
java.lang.AssertionError at CassandraIOTest.java:100
 
org.apache.beam.sdk.io.cassandra.CassandraIOTest > classMethod FAILED
java.lang.NullPointerException at CassandraIOTest.java:125
 
6 tests completed, 2 failed

scan

@ryan-williams

Copy link
Copy Markdown
Contributor Author

Run Java PreCommit

@ryan-williams

Copy link
Copy Markdown
Contributor Author

I think the big outstanding question here is around removing the spec for user metrics here (with context here).

@stale

stale Bot commented May 5, 2019

Copy link
Copy Markdown

This pull request has been marked as stale due to 60 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@beam.apache.org list. Thank you for your contributions.

@stale stale Bot added the stale label May 5, 2019
@stale

stale Bot commented May 12, 2019

Copy link
Copy Markdown

This pull request has been closed due to lack of activity. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time.

@stale stale Bot closed this May 12, 2019
@lukecwik lukecwik reopened this May 13, 2019
@stale

stale Bot commented May 13, 2019

Copy link
Copy Markdown

This pull request is no longer marked as stale.

@stale stale Bot removed the stale label May 13, 2019
@stale

stale Bot commented Jul 12, 2019

Copy link
Copy Markdown

This pull request has been marked as stale due to 60 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@beam.apache.org list. Thank you for your contributions.

@stale stale Bot added the stale label Jul 12, 2019
@stale

stale Bot commented Jul 19, 2019

Copy link
Copy Markdown

This pull request has been closed due to lack of activity. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time.

@stale stale Bot closed this Jul 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants