Skip to content

Commit 868e7da

Browse files
authored
temporality (Azure#26924)
1 parent f23a72b commit 868e7da

File tree

2 files changed

+22
-1
lines changed
  • sdk/monitor/azure-monitor-opentelemetry-exporter

2 files changed

+22
-1
lines changed

sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

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

1012
### Breaking Changes
1113

sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/metrics/_exporter.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,16 @@
44

55
from typing import Optional, Any
66

7+
from opentelemetry.sdk.metrics import (
8+
Counter,
9+
Histogram,
10+
ObservableCounter,
11+
ObservableGauge,
12+
ObservableUpDownCounter,
13+
UpDownCounter,
14+
)
715
from opentelemetry.sdk.metrics.export import (
16+
AggregationTemporality,
817
DataPointT,
918
HistogramDataPoint,
1019
MetricExporter,
@@ -32,14 +41,24 @@
3241
__all__ = ["AzureMonitorMetricExporter"]
3342

3443

44+
APPLICATION_INSIGHTS_METRIC_TEMPORALITIES = {
45+
Counter: AggregationTemporality.DELTA,
46+
Histogram: AggregationTemporality.DELTA,
47+
ObservableCounter: AggregationTemporality.DELTA,
48+
ObservableGauge: AggregationTemporality.CUMULATIVE,
49+
ObservableUpDownCounter: AggregationTemporality.CUMULATIVE,
50+
UpDownCounter: AggregationTemporality.CUMULATIVE,
51+
}
52+
53+
3554
class AzureMonitorMetricExporter(BaseExporter, MetricExporter):
3655
"""Azure Monitor Metric exporter for OpenTelemetry."""
3756

3857
def __init__(self, **kwargs: Any) -> None:
3958
BaseExporter.__init__(self, **kwargs)
4059
MetricExporter.__init__(
4160
self,
42-
preferred_temporality=kwargs.get("preferred_temporality"),
61+
preferred_temporality=APPLICATION_INSIGHTS_METRIC_TEMPORALITIES,
4362
preferred_aggregation=kwargs.get("preferred_aggregation"),
4463
)
4564

0 commit comments

Comments
 (0)