Skip to content

[DO NOT MERGE] [BEAM-4775] Portable metrics over the job-server API - #7641

Closed
ryan-williams wants to merge 27 commits into
apache:masterfrom
ryan-williams:job-api-portable-metrics
Closed

ryan-williams wants to merge 27 commits into
apache:masterfrom
ryan-williams:job-api-portable-metrics

Conversation

@ryan-williams

@ryan-williams ryan-williams commented Jan 28, 2019 •

Copy link
Copy Markdown
Contributor

(Superseded by #7823)

(also fixes BEAM-4776 (Java) and BEAM-4777 (Python)

This currently sits on top of ajamato#1 (which adds a couple of tweaks to #7624) and #7656.

The last 11 commits (beginning with add GetJobMetrics RPC, associated protos) are hopefully well-differentiated, and represent the actual new functionality not covered by the PRs it's based on.

With this merged:

Submitting now to start CI-debugging, and also to seed some design discussions.

CC: @ajamato @mxm @robertwb @angoenka @tweise

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

@ryan-williams ryan-williams left a comment

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.

Highlighting a couple things for discussion / TODOs for myself

}
}

message Metric {

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.

FYI: I moved these into the model/pipeline module, where they are depended on by model/fn-execution and model/job-management modules.

They are in their own file there, beam_pipeline_metrics.proto.

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.

+1, I was about to suggest exactly this.

Could you perhaps break that out as a separate PR that we can get in while we are still working on the rest?

message DistributionData {
oneof distribution {
IntDistributionData int_distribution_data = 1;
DoubleDistributionData double_distribution_data = 2;

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.

TODO: per discussion with @ajamato, I think we were leaning toward only supporting the Int-types for now; existing Java metrics hard-code longs for counters, distributions, and gauges.

option java_outer_classname = "PipelineMetrics";

message MetricKey {
string step = 1;

@ryan-williams ryan-williams Jan 29, 2019 •

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.

This MetricKey and MetricName mimic classes in Java and Python, and represent them over the wire.

TODO: use these to replace the SDK-specific classes?

@ajamato's new scheme (in #7624) identifies PCollection-scoped metrics by a null "step" value.

TODO: should they be abandoned over the wire (and in SDKs?) in favor of URNs?

* Update Flink's internal metrics ({@link this#flinkCounterCache}) with the latest metrics for a
* given step.
*/
void updateMetrics(String stepName) {

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.

The "step name" had an incorrect value in portable contexts, pertaining to the name of a fused stage.

This now queries metrics for all steps that the metricsAccumulator has data for.

TODO: verify non-portable Flink code-paths didn't rely on this in any way.

.get()
.getJobMetrics(JobApi.GetJobMetricsRequest.newBuilder().setJobIdBytes(jobId).build());
List<JobApiMetrics.MetricStatus> statuses = response.getMetricStatusesList();
List<MetricResult<Long>> counters = new ArrayList<>();

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.

TODO: factor the proto→Java conversions here out to Protos.java

/** Return the metric results for the gauges that matched the filter. */
public abstract Iterable<MetricResult<GaugeResult>> getGauges();

static <T> void printMetrics(String type, Iterable<MetricResult<T>> metrics, PrintStream ps) {

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.

this file's changes come from #7656

oneof data {
CounterData counter_data = 1;
DistributionData distribution_data = 2;
ExtremaData extrema_data = 3;

@ryan-williams ryan-williams Jan 29, 2019 •

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.

TODO: ExtremaData isn't populated or consumed in the SDKs (afaik)

@Override
public MetricResults metrics() {
throw new UnsupportedOperationException("Not yet implemented.");
if (metricResults == null) {

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.

The semantics are currently that this should be called once the state is DONE, and at that time it fetches + caches the MetricsResults object for this job from the job server.

TODO: bypass caching the MetricResults object until the state becomes DONE, so that metrics() can be polled while a job is running.

}
}

// Data associated with a Counter or Gauge metric.

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.

TODO: support gauges being sent as CounterData

@ryan-williams
ryan-williams force-pushed the job-api-portable-metrics branch from 497e9f6 to 85e066e Compare January 31, 2019 02:44
@ajamato

ajamato commented Feb 6, 2019

Copy link
Copy Markdown

Let me know when you want to continue the review here. I would love to use this as a way to start writing tests for Metrics using the Dataflow Runner and the Unified Local Runner.

@ryan-williams

Copy link
Copy Markdown
Contributor Author

see #7823

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.

3 participants