use of io.opentelemetry.proto.metrics.v1.Summary in project data-prepper by opensearch-project.
the class MetricsPluginSummaryTest method testSummaryProcessing.
@Test
public void testSummaryProcessing() throws JsonProcessingException {
SummaryDataPoint dataPoint = SummaryDataPoint.newBuilder().addQuantileValues(SummaryDataPoint.ValueAtQuantile.newBuilder().setQuantile(0.5).setValue(100).build()).addQuantileValues(SummaryDataPoint.ValueAtQuantile.newBuilder().setQuantile(0.7).setValue(250).build()).build();
Summary summary = Summary.newBuilder().addDataPoints(dataPoint).build();
Metric metric = Metric.newBuilder().setSummary(summary).setUnit("seconds").setName("name").setDescription("description").build();
InstrumentationLibraryMetrics instLib = InstrumentationLibraryMetrics.newBuilder().addMetrics(metric).build();
Resource resource = Resource.newBuilder().addAttributes(KeyValue.newBuilder().setKey("service.name").setValue(AnyValue.newBuilder().setStringValue("service").build())).build();
ResourceMetrics resourceMetrics = ResourceMetrics.newBuilder().setResource(resource).addInstrumentationLibraryMetrics(instLib).build();
ExportMetricsServiceRequest exportMetricRequest = ExportMetricsServiceRequest.newBuilder().addResourceMetrics(resourceMetrics).build();
Record record = new Record<>(exportMetricRequest);
List<Record<Event>> rec = (List<Record<Event>>) rawProcessor.doExecute(Arrays.asList(record));
Record<Event> firstRecord = rec.get(0);
ObjectMapper objectMapper = new ObjectMapper();
Map map = objectMapper.readValue(firstRecord.getData().toJsonString(), Map.class);
assertSumProcessing(map);
}
Aggregations