()
| 1235 | } |
| 1236 | |
| 1237 | func generateOTLPWriteRequest() pmetricotlp.ExportRequest { |
| 1238 | d := pmetric.NewMetrics() |
| 1239 | |
| 1240 | // Generate One Counter, One Gauge, One Histogram, One Exponential-Histogram |
| 1241 | // with resource attributes: service.name="test-service", service.instance.id="test-instance", host.name="test-host" |
| 1242 | // with metric attibute: foo.bar="baz" |
| 1243 | |
| 1244 | timestamp := time.Now() |
| 1245 | |
| 1246 | resourceMetric := d.ResourceMetrics().AppendEmpty() |
| 1247 | resourceMetric.Resource().Attributes().PutStr("service.name", "test-service") |
| 1248 | resourceMetric.Resource().Attributes().PutStr("service.instance.id", "test-instance") |
| 1249 | resourceMetric.Resource().Attributes().PutStr("host.name", "test-host") |
| 1250 | |
| 1251 | scopeMetric := resourceMetric.ScopeMetrics().AppendEmpty() |
| 1252 | |
| 1253 | // Generate One Counter |
| 1254 | counterMetric := scopeMetric.Metrics().AppendEmpty() |
| 1255 | counterMetric.SetName("test-counter") |
| 1256 | counterMetric.SetDescription("test-counter-description") |
| 1257 | counterMetric.SetEmptySum() |
| 1258 | counterMetric.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) |
| 1259 | counterMetric.Sum().SetIsMonotonic(true) |
| 1260 | |
| 1261 | counterDataPoint := counterMetric.Sum().DataPoints().AppendEmpty() |
| 1262 | counterDataPoint.SetTimestamp(pcommon.NewTimestampFromTime(timestamp)) |
| 1263 | counterDataPoint.SetDoubleValue(10.0) |
| 1264 | counterDataPoint.Attributes().PutStr("foo.bar", "baz") |
| 1265 | |
| 1266 | counterExemplar := counterDataPoint.Exemplars().AppendEmpty() |
| 1267 | counterExemplar.SetTimestamp(pcommon.NewTimestampFromTime(timestamp)) |
| 1268 | counterExemplar.SetDoubleValue(10.0) |
| 1269 | counterExemplar.SetSpanID(pcommon.SpanID{0, 1, 2, 3, 4, 5, 6, 7}) |
| 1270 | counterExemplar.SetTraceID(pcommon.TraceID{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}) |
| 1271 | |
| 1272 | // Generate One Gauge |
| 1273 | gaugeMetric := scopeMetric.Metrics().AppendEmpty() |
| 1274 | gaugeMetric.SetName("test-gauge") |
| 1275 | gaugeMetric.SetDescription("test-gauge-description") |
| 1276 | gaugeMetric.SetEmptyGauge() |
| 1277 | |
| 1278 | gaugeDataPoint := gaugeMetric.Gauge().DataPoints().AppendEmpty() |
| 1279 | gaugeDataPoint.SetTimestamp(pcommon.NewTimestampFromTime(timestamp)) |
| 1280 | gaugeDataPoint.SetDoubleValue(10.0) |
| 1281 | gaugeDataPoint.Attributes().PutStr("foo.bar", "baz") |
| 1282 | |
| 1283 | // Generate One Histogram |
| 1284 | histogramMetric := scopeMetric.Metrics().AppendEmpty() |
| 1285 | histogramMetric.SetName("test-histogram") |
| 1286 | histogramMetric.SetDescription("test-histogram-description") |
| 1287 | histogramMetric.SetEmptyHistogram() |
| 1288 | histogramMetric.Histogram().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) |
| 1289 | |
| 1290 | histogramDataPoint := histogramMetric.Histogram().DataPoints().AppendEmpty() |
| 1291 | histogramDataPoint.SetTimestamp(pcommon.NewTimestampFromTime(timestamp)) |
| 1292 | histogramDataPoint.ExplicitBounds().FromRaw([]float64{0.0, 1.0, 2.0, 3.0, 4.0, 5.0}) |
| 1293 | histogramDataPoint.BucketCounts().FromRaw([]uint64{2, 2, 2, 2, 2, 2}) |
| 1294 | histogramDataPoint.SetCount(10) |
no test coverage detected