@@ -56,20 +56,27 @@ public class EndToEndOtelLogsSourceTest {
5656
5757 @ Test
5858 public void testOtelLogsSourcePipelineEndToEnd () throws InvalidProtocolBufferException {
59- ingestLogs ("/otel-logs-pipeline/logs" );
59+ ingestLogs ("/otel-logs-pipeline/logs" , createOtelLogsJsonRequest () );
6060
6161 searchForLogsAndAssert ();
6262 }
6363
6464 @ Test
6565 public void testOtelLogsSourceWithUnframedRequestsPipelineEndToEnd () throws InvalidProtocolBufferException {
66- ingestLogs ("/opentelemetry.proto.collector.logs.v1.LogsService/Export" );
66+ ingestLogs ("/opentelemetry.proto.collector.logs.v1.LogsService/Export" , createOtelLogsJsonRequest ());
67+
68+ searchForLogsAndAssert ();
69+ }
70+
71+ @ Test
72+ public void testOtelLogsSourcePipelineWithProtobufPayloadEndToEnd () throws InvalidProtocolBufferException {
73+ ingestLogs ("/otel-logs-pipeline/logs" , createOtelLogsProtobufRequest ());
6774
6875 searchForLogsAndAssert ();
6976 }
7077
7178
72- private HttpData createOtelLogsHttpRequest () throws InvalidProtocolBufferException {
79+ private HttpData createOtelLogsJsonRequest () throws InvalidProtocolBufferException {
7380 ExportLogsServiceRequest exportLogsServiceRequest = ExportLogsServiceRequest .newBuilder ().addResourceLogs (
7481 ResourceLogs .newBuilder ()
7582 .addScopeLogs (ScopeLogs .newBuilder ()
@@ -86,6 +93,23 @@ private HttpData createOtelLogsHttpRequest() throws InvalidProtocolBufferExcepti
8693 return HttpData .copyOf (JsonFormat .printer ().print (exportLogsServiceRequest ).getBytes ());
8794 }
8895
96+ private HttpData createOtelLogsProtobufRequest () throws InvalidProtocolBufferException {
97+ ExportLogsServiceRequest exportLogsServiceRequest = ExportLogsServiceRequest .newBuilder ().addResourceLogs (
98+ ResourceLogs .newBuilder ()
99+ .addScopeLogs (ScopeLogs .newBuilder ()
100+ .addLogRecords (LogRecord .newBuilder ()
101+ .setBody (AnyValue .newBuilder ().setStringValue (apacheLogFaker .generateRandomCommonApacheLog ()).build ())
102+ .setSeverityNumberValue (1 )
103+ .setTimeUnixNano (System .currentTimeMillis () * 1_000_000 )
104+ .setTraceId (ByteString .copyFromUtf8 ("trace-id" ))
105+ .setSpanId (ByteString .copyFromUtf8 ("span-id" )
106+ )).build ()
107+ )
108+ ).build ();
109+
110+ return HttpData .copyOf (exportLogsServiceRequest .toByteArray ());
111+ }
112+
89113 private void searchForLogsAndAssert () {
90114 await ().atMost (10 , TimeUnit .SECONDS ).untilAsserted (
91115 () -> {
@@ -109,7 +133,7 @@ private RestHighLevelClient createOpenSearchClient() {
109133 .createClient (null );
110134 }
111135
112- private void ingestLogs (String path ) throws InvalidProtocolBufferException {
136+ private void ingestLogs (String path , HttpData payload ) throws InvalidProtocolBufferException {
113137 RequestHeaders headers = RequestHeaders .builder ()
114138 .scheme (SessionProtocol .HTTP )
115139 .authority (String .format ("127.0.0.1:%d" , SOURCE_PORT ))
@@ -118,7 +142,7 @@ private void ingestLogs(String path) throws InvalidProtocolBufferException {
118142 .contentType (MediaType .JSON_UTF_8 )
119143 .build ();
120144
121- WebClient .of ().execute (headers , createOtelLogsHttpRequest () )
145+ WebClient .of ().execute (headers , payload )
122146 .aggregate ()
123147 .whenComplete ((i , ex ) -> assertThat (i .status (), is (HttpStatus .OK )))
124148 .join ();
0 commit comments