-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prometheus exporter #294
Prometheus exporter #294
Conversation
Removing stats exporter stuff Removing unused imports Minor changes in comments and copyright Unit tests for LastValue aggregation
Removing stats exporter stuff Removing unused imports Minor changes in comments and copyright Unit tests for LastValue aggregation
* Fix bug in updating aggregation map. * Update unit tests. * Use tag_value_aggregation_data_map instead of tag_value_aggregation_map.
README.rst
Outdated
@@ -516,3 +573,4 @@ Disclaimer | |||
---------- | |||
|
|||
This is not an official Google product. | |||
gi |
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.
Spurious?
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.
Removed it
opencensus/stats/aggregation_data.py
Outdated
@@ -230,7 +230,6 @@ def increment_bucket_count(self, value): | |||
return i | |||
|
|||
self._counts_per_bucket[(len(self._bounds))-1] += 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.
Spurious line? Please remove it.
measure_map.measure_int_put(VIDEO_SIZE_MEASURE, 25 * MiB) | ||
measure_map.record(tag_map) | ||
|
||
# Use the line below to see the data on prometheus |
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.
Remove the lines 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.
Hmm, I'm not sure. If we remove, the user may not be able to access Prometheus before the code finishes. This is just a way to time.sleep()
for an uncertain amount of time and allow the user to see the collected data on Prometheus. Do you have any suggestions on how to do that in a better way?
return self._registered_views | ||
|
||
def register_view(self, view): | ||
""" register_view will create the needed structure |
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.
Start with uppercase letter and same for the doc lines below.
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.
It is lower case because we start with the method name (as done in other classes). Do you prefer if we start with the description, like Will create...
?
signature = view_signature(self.options.namespace, view_data.view) | ||
self.view_data[signature] = view_data | ||
|
||
def to_metric(self, desc, view): |
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.
Add docs for args and returns 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.
Done! Please let me know if it can be improved.
agg_data = view.aggregation.aggregation_data | ||
|
||
if isinstance(agg_data, aggregation_data_module.CountAggregationData): | ||
labels = desc['labels'] if agg_data.count_data is None else None |
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 looks a little strange, could you explain the relationship between desc
labels and agg_data.count_data
?
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.
desc['labels']
has the Aggregation Data columns. So, if there is no aggregation data to get the columns from, it gets from desc
. This may be necessary at the begging of an aggregation, when no data point was recorded.
class PrometheusStatsExporter(base.StatsExporter): | ||
""" Exporter exports stats to Prometheus, users need | ||
to register the exporter as an HTTP Handler to be | ||
able to export. |
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.
Add docstrings about the params uses in the constructor.
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! Please let me know if it can be improved.
gatherer, | ||
transport=sync.SyncTransport, | ||
collector=Collector()): | ||
self._options = options |
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.
Looking at the Options
class, all of its args have default value and are optional. So can we also make the options
param here optional?
if options is None:
options = Options()
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.
Indeed it has default values, but at least the namespace has to be changed since it is an empty string and new_stats_exporter()
doesn't allow empty namespaces in the options. So, unless we set a non-empty namespace as default or allow empty namespaces to create exporters, we have to keep this way.
@vcasadei thanks for the PR! However, how come this PR has more than 20 commits that are unrelated to this PR? Could you please properly rebase it with master so that it is up to-date but also |
import time | ||
|
||
from opencensus.stats import aggregation as aggregation_module | ||
from opencensus.stats.exporters import prometheus_exporter as prometheus |
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 don't we keep the file name as prometheus? Instead of prometheus_exporter, which already resides under opencensus/stats/exporters, hence the _exporter suffix here there is redundant.
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.
I got your point, but this is how the exporters files where named in trace and stats before. I believe they were just following the pattern. But I like your suggestion, I think we can open an issue about this.
@@ -0,0 +1,339 @@ | |||
# Copyright 2018, 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.
I commented about keeping this file name as prometheus.py
instead of prometheus_exporter.py
because it already resides under opencensus/stats/exporters
so the _exporter.py
suffix is redundant.
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.
Same of the last discussion 😄
""" | ||
def __init__(self, | ||
namespace='', | ||
port=8000, |
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.
Let's document this default port.
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, thanks for noticing. Please let me know if it can be improved.
Hey guys. I'll give a little help here. |
e0b97ee
to
7706ed7
Compare
7706ed7
to
ed73ffd
Compare
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) |
No description provided.