Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Initial draft for a metrics, an API for exporters. #53

Merged
merged 3 commits into from
Apr 30, 2018

Conversation

bogdandrutu
Copy link
Contributor

@bogdandrutu bogdandrutu commented Apr 15, 2018

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:

  • The current OpenCensus stats API is hard to be used for real GAUGE metrics (any pre-aggregated metric, e.g. machine-cpu-usage).
  • The current OpenCensus stats exporter API is focus only on supporting OpenCensus stats, but the library needs to support different external sources (dropwizard, etc.) and supporting these sources is very hard with the current OpenCensus stats exporter API.

Here is an example of how to map ViewData into the Metrics:

MetricPoint
  MetricDescriptor
     Name <- ViewData.View.name
     Description <- ViewData.View.description
     Unit <- ViewData.View.Measure.unit
     Type <- Cumulative (except LastValue which is GAUGE)
  TimeSeries
     Labels <- {ViewData.rows, ViewData.View.columns}
  CumulativePoint
     Value <- ViewData.AggregationData.value (for DistributionValue the bucket_bounds are defined in the ViewData.View.DistributionAggregation.bucket_bounds)
     Start_time <- ViewData.start_time
     End_time <- ViewData.end_time

@bogdandrutu
Copy link
Contributor Author

This PR will allow to make progress on census-instrumentation/opencensus-specs#59

@deadtrickster
Copy link
Member

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.

Copy link
Contributor

@songy23 songy23 left a 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'
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -0,0 +1,33 @@
# Copyright 2017, OpenCensus Authors
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: s/2017/2018

Copy link
Contributor Author

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.
Copy link
Contributor

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?

Copy link
Contributor Author

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.
Copy link
Contributor

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?

Copy link
Contributor Author

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@bogdandrutu
Copy link
Contributor Author

@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 {
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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 {
Copy link
Contributor

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

Choose a reason for hiding this comment

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

trip -> rip

Copy link
Contributor Author

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

Choose a reason for hiding this comment

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

this metric -> this timeseries

Copy link
Contributor Author

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"],
)
Copy link
Contributor

Choose a reason for hiding this comment

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

line ending missing

Copy link
Contributor Author

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.
Copy link
Contributor

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

Copy link
Contributor Author

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

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.

Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants