Skip to content
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

Merged

Conversation

vcasadei
Copy link
Contributor

@vcasadei vcasadei commented Sep 4, 2018

No description provided.

MarceloAquino7 and others added 30 commits August 14, 2018 14:41
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
Copy link
Member

Choose a reason for hiding this comment

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

Spurious?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed it

@@ -230,7 +230,6 @@ def increment_bucket_count(self, value):
return i

self._counts_per_bucket[(len(self._bounds))-1] += 1

Copy link
Member

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

Choose a reason for hiding this comment

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

Remove the lines here?

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

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.

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

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.

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

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?

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

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.

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

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

Copy link

@eduardoemery eduardoemery Sep 17, 2018

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.

@odeke-em
Copy link
Member

@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
so that we have the commits relevant to this PR?

import time

from opencensus.stats import aggregation as aggregation_module
from opencensus.stats.exporters import prometheus_exporter as prometheus
Copy link
Member

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.

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

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.

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,
Copy link
Member

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.

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.

@eduardoemery
Copy link

Hey guys. I'll give a little help here.

@eduardoemery eduardoemery force-pushed the prometheus_exporter branch 5 times, most recently from e0b97ee to 7706ed7 Compare September 17, 2018 19:32
@songy23 songy23 added cla: yes and removed cla: no labels Sep 19, 2018
@googlebot
Copy link

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

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

Successfully merging this pull request may close these issues.

10 participants