Skip to content

Commit

Permalink
temporality (#26924)
Browse files Browse the repository at this point in the history
  • Loading branch information
lzchen authored Oct 20, 2022
1 parent f23a72b commit 868e7da
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

- Add validation logic to ApplicationInsightsSampler
([#26546](https://github.com/Azure/azure-sdk-for-python/pull/26546))
- Change default temporality of metrics to follow OTLP
([#26546](https://github.com/Azure/azure-sdk-for-python/pull/26546))

### Breaking Changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@

from typing import Optional, Any

from opentelemetry.sdk.metrics import (
Counter,
Histogram,
ObservableCounter,
ObservableGauge,
ObservableUpDownCounter,
UpDownCounter,
)
from opentelemetry.sdk.metrics.export import (
AggregationTemporality,
DataPointT,
HistogramDataPoint,
MetricExporter,
Expand Down Expand Up @@ -32,14 +41,24 @@
__all__ = ["AzureMonitorMetricExporter"]


APPLICATION_INSIGHTS_METRIC_TEMPORALITIES = {
Counter: AggregationTemporality.DELTA,
Histogram: AggregationTemporality.DELTA,
ObservableCounter: AggregationTemporality.DELTA,
ObservableGauge: AggregationTemporality.CUMULATIVE,
ObservableUpDownCounter: AggregationTemporality.CUMULATIVE,
UpDownCounter: AggregationTemporality.CUMULATIVE,
}


class AzureMonitorMetricExporter(BaseExporter, MetricExporter):
"""Azure Monitor Metric exporter for OpenTelemetry."""

def __init__(self, **kwargs: Any) -> None:
BaseExporter.__init__(self, **kwargs)
MetricExporter.__init__(
self,
preferred_temporality=kwargs.get("preferred_temporality"),
preferred_temporality=APPLICATION_INSIGHTS_METRIC_TEMPORALITIES,
preferred_aggregation=kwargs.get("preferred_aggregation"),
)

Expand Down

0 comments on commit 868e7da

Please sign in to comment.