Skip to content

Commit cd4d593

Browse files
update MetricsAdapter to include exemplars for counters (#949)
1 parent 3a3eddb commit cd4d593

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Sources/Exporters/OpenTelemetryProtocolCommon/metric/MetricsAdapter.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,14 @@ public enum MetricsAdapter {
228228
pointData.exemplars.forEach {
229229
var protoExemplar = Opentelemetry_Proto_Metrics_V1_Exemplar()
230230
protoExemplar.timeUnixNano = $0.epochNanos
231+
232+
if let doubleExemplar = $0 as? DoubleExemplarData {
233+
protoExemplar.value = .asDouble(doubleExemplar.value)
234+
}
235+
236+
if let longExemplar = $0 as? LongExemplarData {
237+
protoExemplar.value = .asInt(Int64(longExemplar.value))
238+
}
231239

232240
$0.filteredAttributes.forEach {
233241
protoExemplar.filteredAttributes.append(CommonAdapter.toProtoAttribute(key: $0.key, attributeValue: $0.value))

0 commit comments

Comments
 (0)