Search in sources :

Example 56 with Record

use of com.amazon.dataprepper.model.record.Record in project data-prepper by opensearch-project.

the class PeerForwarderTest method testSingleRemoteIpForwardedRequestOnlyWithExportTraceServiceRequestRecordData.

// TODO: remove in 2.0
@Test
public void testSingleRemoteIpForwardedRequestOnlyWithExportTraceServiceRequestRecordData() throws Exception {
    final List<String> testIps = generateTestIps(2);
    final Channel channel = mock(Channel.class);
    final String peerIp = testIps.get(1);
    final String fullPeerIp = String.format("%s:21890", peerIp);
    when(channel.authority()).thenReturn(fullPeerIp);
    when(peerClientPool.getClient(peerIp)).thenReturn(client);
    when(client.getChannel()).thenReturn(channel);
    final Map<String, List<ExportTraceServiceRequest>> requestsByIp = testIps.stream().collect(Collectors.toMap(ip -> ip, ip -> new ArrayList<>()));
    doAnswer(invocation -> {
        final ExportTraceServiceRequest exportTraceServiceRequest = invocation.getArgument(0);
        requestsByIp.get(peerIp).add(exportTraceServiceRequest);
        return null;
    }).when(client).export(any(ExportTraceServiceRequest.class));
    MetricsTestUtil.initMetrics();
    final PeerForwarder testPeerForwarder = generatePeerForwarder(testIps, 3);
    final List<Record<Object>> exportedRecords = testPeerForwarder.doExecute(Collections.singletonList(new Record<>(REQUEST_4)));
    final List<ResourceSpans> expectedForwardedResourceSpans = Collections.singletonList(generateResourceSpans(OTLP_SPAN_4, OTLP_SPAN_5, OTLP_SPAN_6));
    assertEquals(1, requestsByIp.get(peerIp).size());
    final ExportTraceServiceRequest forwardedRequest = requestsByIp.get(peerIp).get(0);
    final List<ResourceSpans> forwardedResourceSpans = forwardedRequest.getResourceSpansList();
    assertTrue(forwardedResourceSpans.containsAll(expectedForwardedResourceSpans));
    assertTrue(expectedForwardedResourceSpans.containsAll(forwardedResourceSpans));
    assertEquals(0, exportedRecords.size());
    // Verify metrics
    final List<Measurement> forwardRequestErrorMeasurements = MetricsTestUtil.getMeasurementList(new StringJoiner(MetricNames.DELIMITER).add(TEST_PIPELINE_NAME).add("peer_forwarder").add(PeerForwarder.ERRORS).toString());
    assertEquals(1, forwardRequestErrorMeasurements.size());
    assertEquals(0.0, forwardRequestErrorMeasurements.get(0).getValue(), 0);
    final List<Measurement> forwardRequestSuccessMeasurements = MetricsTestUtil.getMeasurementList(new StringJoiner(MetricNames.DELIMITER).add(TEST_PIPELINE_NAME).add("peer_forwarder").add(PeerForwarder.REQUESTS).toString());
    assertEquals(1, forwardRequestSuccessMeasurements.size());
    assertEquals(1.0, forwardRequestSuccessMeasurements.get(0).getValue(), 0);
    final List<Measurement> forwardRequestLatencyMeasurements = MetricsTestUtil.getMeasurementList(new StringJoiner(MetricNames.DELIMITER).add(TEST_PIPELINE_NAME).add("peer_forwarder").add(PeerForwarder.LATENCY).toString());
    assertEquals(3, forwardRequestLatencyMeasurements.size());
    // COUNT
    assertEquals(1.0, forwardRequestLatencyMeasurements.get(0).getValue(), 0);
    // TOTAL_TIME
    assertTrue(forwardRequestLatencyMeasurements.get(1).getValue() > 0.0);
    // MAX
    assertTrue(forwardRequestLatencyMeasurements.get(2).getValue() > 0.0);
}
Also used : Arrays(java.util.Arrays) ArgumentMatchers(org.mockito.ArgumentMatchers) MetricsTestUtil(com.amazon.dataprepper.metrics.MetricsTestUtil) Channel(io.grpc.Channel) Mockito.verifyNoInteractions(org.mockito.Mockito.verifyNoInteractions) ResourceSpans(io.opentelemetry.proto.trace.v1.ResourceSpans) After(org.junit.After) Map(java.util.Map) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Resource(io.opentelemetry.proto.resource.v1.Resource) Record(com.amazon.dataprepper.model.record.Record) DefaultTraceGroupFields(com.amazon.dataprepper.model.trace.DefaultTraceGroupFields) Span(com.amazon.dataprepper.model.trace.Span) DecoderException(org.apache.commons.codec.DecoderException) UUID(java.util.UUID) TraceServiceGrpc(io.opentelemetry.proto.collector.trace.v1.TraceServiceGrpc) Collectors(java.util.stream.Collectors) ByteString(com.google.protobuf.ByteString) MockedStatic(org.mockito.MockedStatic) List(java.util.List) JacksonSpan(com.amazon.dataprepper.model.trace.JacksonSpan) ExportTraceServiceRequest(io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest) OTelProtoCodec(com.amazon.dataprepper.plugins.otel.codec.OTelProtoCodec) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Mock(org.mockito.Mock) Mockito.mockStatic(org.mockito.Mockito.mockStatic) RunWith(org.junit.runner.RunWith) InstrumentationLibrarySpans(io.opentelemetry.proto.trace.v1.InstrumentationLibrarySpans) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) MetricNames(com.amazon.dataprepper.metrics.MetricNames) Hex(org.apache.commons.codec.binary.Hex) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) ExecutorService(java.util.concurrent.ExecutorService) Before(org.junit.Before) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) OTelProtoCodec.convertUnixNanosToISO8601(com.amazon.dataprepper.plugins.otel.codec.OTelProtoCodec.convertUnixNanosToISO8601) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) Mockito.when(org.mockito.Mockito.when) Field(java.lang.reflect.Field) Measurement(io.micrometer.core.instrument.Measurement) Mockito.verify(org.mockito.Mockito.verify) ExecutionException(java.util.concurrent.ExecutionException) InstrumentationLibrary(io.opentelemetry.proto.common.v1.InstrumentationLibrary) StringJoiner(java.util.StringJoiner) Assert(org.junit.Assert) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) ExportTraceServiceRequest(io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest) Measurement(io.micrometer.core.instrument.Measurement) Channel(io.grpc.Channel) ArrayList(java.util.ArrayList) ByteString(com.google.protobuf.ByteString) ResourceSpans(io.opentelemetry.proto.trace.v1.ResourceSpans) List(java.util.List) ArrayList(java.util.ArrayList) Record(com.amazon.dataprepper.model.record.Record) StringJoiner(java.util.StringJoiner) Test(org.junit.Test)

Example 57 with Record

use of com.amazon.dataprepper.model.record.Record in project data-prepper by opensearch-project.

the class PeerForwarderTest method testSingleRemoteIpForwardRequestClientErrorWithEventRecordData.

@Test
public void testSingleRemoteIpForwardRequestClientErrorWithEventRecordData() {
    final List<String> testIps = generateTestIps(2);
    final Channel channel = mock(Channel.class);
    final String peerIp = testIps.get(1);
    final String fullPeerIp = String.format("%s:21890", peerIp);
    when(channel.authority()).thenReturn(fullPeerIp);
    when(peerClientPool.getClient(peerIp)).thenReturn(client);
    when(client.export(any(ExportTraceServiceRequest.class))).thenThrow(new RuntimeException());
    when(client.getChannel()).thenReturn(channel);
    MetricsTestUtil.initMetrics();
    final PeerForwarder testPeerForwarder = generatePeerForwarder(testIps, 3);
    final List<Record<Object>> exportedRecords = testPeerForwarder.doExecute(TEST_SPANS_B.stream().map(span -> new Record<Object>(span)).collect(Collectors.toList()));
    Assert.assertEquals(3, exportedRecords.size());
    final List<Span> exportedSpans = exportedRecords.stream().map(record -> (Span) record.getData()).collect(Collectors.toList());
    assertTrue(exportedSpans.containsAll(TEST_SPANS_B));
    assertTrue(TEST_SPANS_B.containsAll(exportedSpans));
    // Verify metrics
    final List<Measurement> forwardRequestErrorMeasurements = MetricsTestUtil.getMeasurementList(new StringJoiner(MetricNames.DELIMITER).add(TEST_PIPELINE_NAME).add("peer_forwarder").add(PeerForwarder.ERRORS).toString());
    Assert.assertEquals(1, forwardRequestErrorMeasurements.size());
    Assert.assertEquals(1.0, forwardRequestErrorMeasurements.get(0).getValue(), 0);
    final List<Measurement> forwardRequestSuccessMeasurements = MetricsTestUtil.getMeasurementList(new StringJoiner(MetricNames.DELIMITER).add(TEST_PIPELINE_NAME).add("peer_forwarder").add(PeerForwarder.REQUESTS).toString());
    Assert.assertEquals(1, forwardRequestSuccessMeasurements.size());
    Assert.assertEquals(1.0, forwardRequestSuccessMeasurements.get(0).getValue(), 0);
    final List<Measurement> forwardRequestLatencyMeasurements = MetricsTestUtil.getMeasurementList(new StringJoiner(MetricNames.DELIMITER).add(TEST_PIPELINE_NAME).add("peer_forwarder").add(PeerForwarder.LATENCY).toString());
    Assert.assertEquals(3, forwardRequestLatencyMeasurements.size());
    // COUNT
    Assert.assertEquals(1.0, forwardRequestLatencyMeasurements.get(0).getValue(), 0);
    // TOTAL_TIME
    assertTrue(forwardRequestLatencyMeasurements.get(1).getValue() > 0.0);
    // MAX
    assertTrue(forwardRequestLatencyMeasurements.get(2).getValue() > 0.0);
}
Also used : ExportTraceServiceRequest(io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest) Arrays(java.util.Arrays) ArgumentMatchers(org.mockito.ArgumentMatchers) MetricsTestUtil(com.amazon.dataprepper.metrics.MetricsTestUtil) Channel(io.grpc.Channel) Mockito.verifyNoInteractions(org.mockito.Mockito.verifyNoInteractions) ResourceSpans(io.opentelemetry.proto.trace.v1.ResourceSpans) After(org.junit.After) Map(java.util.Map) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Resource(io.opentelemetry.proto.resource.v1.Resource) Record(com.amazon.dataprepper.model.record.Record) DefaultTraceGroupFields(com.amazon.dataprepper.model.trace.DefaultTraceGroupFields) Span(com.amazon.dataprepper.model.trace.Span) DecoderException(org.apache.commons.codec.DecoderException) UUID(java.util.UUID) TraceServiceGrpc(io.opentelemetry.proto.collector.trace.v1.TraceServiceGrpc) Collectors(java.util.stream.Collectors) ByteString(com.google.protobuf.ByteString) MockedStatic(org.mockito.MockedStatic) List(java.util.List) JacksonSpan(com.amazon.dataprepper.model.trace.JacksonSpan) ExportTraceServiceRequest(io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest) OTelProtoCodec(com.amazon.dataprepper.plugins.otel.codec.OTelProtoCodec) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Mock(org.mockito.Mock) Mockito.mockStatic(org.mockito.Mockito.mockStatic) RunWith(org.junit.runner.RunWith) InstrumentationLibrarySpans(io.opentelemetry.proto.trace.v1.InstrumentationLibrarySpans) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) MetricNames(com.amazon.dataprepper.metrics.MetricNames) Hex(org.apache.commons.codec.binary.Hex) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) ExecutorService(java.util.concurrent.ExecutorService) Before(org.junit.Before) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) OTelProtoCodec.convertUnixNanosToISO8601(com.amazon.dataprepper.plugins.otel.codec.OTelProtoCodec.convertUnixNanosToISO8601) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) Mockito.when(org.mockito.Mockito.when) Field(java.lang.reflect.Field) Measurement(io.micrometer.core.instrument.Measurement) Mockito.verify(org.mockito.Mockito.verify) ExecutionException(java.util.concurrent.ExecutionException) InstrumentationLibrary(io.opentelemetry.proto.common.v1.InstrumentationLibrary) StringJoiner(java.util.StringJoiner) Assert(org.junit.Assert) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) Measurement(io.micrometer.core.instrument.Measurement) Channel(io.grpc.Channel) ByteString(com.google.protobuf.ByteString) Span(com.amazon.dataprepper.model.trace.Span) JacksonSpan(com.amazon.dataprepper.model.trace.JacksonSpan) Record(com.amazon.dataprepper.model.record.Record) StringJoiner(java.util.StringJoiner) Test(org.junit.Test)

Example 58 with Record

use of com.amazon.dataprepper.model.record.Record in project data-prepper by opensearch-project.

the class PeerForwarderTest method testSingleRemoteIpBothLocalAndForwardedRequestWithExportTraceServiceRequestRecordData.

// TODO: remove in 2.0
@Test
public void testSingleRemoteIpBothLocalAndForwardedRequestWithExportTraceServiceRequestRecordData() {
    final List<String> testIps = generateTestIps(2);
    final Channel channel = mock(Channel.class);
    final String peerIp = testIps.get(1);
    when(channel.authority()).thenReturn(String.format("%s:21890", peerIp));
    when(peerClientPool.getClient(peerIp)).thenReturn(client);
    when(client.getChannel()).thenReturn(channel);
    final Map<String, List<ExportTraceServiceRequest>> requestsByIp = testIps.stream().collect(Collectors.toMap(ip -> ip, ip -> new ArrayList<>()));
    doAnswer(invocation -> {
        final ExportTraceServiceRequest exportTraceServiceRequest = invocation.getArgument(0);
        requestsByIp.get(peerIp).add(exportTraceServiceRequest);
        return null;
    }).when(client).export(any(ExportTraceServiceRequest.class));
    MetricsTestUtil.initMetrics();
    final PeerForwarder testPeerForwarder = generatePeerForwarder(testIps, 3);
    final List<Record<Object>> exportedRecords = testPeerForwarder.doExecute(Arrays.asList(new Record<>(REQUEST_1), new Record<>(REQUEST_2)));
    final List<ResourceSpans> expectedLocalResourceSpans = Arrays.asList(generateResourceSpans(OTLP_SPAN_1, OTLP_SPAN_2), generateResourceSpans(OTLP_SPAN_3));
    final List<ResourceSpans> expectedForwardedResourceSpans = Arrays.asList(generateResourceSpans(OTLP_SPAN_5, OTLP_SPAN_6), generateResourceSpans(OTLP_SPAN_4));
    assertEquals(1, exportedRecords.size());
    final ExportTraceServiceRequest localRequest = (ExportTraceServiceRequest) exportedRecords.get(0).getData();
    final List<ResourceSpans> localResourceSpans = localRequest.getResourceSpansList();
    assertTrue(localResourceSpans.containsAll(expectedLocalResourceSpans));
    assertTrue(expectedLocalResourceSpans.containsAll(localResourceSpans));
    assertEquals(1, requestsByIp.get(peerIp).size());
    final ExportTraceServiceRequest forwardedRequest = requestsByIp.get(peerIp).get(0);
    final List<ResourceSpans> forwardedResourceSpans = forwardedRequest.getResourceSpansList();
    assertTrue(forwardedResourceSpans.containsAll(expectedForwardedResourceSpans));
    assertTrue(expectedForwardedResourceSpans.containsAll(forwardedResourceSpans));
}
Also used : Arrays(java.util.Arrays) ArgumentMatchers(org.mockito.ArgumentMatchers) MetricsTestUtil(com.amazon.dataprepper.metrics.MetricsTestUtil) Channel(io.grpc.Channel) Mockito.verifyNoInteractions(org.mockito.Mockito.verifyNoInteractions) ResourceSpans(io.opentelemetry.proto.trace.v1.ResourceSpans) After(org.junit.After) Map(java.util.Map) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Resource(io.opentelemetry.proto.resource.v1.Resource) Record(com.amazon.dataprepper.model.record.Record) DefaultTraceGroupFields(com.amazon.dataprepper.model.trace.DefaultTraceGroupFields) Span(com.amazon.dataprepper.model.trace.Span) DecoderException(org.apache.commons.codec.DecoderException) UUID(java.util.UUID) TraceServiceGrpc(io.opentelemetry.proto.collector.trace.v1.TraceServiceGrpc) Collectors(java.util.stream.Collectors) ByteString(com.google.protobuf.ByteString) MockedStatic(org.mockito.MockedStatic) List(java.util.List) JacksonSpan(com.amazon.dataprepper.model.trace.JacksonSpan) ExportTraceServiceRequest(io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest) OTelProtoCodec(com.amazon.dataprepper.plugins.otel.codec.OTelProtoCodec) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Mock(org.mockito.Mock) Mockito.mockStatic(org.mockito.Mockito.mockStatic) RunWith(org.junit.runner.RunWith) InstrumentationLibrarySpans(io.opentelemetry.proto.trace.v1.InstrumentationLibrarySpans) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) MetricNames(com.amazon.dataprepper.metrics.MetricNames) Hex(org.apache.commons.codec.binary.Hex) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) ExecutorService(java.util.concurrent.ExecutorService) Before(org.junit.Before) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) OTelProtoCodec.convertUnixNanosToISO8601(com.amazon.dataprepper.plugins.otel.codec.OTelProtoCodec.convertUnixNanosToISO8601) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) Mockito.when(org.mockito.Mockito.when) Field(java.lang.reflect.Field) Measurement(io.micrometer.core.instrument.Measurement) Mockito.verify(org.mockito.Mockito.verify) ExecutionException(java.util.concurrent.ExecutionException) InstrumentationLibrary(io.opentelemetry.proto.common.v1.InstrumentationLibrary) StringJoiner(java.util.StringJoiner) Assert(org.junit.Assert) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) ExportTraceServiceRequest(io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest) Channel(io.grpc.Channel) ArrayList(java.util.ArrayList) ByteString(com.google.protobuf.ByteString) ResourceSpans(io.opentelemetry.proto.trace.v1.ResourceSpans) List(java.util.List) ArrayList(java.util.ArrayList) Record(com.amazon.dataprepper.model.record.Record) Test(org.junit.Test)

Example 59 with Record

use of com.amazon.dataprepper.model.record.Record in project data-prepper by opensearch-project.

the class PeerForwarderTest method testSingleRemoteIpForwardRequestClientErrorWithExportTraceServiceRequestRecordData.

// TODO: remove in 2.0
@Test
public void testSingleRemoteIpForwardRequestClientErrorWithExportTraceServiceRequestRecordData() {
    final List<String> testIps = generateTestIps(2);
    final Channel channel = mock(Channel.class);
    final String peerIp = testIps.get(1);
    final String fullPeerIp = String.format("%s:21890", peerIp);
    when(channel.authority()).thenReturn(fullPeerIp);
    when(peerClientPool.getClient(peerIp)).thenReturn(client);
    when(client.export(any(ExportTraceServiceRequest.class))).thenThrow(new RuntimeException());
    when(client.getChannel()).thenReturn(channel);
    MetricsTestUtil.initMetrics();
    final PeerForwarder testPeerForwarder = generatePeerForwarder(testIps, 3);
    final List<Record<Object>> exportedRecords = testPeerForwarder.doExecute(Collections.singletonList(new Record<>(REQUEST_4)));
    final List<ResourceSpans> expectedLocalResourceSpans = Collections.singletonList(generateResourceSpans(OTLP_SPAN_4, OTLP_SPAN_5, OTLP_SPAN_6));
    assertEquals(1, exportedRecords.size());
    final ExportTraceServiceRequest exportedRequest = (ExportTraceServiceRequest) exportedRecords.get(0).getData();
    final List<ResourceSpans> forwardedResourceSpans = exportedRequest.getResourceSpansList();
    assertTrue(forwardedResourceSpans.containsAll(expectedLocalResourceSpans));
    assertTrue(expectedLocalResourceSpans.containsAll(forwardedResourceSpans));
    // Verify metrics
    final List<Measurement> forwardRequestErrorMeasurements = MetricsTestUtil.getMeasurementList(new StringJoiner(MetricNames.DELIMITER).add(TEST_PIPELINE_NAME).add("peer_forwarder").add(PeerForwarder.ERRORS).toString());
    assertEquals(1, forwardRequestErrorMeasurements.size());
    assertEquals(1.0, forwardRequestErrorMeasurements.get(0).getValue(), 0);
    final List<Measurement> forwardRequestSuccessMeasurements = MetricsTestUtil.getMeasurementList(new StringJoiner(MetricNames.DELIMITER).add(TEST_PIPELINE_NAME).add("peer_forwarder").add(PeerForwarder.REQUESTS).toString());
    assertEquals(1, forwardRequestSuccessMeasurements.size());
    assertEquals(1.0, forwardRequestSuccessMeasurements.get(0).getValue(), 0);
    final List<Measurement> forwardRequestLatencyMeasurements = MetricsTestUtil.getMeasurementList(new StringJoiner(MetricNames.DELIMITER).add(TEST_PIPELINE_NAME).add("peer_forwarder").add(PeerForwarder.LATENCY).toString());
    assertEquals(3, forwardRequestLatencyMeasurements.size());
    // COUNT
    assertEquals(1.0, forwardRequestLatencyMeasurements.get(0).getValue(), 0);
    // TOTAL_TIME
    assertTrue(forwardRequestLatencyMeasurements.get(1).getValue() > 0.0);
    // MAX
    assertTrue(forwardRequestLatencyMeasurements.get(2).getValue() > 0.0);
}
Also used : ExportTraceServiceRequest(io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest) Measurement(io.micrometer.core.instrument.Measurement) Channel(io.grpc.Channel) ByteString(com.google.protobuf.ByteString) ResourceSpans(io.opentelemetry.proto.trace.v1.ResourceSpans) Record(com.amazon.dataprepper.model.record.Record) StringJoiner(java.util.StringJoiner) Test(org.junit.Test)

Example 60 with Record

use of com.amazon.dataprepper.model.record.Record in project data-prepper by opensearch-project.

the class PeerForwarderTest method testSingleRemoteIpLocalRequestOnlyWithExportTraceServiceRequestRecordData.

// TODO: remove in 2.0
@Test
public void testSingleRemoteIpLocalRequestOnlyWithExportTraceServiceRequestRecordData() throws Exception {
    final List<String> testIps = generateTestIps(2);
    final PeerForwarder testPeerForwarder = generatePeerForwarder(testIps, 3);
    final List<Record<Object>> exportedRecords = testPeerForwarder.doExecute(Collections.singletonList(new Record<>(REQUEST_3)));
    final List<ResourceSpans> expectedLocalResourceSpans = Collections.singletonList(generateResourceSpans(OTLP_SPAN_1, OTLP_SPAN_2, OTLP_SPAN_3));
    assertEquals(1, exportedRecords.size());
    final ExportTraceServiceRequest localRequest = (ExportTraceServiceRequest) exportedRecords.get(0).getData();
    final List<ResourceSpans> localResourceSpans = localRequest.getResourceSpansList();
    assertTrue(localResourceSpans.containsAll(expectedLocalResourceSpans));
    assertTrue(expectedLocalResourceSpans.containsAll(localResourceSpans));
}
Also used : ExportTraceServiceRequest(io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest) Record(com.amazon.dataprepper.model.record.Record) ByteString(com.google.protobuf.ByteString) ResourceSpans(io.opentelemetry.proto.trace.v1.ResourceSpans) Test(org.junit.Test)

Aggregations

Record (com.amazon.dataprepper.model.record.Record)103 Test (org.junit.Test)43 Measurement (io.micrometer.core.instrument.Measurement)35 StringJoiner (java.util.StringJoiner)35 PluginSetting (com.amazon.dataprepper.model.configuration.PluginSetting)33 ArrayList (java.util.ArrayList)31 Map (java.util.Map)30 Test (org.junit.jupiter.api.Test)30 HashMap (java.util.HashMap)29 List (java.util.List)28 Event (com.amazon.dataprepper.model.event.Event)23 ExportTraceServiceRequest (io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest)20 ResourceSpans (io.opentelemetry.proto.trace.v1.ResourceSpans)19 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)16 JacksonEvent (com.amazon.dataprepper.model.event.JacksonEvent)14 ByteString (com.google.protobuf.ByteString)13 ExecutorService (java.util.concurrent.ExecutorService)13 Resource (io.opentelemetry.proto.resource.v1.Resource)12 Channel (io.grpc.Channel)11 MetricNames (com.amazon.dataprepper.metrics.MetricNames)10