-
Notifications
You must be signed in to change notification settings - Fork 95
Initial draft for a metrics, an API for exporters. #53
Initial draft for a metrics, an API for exporters. #53
Conversation
This PR will allow to make progress on census-instrumentation/opencensus-specs#59 |
If I want to push number of open fds to opencensus, how I set timestamps? What "push" actually means? Will those Metrics be queried by Exporters somehow? There must be a Metrics registry somewhere for this. |
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.
A few nits but overall LGTM.
build.gradle
Outdated
@@ -21,6 +21,7 @@ sourceSets { | |||
main { | |||
proto { | |||
// In addition to the default 'src/main/proto' | |||
srcDir 'opencensus/proto/metrics' |
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.
Should this be under stats/metrics?
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.
Done.
opencensus/proto/metrics/BUILD.bazel
Outdated
@@ -0,0 +1,33 @@ | |||
# Copyright 2017, OpenCensus Authors |
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.
nit: s/2017/2018
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.
Done.
|
||
// Defines a metric type and its schema. | ||
message MetricDescriptor { | ||
// The metric type, including its DNS name prefix. It must be unique. |
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.
Should we mention the constraint (and possibly, sanitization rules) on MetricDescriptor names?
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.
Added a TODO for the moment.
} | ||
|
||
message Label { | ||
// The label name. |
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.
Similarly, should we mention the constraints here?
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.
Similar, added a TODO for the moment.
message Point { | ||
oneof point { | ||
GaugePoint gauge_point = 1; | ||
CumulativePoint points = 2; |
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.
nit: s/points/cumulative_point
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.
Done.
@deadtrickster updated the comment to not mention push/pull model yet. The way how I envision this framework is that you have: public class MetricSource {
public MetricPointSet getMetricPointSet();
}
public class MetricsExporter {
public void registerMetricSource(MetricSource);
} The way it will work is based on how exporters are pull (Prometheus) vs push (Stackdriver). In case of Prometheus we wait for the request to come and then query all the registered MetricSources to get the MetricPoints, in case of Stackdriver we set an exporting interval on the Stackdriver exporter (e.g. interval=10sec) then we configure a timer to wakeup every 10seconds and pull the data from all MetricSources. For reading the "fds" it depends on how you implement the MetricSource that reads the "fds", one example is to read the fds when the metrics framework calls getMetricPointSet then that will be the timestamp. |
} | ||
|
||
// Defines a MetricPoint which has one or more timeseries for a single metric. | ||
message MetricPoint { |
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.
Shouldn't this be named MetricTimeSeries? MetricPoint makes it sound like it represents only one point.
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.
Why not just "Metric"?
I agree that "point" is confusing.
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.
went with Metric/MetricSet. Let me know if it makes sense.
} | ||
|
||
// Defines a MetricPoint which has one or more timeseries for a single metric. | ||
message MetricPoint { |
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.
Why not just "Metric"?
I agree that "point" is confusing.
// Defines a MetricPoint which has one or more timeseries for a single metric. | ||
message MetricPoint { | ||
// The description of the metric. | ||
MetricDescriptor desctriptor = 1; |
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.
trip -> rip
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.
done
// A collection of data points that describes the time-varying values | ||
// of a metric. | ||
message TimeSeries { | ||
// The set of label values that uniquely identify this metric. Apply to all |
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 metric -> this timeseries
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.
done.
java_proto_library( | ||
name = "metrics_proto_java", | ||
deps = [":metrics_proto"], | ||
) |
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.
line ending missing
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.
done.
option java_package = "io.opencensus.proto.metrics"; | ||
option java_outer_classname = "MetricsProto"; | ||
|
||
// A collection of MetricPoint's. |
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.
No need for apostrophe here I think
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.
done.
message TimeSeries { | ||
// The set of label values that uniquely identify this metric. Apply to all | ||
// points. | ||
repeated Label label = 1; |
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.
Are duplicate keys permitted? If so, we should define here the behavior (i.e. last one wins) or we should switch to type map<string, string>. If not, we should say that duplicates are an error.
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.
My opinion would be to copy what map<string, string> does or switch to that
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.
Done.
This API can be seen as the api for the metrics/stats exporters, and it is not intended to replace the stats API.
The metrics API is intended to be used by the stats API as well as other metric systems (dropwizard, etc.) to send data using the census metric exporters framework.
Why do we need a different API for exporters:
Here is an example of how to map ViewData into the Metrics: