Search in sources :

Example 1 with Summary

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);
}
Also used : Resource(io.opentelemetry.proto.resource.v1.Resource) InstrumentationLibraryMetrics(io.opentelemetry.proto.metrics.v1.InstrumentationLibraryMetrics) ResourceMetrics(io.opentelemetry.proto.metrics.v1.ResourceMetrics) Summary(io.opentelemetry.proto.metrics.v1.Summary) Event(com.amazon.dataprepper.model.event.Event) Metric(io.opentelemetry.proto.metrics.v1.Metric) Record(com.amazon.dataprepper.model.record.Record) List(java.util.List) SummaryDataPoint(io.opentelemetry.proto.metrics.v1.SummaryDataPoint) Map(java.util.Map) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ExportMetricsServiceRequest(io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest) Test(org.junit.Test)

Aggregations

Event (com.amazon.dataprepper.model.event.Event)1 Record (com.amazon.dataprepper.model.record.Record)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ExportMetricsServiceRequest (io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest)1 InstrumentationLibraryMetrics (io.opentelemetry.proto.metrics.v1.InstrumentationLibraryMetrics)1 Metric (io.opentelemetry.proto.metrics.v1.Metric)1 ResourceMetrics (io.opentelemetry.proto.metrics.v1.ResourceMetrics)1 Summary (io.opentelemetry.proto.metrics.v1.Summary)1 SummaryDataPoint (io.opentelemetry.proto.metrics.v1.SummaryDataPoint)1 Resource (io.opentelemetry.proto.resource.v1.Resource)1 List (java.util.List)1 Map (java.util.Map)1 Test (org.junit.Test)1