Skip to content

Commit e1e057f

Browse files
committed
corrected missing timestamps from MetricAdapter.swift
1 parent 7b0b66c commit e1e057f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Sources/Exporters/OpenTelemetryProtocol/metric/MetricsAdapter.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ struct MetricsAdapter {
5555
break
5656
}
5757
var protoDataPoint = Opentelemetry_Proto_Metrics_V1_DoubleDataPoint()
58-
58+
protoDataPoint.timeUnixNano = gaugeData.timestamp.timeIntervalSince1970.toNanoseconds
59+
protoDataPoint.startTimeUnixNano = gaugeData.startTimestamp.timeIntervalSince1970.toNanoseconds
5960
protoDataPoint.value = gaugeData.sum
6061
gaugeData.labels.forEach {
6162
var kvp = Opentelemetry_Proto_Common_V1_StringKeyValue()
@@ -73,6 +74,8 @@ struct MetricsAdapter {
7374
var protoDataPoint = Opentelemetry_Proto_Metrics_V1_IntDataPoint()
7475

7576
protoDataPoint.value = Int64(gaugeData.sum)
77+
protoDataPoint.timeUnixNano = gaugeData.timestamp.timeIntervalSince1970.toNanoseconds
78+
protoDataPoint.startTimeUnixNano = gaugeData.startTimestamp.timeIntervalSince1970.toNanoseconds
7679
gaugeData.labels.forEach {
7780
var kvp = Opentelemetry_Proto_Common_V1_StringKeyValue()
7881
kvp.key = $0.key
@@ -88,6 +91,8 @@ struct MetricsAdapter {
8891

8992
var protoDataPoint = Opentelemetry_Proto_Metrics_V1_DoubleDataPoint()
9093
protoDataPoint.value = sumData.sum
94+
protoDataPoint.timeUnixNano = sumData.timestamp.timeIntervalSince1970.toNanoseconds
95+
protoDataPoint.startTimeUnixNano = sumData.startTimestamp.timeIntervalSince1970.toNanoseconds
9196
sumData.labels.forEach {
9297
var kvp = Opentelemetry_Proto_Common_V1_StringKeyValue()
9398
kvp.key = $0.key
@@ -122,6 +127,8 @@ struct MetricsAdapter {
122127
}
123128
var protoDataPoint = Opentelemetry_Proto_Metrics_V1_IntDataPoint()
124129
protoDataPoint.value = Int64(sumData.sum)
130+
protoDataPoint.timeUnixNano = sumData.timestamp.timeIntervalSince1970.toNanoseconds
131+
protoDataPoint.startTimeUnixNano = sumData.startTimestamp.timeIntervalSince1970.toNanoseconds
125132
sumData.labels.forEach {
126133
var kvp = Opentelemetry_Proto_Common_V1_StringKeyValue()
127134
kvp.key = $0.key

0 commit comments

Comments
 (0)