Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f05bd39
add toString()s to Metrics classes
ryan-williams Jan 27, 2019
ef44fa2
add MetricResult.result wrapper around committed || attempted
ryan-williams Jan 27, 2019
b4b5495
fix MetricQueryResults comments
ryan-williams Jan 28, 2019
ea14497
Some initial code
Jan 19, 2019
8049119
got start and finish metrics working
Jan 19, 2019
875ce2f
Fixup after merge and make process work with user metrics as well
Jan 25, 2019
11e67f3
Fixup after merge and make process work with user metrics as well
Jan 25, 2019
3367b34
Broken MetricContainerStepMap tests
Jan 25, 2019
d406df6
More tests passing
Jan 26, 2019
b94d070
Did a bit of a pass on my own
Jan 26, 2019
745ae62
spotless
Jan 26, 2019
f5bc350
Add tests for ElementCountFnDataReceiver, PCollectionConsumerRegistry…
Jan 30, 2019
76e1f31
Added another test to MetricsContainerStepMap
Jan 30, 2019
6525491
spotless
Jan 30, 2019
8d37535
spotless
Jan 30, 2019
9c89a03
Merge in upstream/HEAD,pr/7656,a/user_counter_ptransform_name
ryan-williams Jan 30, 2019
d8dbc49
move Metric protos from model/fn-execution to model/pipeline
ryan-williams Jan 27, 2019
a245f38
add MetricKey, MetricName protos
ryan-williams Jan 27, 2019
417341e
add GetJobMetrics RPC, associated protos
ryan-williams Jan 25, 2019
d7a3b6a
protect against null step-name (e.g. for PCollection metrics) in Metr…
ryan-williams Jan 27, 2019
3c097fd
add JobInvocation.getMetrics() API
ryan-williams Jan 25, 2019
8b0074d
populate metrics in FlinkJobInvocation
ryan-williams Jan 25, 2019
46bb652
store flink metrics keyed by step name
ryan-williams Jan 25, 2019
43c4e36
implement GetJobMetrics RPC in InMemoryJobService
ryan-williams Jan 25, 2019
94abd52
surface metrics in JobServicePipelineResult
ryan-williams Jan 25, 2019
75e15bd
implement portable python metrics over job API
ryan-williams Jan 25, 2019
85e066e
enable Flink PVR metrics cases
ryan-williams Jan 27, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 2 additions & 63 deletions model/fn-execution/src/main/proto/beam_fn_api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ option go_package = "fnexecution_v1";
option java_package = "org.apache.beam.model.fnexecution.v1";
option java_outer_classname = "BeamFnApi";

import "beam_pipeline_metrics.proto";
import "beam_runner_api.proto";
import "endpoints.proto";
import "google/protobuf/descriptor.proto";
Expand Down Expand Up @@ -428,7 +429,7 @@ message MonitoringInfo {
// The Metric or monitored state.
oneof data {
MonitoringTableData monitoring_table_data = 3;
Metric metric = 4;
org.apache.beam.model.pipeline.v1.Metric metric = 4;
}

enum MonitoringInfoLabels {
Expand Down Expand Up @@ -494,68 +495,6 @@ message MonitoringInfoTypeUrns {
}
}

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?

// (Required) The data for this metric.
oneof data {
CounterData counter_data = 1;
DistributionData distribution_data = 2;
ExtremaData extrema_data = 3;
}
}

// Data associated with a Counter or Gauge metric.
// This is designed to be compatible with metric collection
// systems such as DropWizard.
message CounterData {
oneof value {
int64 int64_value = 1;
double double_value = 2;
string string_value = 3;
}
}

// Extrema messages are used for calculating
// Top-N/Bottom-N metrics.
message ExtremaData {
oneof extrema {
IntExtremaData int_extrema_data = 1;
DoubleExtremaData double_extrema_data = 2;
}
}

message IntExtremaData {
repeated int64 int_values = 1;
}

message DoubleExtremaData {
repeated double double_values = 2;
}

// Data associated with a distribution metric.
// This is based off of the current DistributionData metric.
// This is not a stackdriver or dropwizard compatible
// style of distribution metric.
message DistributionData {
oneof distribution {
IntDistributionData int_distribution_data = 1;
DoubleDistributionData double_distribution_data = 2;
}
}

message IntDistributionData {
int64 count = 1;
int64 sum = 2;
int64 min = 3;
int64 max = 4;
}

message DoubleDistributionData {
int64 count = 1;
double sum = 2;
double min = 3;
double max = 4;
}

// General MonitoredState information which contains
// structured information which does not fit into a typical
// metric format. For example, a table of important files
Expand Down
12 changes: 12 additions & 0 deletions model/job-management/src/main/proto/beam_job_api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ option java_outer_classname = "JobApi";

import "beam_runner_api.proto";
import "endpoints.proto";
import "beam_job_metrics.proto";
import "google/protobuf/struct.proto";


Expand All @@ -57,6 +58,9 @@ service JobService {

// Get the supported pipeline options of the runner
rpc DescribePipelineOptions (DescribePipelineOptionsRequest) returns (DescribePipelineOptionsResponse);

// Fetch metrics for a given job
rpc GetJobMetrics (GetJobMetricsRequest) returns (GetJobMetricsResponse);
}


Expand Down Expand Up @@ -155,6 +159,14 @@ message JobMessage {
}
}

message GetJobMetricsRequest {
string job_id = 1; // (required)
}

message GetJobMetricsResponse {
repeated MetricStatus metric_statuses = 1;
}

message JobMessagesResponse {
oneof response {
JobMessage message_response = 1;
Expand Down
54 changes: 54 additions & 0 deletions model/job-management/src/main/proto/beam_job_metrics.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* Protocol Buffers for sending metrics over the Job API, between a runner and job server
*/

syntax = "proto3";

package org.apache.beam.model.job_management.v1;

option go_package = "jobmanagement_v1";
option java_package = "org.apache.beam.model.jobmanagement.v1";
option java_outer_classname = "JobApiMetrics";

import "beam_pipeline_metrics.proto";

message CounterResult {
int64 attempted = 1;
int64 committed = 2;
}

message DistributionResult {
org.apache.beam.model.pipeline.v1.IntDistributionData attempted = 1;
org.apache.beam.model.pipeline.v1.IntDistributionData committed = 2;
}

message MetricResult {
oneof result {
CounterResult counter_result = 1;
DistributionResult distribution_result = 2;
}
}

message MetricStatus {
org.apache.beam.model.pipeline.v1.MetricKey metric_key = 1;
MetricResult metric_result = 2;
}

103 changes: 103 additions & 0 deletions model/pipeline/src/main/proto/beam_pipeline_metrics.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* Protocol Buffers describing the Runner API, which is the runner-independent,
* SDK-independent definition of the Beam model.
*/

syntax = "proto3";

package org.apache.beam.model.pipeline.v1;

option go_package = "pipeline_v1";
option java_package = "org.apache.beam.model.pipeline.v1";
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?

MetricName metric_name = 2;
}

message MetricName {
string namespace = 1;
string name = 2;
}

message Metric {
// (Required) The data for this metric.
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)

}
}

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

// This is designed to be compatible with metric collection
// systems such as DropWizard.
message CounterData {
oneof value {
int64 int64_value = 1;
double double_value = 2;
string string_value = 3;
}
}

// Extrema messages are used for calculating
// Top-N/Bottom-N metrics.
message ExtremaData {
oneof extrema {
IntExtremaData int_extrema_data = 1;
DoubleExtremaData double_extrema_data = 2;
}
}

message IntExtremaData {
repeated int64 int_values = 1;
}

message DoubleExtremaData {
repeated double double_values = 2;
}

// Data associated with a distribution metric.
// This is based off of the current DistributionData metric.
// This is not a stackdriver or dropwizard compatible
// style of distribution metric.
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.

}
}

message IntDistributionData {
int64 count = 1;
int64 sum = 2;
int64 min = 3;
int64 max = 4;
}

message DoubleDistributionData {
int64 count = 1;
double sum = 2;
double min = 3;
double max = 4;
}

Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ private MetricFiltering() {}
public static boolean matches(MetricsFilter filter, MetricKey key) {
return filter == null
|| (matchesName(key.metricName(), filter.names())
&& key.stepName() != null
&& matchesScope(key.stepName(), filter.steps()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import com.google.auto.value.AutoValue;
import java.io.Serializable;
import javax.annotation.Nullable;
import org.apache.beam.sdk.annotations.Experimental;
import org.apache.beam.sdk.annotations.Experimental.Kind;
import org.apache.beam.sdk.metrics.MetricName;
Expand All @@ -28,12 +29,18 @@
@AutoValue
public abstract class MetricKey implements Serializable {

/** The step name that is associated with this metric. */
/** The step name that is associated with this metric or Null if none is associated. */
@Nullable
public abstract String stepName();

/** The name of the metric. */
public abstract MetricName metricName();

@Override
public String toString() {
return String.format("%s:%s", stepName(), metricName());
}

public static MetricKey create(String stepName, MetricName metricName) {
return new AutoValue_MetricKey(stepName, metricName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
@Experimental(Kind.METRICS)
public class MetricsContainerImpl implements Serializable, MetricsContainer {

private final String stepName;
@Nullable private final String stepName;

private MetricsMap<MetricName, CounterCell> counters = new MetricsMap<>(CounterCell::new);

Expand All @@ -60,7 +60,7 @@ public class MetricsContainerImpl implements Serializable, MetricsContainer {
private MetricsMap<MetricName, GaugeCell> gauges = new MetricsMap<>(GaugeCell::new);

/** Create a new {@link MetricsContainerImpl} associated with the given {@code stepName}. */
public MetricsContainerImpl(String stepName) {
public MetricsContainerImpl(@Nullable String stepName) {
this.stepName = stepName;
}

Expand Down Expand Up @@ -158,6 +158,11 @@ private MonitoringInfo counterUpdateToMonitoringInfo(MetricUpdate<Long> metricUp
builder.setUrnForUserMetric(
metricUpdate.getKey().metricName().getNamespace(),
metricUpdate.getKey().metricName().getName());
String stepName = "";
if (metricUpdate.getKey().stepName() != null) {
stepName = metricUpdate.getKey().stepName();
}
builder.setPTransformLabel(stepName);
}
builder.setInt64Value(metricUpdate.getUpdate());
builder.setTimestampToNow();
Expand Down
Loading