@@ -54,114 +54,121 @@ struct MetricsAdapter {
5454 guard let gaugeData = $0 as? SumData < Double > else {
5555 break
5656 }
57- var protoDataPoint = Opentelemetry_Proto_Metrics_V1_DoubleDataPoint ( )
57+ var protoDataPoint = Opentelemetry_Proto_Metrics_V1_NumberDataPoint ( )
58+
5859 protoDataPoint. timeUnixNano = gaugeData. timestamp. timeIntervalSince1970. toNanoseconds
5960 protoDataPoint. startTimeUnixNano = gaugeData. startTimestamp. timeIntervalSince1970. toNanoseconds
60- protoDataPoint. value = gaugeData. sum
61+ protoDataPoint. value = . asDouble ( gaugeData. sum)
6162 gaugeData. labels. forEach {
62- var kvp = Opentelemetry_Proto_Common_V1_StringKeyValue ( )
63+ var kvp = Opentelemetry_Proto_Common_V1_KeyValue ( )
6364 kvp. key = $0. key
64- kvp. value = $0. value
65- protoDataPoint. labels . append ( kvp)
65+ kvp. value. stringValue = $0. value
66+ protoDataPoint. attributes . append ( kvp)
6667 }
6768
68- protoMetric. doubleGauge . dataPoints. append ( protoDataPoint)
69+ protoMetric. gauge . dataPoints. append ( protoDataPoint)
6970 case . intGauge:
7071 guard let gaugeData = $0 as? SumData < Int > else {
7172 break
7273 }
7374
74- var protoDataPoint = Opentelemetry_Proto_Metrics_V1_IntDataPoint ( )
75+ var protoDataPoint = Opentelemetry_Proto_Metrics_V1_NumberDataPoint ( )
7576
76- protoDataPoint. value = Int64 ( gaugeData. sum)
77+ protoDataPoint. value = . asInt ( Int64 ( exactly : gaugeData. sum) ! )
7778 protoDataPoint. timeUnixNano = gaugeData. timestamp. timeIntervalSince1970. toNanoseconds
7879 protoDataPoint. startTimeUnixNano = gaugeData. startTimestamp. timeIntervalSince1970. toNanoseconds
7980 gaugeData. labels. forEach {
80- var kvp = Opentelemetry_Proto_Common_V1_StringKeyValue ( )
81+ var kvp = Opentelemetry_Proto_Common_V1_KeyValue ( )
8182 kvp. key = $0. key
82- kvp. value = $0. value
83- protoDataPoint. labels . append ( kvp)
83+ kvp. value. stringValue = $0. value
84+ protoDataPoint. attributes . append ( kvp)
8485 }
8586
86- protoMetric. intGauge . dataPoints. append ( protoDataPoint)
87+ protoMetric. gauge . dataPoints. append ( protoDataPoint)
8788 case . doubleSum:
8889 guard let sumData = $0 as? SumData < Double > else {
8990 break
9091 }
9192
92- var protoDataPoint = Opentelemetry_Proto_Metrics_V1_DoubleDataPoint ( )
93- protoDataPoint. value = sumData. sum
93+ var protoDataPoint = Opentelemetry_Proto_Metrics_V1_NumberDataPoint ( )
94+
95+ protoDataPoint. value = . asDouble( sumData. sum)
9496 protoDataPoint. timeUnixNano = sumData. timestamp. timeIntervalSince1970. toNanoseconds
9597 protoDataPoint. startTimeUnixNano = sumData. startTimestamp. timeIntervalSince1970. toNanoseconds
9698 sumData. labels. forEach {
97- var kvp = Opentelemetry_Proto_Common_V1_StringKeyValue ( )
99+ var kvp = Opentelemetry_Proto_Common_V1_KeyValue ( )
98100 kvp. key = $0. key
99- kvp. value = $0. value
100- protoDataPoint. labels . append ( kvp)
101+ kvp. value. stringValue = $0. value
102+ protoDataPoint. attributes . append ( kvp)
101103 }
102104
103- protoMetric. doubleSum . aggregationTemporality = . cumulative
104- protoMetric. doubleSum . dataPoints. append ( protoDataPoint)
105+ protoMetric. sum . aggregationTemporality = . cumulative
106+ protoMetric. sum . dataPoints. append ( protoDataPoint)
105107 case . doubleSummary:
106108
107109 guard let summaryData = $0 as? SummaryData < Double > else {
108110 break
109111 }
110- var protoDataPoint = Opentelemetry_Proto_Metrics_V1_DoubleSummaryDataPoint ( )
112+ var protoDataPoint = Opentelemetry_Proto_Metrics_V1_SummaryDataPoint ( )
113+
111114 protoDataPoint. sum = summaryData. sum
112115 protoDataPoint. count = UInt64 ( summaryData. count)
113116
114117 protoDataPoint. startTimeUnixNano = summaryData. startTimestamp. timeIntervalSince1970. toNanoseconds
115118 protoDataPoint. timeUnixNano = summaryData. timestamp. timeIntervalSince1970. toNanoseconds
116119
117120 summaryData. labels. forEach {
118- var kvp = Opentelemetry_Proto_Common_V1_StringKeyValue ( )
121+ var kvp = Opentelemetry_Proto_Common_V1_KeyValue ( )
119122 kvp. key = $0. key
120- kvp. value = $0. value
121- protoDataPoint. labels . append ( kvp)
123+ kvp. value. stringValue = $0. value
124+ protoDataPoint. attributes . append ( kvp)
122125 }
123126
124- protoMetric. doubleSummary . dataPoints. append ( protoDataPoint)
127+ protoMetric. summary . dataPoints. append ( protoDataPoint)
125128 case . intSum:
126129 guard let sumData = $0 as? SumData < Int > else {
127130 break
128131 }
129- var protoDataPoint = Opentelemetry_Proto_Metrics_V1_IntDataPoint ( )
130- protoDataPoint. value = Int64 ( sumData. sum)
132+ var protoDataPoint = Opentelemetry_Proto_Metrics_V1_NumberDataPoint ( )
133+
134+ protoDataPoint. value = . asInt( Int64 ( sumData. sum) )
131135 protoDataPoint. timeUnixNano = sumData. timestamp. timeIntervalSince1970. toNanoseconds
132136 protoDataPoint. startTimeUnixNano = sumData. startTimestamp. timeIntervalSince1970. toNanoseconds
133137 sumData. labels. forEach {
134- var kvp = Opentelemetry_Proto_Common_V1_StringKeyValue ( )
138+ var kvp = Opentelemetry_Proto_Common_V1_KeyValue ( )
139+
135140 kvp. key = $0. key
136- kvp. value = $0. value
137- protoDataPoint. labels . append ( kvp)
141+ kvp. value. stringValue = $0. value
142+ protoDataPoint. attributes . append ( kvp)
138143 }
139144
140- protoMetric. intSum . aggregationTemporality = . cumulative
141- protoMetric. intSum . dataPoints. append ( protoDataPoint)
145+ protoMetric. sum . aggregationTemporality = . cumulative
146+ protoMetric. sum . dataPoints. append ( protoDataPoint)
142147 case . intSummary:
143148 guard let summaryData = $0 as? SummaryData < Int > else {
144149 break
145150 }
146- var protoDataPoint = Opentelemetry_Proto_Metrics_V1_DoubleSummaryDataPoint ( )
151+ var protoDataPoint = Opentelemetry_Proto_Metrics_V1_SummaryDataPoint ( )
152+
147153 protoDataPoint. sum = Double ( summaryData. sum)
148154 protoDataPoint. count = UInt64 ( summaryData. count)
149155 protoDataPoint. startTimeUnixNano = summaryData. startTimestamp. timeIntervalSince1970. toNanoseconds
150156 protoDataPoint. timeUnixNano = summaryData. timestamp. timeIntervalSince1970. toNanoseconds
151157
152158 summaryData. labels. forEach {
153- var kvp = Opentelemetry_Proto_Common_V1_StringKeyValue ( )
159+ var kvp = Opentelemetry_Proto_Common_V1_KeyValue ( )
154160 kvp. key = $0. key
155- kvp. value = $0. value
156- protoDataPoint. labels . append ( kvp)
161+ kvp. value. stringValue = $0. value
162+ protoDataPoint. attributes . append ( kvp)
157163 }
158164
159- protoMetric. doubleSummary . dataPoints. append ( protoDataPoint)
165+ protoMetric. summary . dataPoints. append ( protoDataPoint)
160166 case . intHistogram:
161167 guard let histogramData = $0 as? HistogramData < Int > else {
162168 break
163169 }
164- var protoDataPoint = Opentelemetry_Proto_Metrics_V1_DoubleHistogramDataPoint ( )
170+ var protoDataPoint = Opentelemetry_Proto_Metrics_V1_HistogramDataPoint ( )
171+
165172 protoDataPoint. sum = Double ( histogramData. sum)
166173 protoDataPoint. count = UInt64 ( histogramData. count)
167174 protoDataPoint. startTimeUnixNano = histogramData. startTimestamp. timeIntervalSince1970. toNanoseconds
@@ -170,19 +177,19 @@ struct MetricsAdapter {
170177 protoDataPoint. bucketCounts = histogramData. buckets. counts. map { UInt64 ( $0) }
171178
172179 histogramData. labels. forEach {
173- var kvp = Opentelemetry_Proto_Common_V1_StringKeyValue ( )
180+ var kvp = Opentelemetry_Proto_Common_V1_KeyValue ( )
174181 kvp. key = $0. key
175- kvp. value = $0. value
176- protoDataPoint. labels . append ( kvp)
182+ kvp. value. stringValue = $0. value
183+ protoDataPoint. attributes . append ( kvp)
177184 }
178185
179- protoMetric. doubleHistogram . aggregationTemporality = . cumulative
180- protoMetric. doubleHistogram . dataPoints. append ( protoDataPoint)
186+ protoMetric. histogram . aggregationTemporality = . cumulative
187+ protoMetric. histogram . dataPoints. append ( protoDataPoint)
181188 case . doubleHistogram:
182189 guard let histogramData = $0 as? HistogramData < Double > else {
183190 break
184191 }
185- var protoDataPoint = Opentelemetry_Proto_Metrics_V1_DoubleHistogramDataPoint ( )
192+ var protoDataPoint = Opentelemetry_Proto_Metrics_V1_HistogramDataPoint ( )
186193 protoDataPoint. sum = Double ( histogramData. sum)
187194 protoDataPoint. count = UInt64 ( histogramData. count)
188195 protoDataPoint. startTimeUnixNano = histogramData. startTimestamp. timeIntervalSince1970. toNanoseconds
@@ -191,14 +198,14 @@ struct MetricsAdapter {
191198 protoDataPoint. bucketCounts = histogramData. buckets. counts. map { UInt64 ( $0) }
192199
193200 histogramData. labels. forEach {
194- var kvp = Opentelemetry_Proto_Common_V1_StringKeyValue ( )
201+ var kvp = Opentelemetry_Proto_Common_V1_KeyValue ( )
195202 kvp. key = $0. key
196- kvp. value = $0. value
197- protoDataPoint. labels . append ( kvp)
203+ kvp. value. stringValue = $0. value
204+ protoDataPoint. attributes . append ( kvp)
198205 }
199206
200- protoMetric. doubleHistogram . aggregationTemporality = . cumulative
201- protoMetric. doubleHistogram . dataPoints. append ( protoDataPoint)
207+ protoMetric. histogram . aggregationTemporality = . cumulative
208+ protoMetric. histogram . dataPoints. append ( protoDataPoint)
202209 }
203210 }
204211 return protoMetric
0 commit comments