Skip to content

Commit b283376

Browse files
Add histogram (#27544)
* add histogram * add comment on count * Typecast by shift. * revert * add histogram to supported Co-authored-by: Rajkumar Rangaraj <[email protected]>
1 parent 43f84d7 commit b283376

File tree

1 file changed

+9
-0
lines changed
  • sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Customizations/Models

1 file changed

+9
-0
lines changed

sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Customizations/Models/MetricData.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ public MetricsData(int version, Metric metric, MetricPoint metricPoint) : base(v
5454
DataPointType = DataPointType.Measurement
5555
};
5656
break;
57+
case MetricType.Histogram:
58+
metricDataPoint = new MetricDataPoint(metric.Name, metricPoint.GetHistogramSum());
59+
metricDataPoint.DataPointType = DataPointType.Aggregation;
60+
long histogramCount = metricPoint.GetHistogramCount();
61+
// Current schema only supports int values for count
62+
// if the value is within integer range we will use it otherwise ignore it.
63+
metricDataPoint.Count = (histogramCount <= int.MaxValue && histogramCount >= int.MinValue) ? (int?)histogramCount : null;
64+
break;
5765
}
5866

5967
metricDataPoints.Add(metricDataPoint);
@@ -73,6 +81,7 @@ internal static bool IsSupportedType(MetricType metricType) =>
7381
MetricType.DoubleSum => true,
7482
MetricType.LongGauge => true,
7583
MetricType.LongSum => true,
84+
MetricType.Histogram => true,
7685
_ => false
7786
};
7887
}

0 commit comments

Comments
 (0)