Skeleton for Azure Metrics Exporter#678
Skeleton for Azure Metrics Exporter#678reyang merged 24 commits intocensus-instrumentation:masterfrom
Conversation
contrib/opencensus-ext-azure/opencensus/ext/azure/metric_exporter/__init__.py
Outdated
Show resolved
Hide resolved
| .. code:: python | ||
|
|
||
| from opencensus.ext.azure import metric_exporter | ||
| from opencensus.stats import stats as stats_module |
There was a problem hiding this comment.
- Remove partial example code.
- Move from stats to metrics,
opencensus.statsis being replaced byopencensus.metrics. If we have dependency instats, we need to refactor it and move tometrics.
contrib/opencensus-ext-azure/opencensus/ext/azure/metric_exporter/__init__.py
Outdated
Show resolved
Hide resolved
|
|
||
| __all__ = ['MetricsExporter'] | ||
|
|
||
| class MetricsExporter(object): |
There was a problem hiding this comment.
Regarding the name, I wish to discuss about (we might want to do a better job in OpenTelemetry):
- Do we want to drive for some level of consistency or not at all (and leave this for individual vendor's choice of flavor)?
- When to use plural form versus not?
- Should the class name be specific or generic? (e.g. do we want AzureExporter, AzureMonitorExporter, AzureMetricExporter or AzureMetricsExporter, my personal preference would be something we did for Azure trace exporter and stackdriver trace exporter)
- Should the class name be self contained or we should leverage package name? (e.g.
ext.azure.trace_exporter.AzureExporter,ext.azure.TraceExporterorext.azure.AzureTraceExporter).
There was a problem hiding this comment.
Yes I was thinking about this as well. I think it is good to be consistent across the entire project and set some standards.
In my opinion:
-
We should use singular form when referring to the "task-doer" such as MetricExporter, TraceExporter, etc. We should use the plural when we are referring to the category in a collective context (this will export metrics..., the traces are sent through..., etc) because the logic involves one or possibly more of these.
-
In regards to the class name, I think we should be as specific as possible. When going through the codebase, it is easier to identify what module I am looking at without having to look at the package I am under (problem that I am having with init.py). Also, if we ever take code snippets, readers can identify what class is being looked at without having to see the file path.
-
In regards to leveraging the package name, separating the files based off levels is my preference. So ext.azure.trace_exporter.AzureTraceExporter would be ideal.
There was a problem hiding this comment.
@c24t what's your opinion?
Seems in OpenTelemetry Java we've already started to diverge (metrics and tags are plural form, while trace is not):
There was a problem hiding this comment.
We have just discussed the exact same issue recently, in open-telemetry/opentelemetry-java#259 (comment). The conclusion is:
Let's stick with what we have, but pluralize resources.
trace
metrics
tags
resources
There was a problem hiding this comment.
What about log? Using logs seems to be against language convention.
There was a problem hiding this comment.
We haven't talked about it but personally I'd suggest to go with log for now. Agree logs doesn't seem to be a great name here.
There was a problem hiding this comment.
I will make the changes based off these decisions for metrics.
|
Going to refactor the PR to use metrics instead of stats. |
README.rst
Outdated
| .. _threading: https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-threading | ||
| .. _Zipkin: https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-zipkin | ||
|
|
||
| Metrics Exporter |
There was a problem hiding this comment.
Probably need to put this under "Stats Exporter".
There was a problem hiding this comment.
Yes I will do that. I will change it back to Metrics next time when we truly have a metrics exporter.
| import logging | ||
|
|
||
| from opencensus.ext.azure.log_exporter import AzureLogHandler | ||
| from opencensus.ext.azure.logs_exporter import AzureLogHandler |
There was a problem hiding this comment.
This is a breaking change, we need to:
- Update the changelog to mention it, so users would know.
- Bump the version when we do a release.
I would suggest that we don't touch this for now (since we haven't yet finalized whether to take plural form or not).
There was a problem hiding this comment.
You're right. I did not realize this. I will revert this for now.
reyang
left a comment
There was a problem hiding this comment.
This PR is becoming too big.
Let's revert the log->logs change. Other parts looks good once we cleaned up CI error.
| Metrics | ||
| ~~~~~~~ | ||
|
|
||
| The **OpenCensus Azure Monitor Metrics Exporter** allows you to export metrics to `Azure Monitor`_. |
There was a problem hiding this comment.
Minor: I feel that we don't need to mention "OpenCensus" here given the context we have in the doc, otherwise it is too long?
Up to you, if you decide to keep it, need to update trace/logs to make them consistent.
There was a problem hiding this comment.
Yes, you are right. We should be consistent with the other two and it seems a bit redundant given the package we are in. I shall remove it.
| def main(): | ||
| # Enable metrics | ||
| # Set the interval in seconds in which you want to send metrics | ||
| exporter = metrics_exporter.new_metrics_exporter(export_interval=2) |
There was a problem hiding this comment.
Minor suggestion, it is not clear if the interval should be an integer or it can be a float/decimal, consider either update the comment or put something like 2.0 (if we do support float).
There was a problem hiding this comment.
We allow floats so I will put 2.0 in the sample to let users know implicitly this is possible.
There was a problem hiding this comment.
Great, this is something that we've been practicing, e.g. ProbabilitySampler(1.0) and
aggregation_module.DistributionAggregation(
[100.0, 200.0, 400.0, 1000.0, 2000.0, 4000.0]))
|
|
||
|
|
||
| def new_metrics_exporter(**options): | ||
| options = Options(**options) |
There was a problem hiding this comment.
I'm curious why would we want to validate options here versus in the MetricsExporter.__init__.
There was a problem hiding this comment.
I feel like validation logic should be handled in the service layer, outside of the constructor. IMO init should only serve to instantiate variables.
There was a problem hiding this comment.
Would you explain a bit more?
In general people do validate inside constructors, which prevent them from creating a wrong object.
There was a problem hiding this comment.
Hmm, it does seem like we do validation everywhere inside the constructor for a lot of classes. I can make the change to be consistent.
reyang
left a comment
There was a problem hiding this comment.
LGTM, I've left some minor suggestions.
Add skeleton metrics exporter to azure
Add skeleton metrics exporter to azure
Add skeleton metrics exporter to azure
Add skeleton metrics exporter to azure add bracket (census-instrumentation#690) Implement Azure Metrics Exporter (census-instrumentation#693) fix rst doc for Azure exporter bump version
Add skeleton metrics exporter to azure add bracket (census-instrumentation#690) Implement Azure Metrics Exporter (census-instrumentation#693) fix rst doc for Azure exporter bump version fix comment
Initial structure of the Azure Metrics Exporter.
Follows the StackDriver Stats Exporter logic. We use a poll-based mechanism instead of push-based as seen in the Prometheus Stats Exporter.
Currently, the exporter simply prints the meta data related to the metric.
@c24t @reyang