Search in sources :

Example 1 with ConnectionConfiguration

use of com.amazon.dataprepper.plugins.sink.opensearch.ConnectionConfiguration in project data-prepper by opensearch-project.

the class OTelTraceGroupProcessorConfigTests method testInitialize.

@Test
public void testInitialize() {
    try (MockedStatic<ConnectionConfiguration> connectionConfigurationMockedStatic = Mockito.mockStatic(ConnectionConfiguration.class)) {
        connectionConfigurationMockedStatic.when(() -> ConnectionConfiguration.readConnectionConfiguration(any(PluginSetting.class))).thenReturn(connectionConfigurationMock);
        PluginSetting testPluginSetting = new PluginSetting("otel_trace_group", new HashMap<>());
        OTelTraceGroupProcessorConfig otelTraceGroupProcessorConfig = OTelTraceGroupProcessorConfig.buildConfig(testPluginSetting);
        assertEquals(connectionConfigurationMock, otelTraceGroupProcessorConfig.getEsConnectionConfig());
    }
}
Also used : ConnectionConfiguration(com.amazon.dataprepper.plugins.sink.opensearch.ConnectionConfiguration) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.Test)

Example 2 with ConnectionConfiguration

use of com.amazon.dataprepper.plugins.sink.opensearch.ConnectionConfiguration in project data-prepper by opensearch-project.

the class ZipkinOpenSearchToOtel method main.

public static void main(final String[] args) throws IOException {
    if (args.length < 1) {
        System.err.println("Missing indexPattern as arg");
        System.exit(1);
    }
    final String indexPattern = args[0];
    final String field = args.length >= 2 ? args[1] : null;
    final String value = args.length >= 3 ? args[2] : null;
    final boolean isTest = !System.getProperty("test", "false").equalsIgnoreCase("false");
    OTelTraceSource oTelTraceSource = null;
    if (isTest) {
        System.out.println("Setting up testing OtelTraceSource");
        oTelTraceSource = setUpOtelTraceSource();
    }
    final ConnectionConfiguration connectionConfiguration = new ConnectionConfiguration.Builder(Collections.singletonList("https://localhost:9200")).withUsername("admin").withPassword("admin").build();
    final RestHighLevelClient restHighLevelClient = connectionConfiguration.createClient();
    final OpenSearchReader reader = new OpenSearchReader(indexPattern, field, value);
    final TraceServiceGrpc.TraceServiceBlockingStub client = createGRPCClient();
    System.out.println("Reading batch 0");
    List<Map<String, Object>> sources = reader.nextBatch(restHighLevelClient);
    System.out.println(String.format("Batch size: %d", sources.size()));
    System.out.println(String.format("Total number of hits: %d", reader.getTotal()));
    int i = 0;
    while (sources.size() > 0) {
        System.out.println(String.format("Processing batch %d as ExportTraceServiceRequest", i));
        try {
            final ExportTraceServiceRequest exportTraceServiceRequest = ZipkinOpenSearchToOtelPrepper.sourcesToRequest(sources);
            client.export(exportTraceServiceRequest);
        } catch (Exception e) {
            LOG.error(e.getMessage(), e);
        }
        System.out.println(String.format("Reading batch %d", i + 1));
        sources = reader.nextBatch(restHighLevelClient);
        i++;
    }
    System.out.println("Clearing reader scroll context ...");
    reader.clearScroll(restHighLevelClient);
    System.out.println("Closing REST client");
    restHighLevelClient.close();
    if (isTest) {
        closeOtelTraceSource(oTelTraceSource);
    }
}
Also used : ExportTraceServiceRequest(io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest) RestHighLevelClient(org.opensearch.client.RestHighLevelClient) IOException(java.io.IOException) ConnectionConfiguration(com.amazon.dataprepper.plugins.sink.opensearch.ConnectionConfiguration) HashMap(java.util.HashMap) Map(java.util.Map) TraceServiceGrpc(io.opentelemetry.proto.collector.trace.v1.TraceServiceGrpc) OTelTraceSource(com.amazon.dataprepper.plugins.source.oteltrace.OTelTraceSource)

Example 3 with ConnectionConfiguration

use of com.amazon.dataprepper.plugins.sink.opensearch.ConnectionConfiguration in project data-prepper by opensearch-project.

the class OTelTraceGroupPrepperConfigTests method testInitialize.

@Test
public void testInitialize() {
    try (MockedStatic<ConnectionConfiguration> connectionConfigurationMockedStatic = Mockito.mockStatic(ConnectionConfiguration.class)) {
        connectionConfigurationMockedStatic.when(() -> ConnectionConfiguration.readConnectionConfiguration(any(PluginSetting.class))).thenReturn(connectionConfigurationMock);
        PluginSetting testPluginSetting = new PluginSetting("otel_trace_group_prepper", new HashMap<>());
        OTelTraceGroupPrepperConfig otelTraceGroupPrepperConfig = OTelTraceGroupPrepperConfig.buildConfig(testPluginSetting);
        assertEquals(connectionConfigurationMock, otelTraceGroupPrepperConfig.getEsConnectionConfig());
    }
}
Also used : ConnectionConfiguration(com.amazon.dataprepper.plugins.sink.opensearch.ConnectionConfiguration) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.Test)

Aggregations

ConnectionConfiguration (com.amazon.dataprepper.plugins.sink.opensearch.ConnectionConfiguration)3 PluginSetting (com.amazon.dataprepper.model.configuration.PluginSetting)2 Test (org.junit.Test)2 OTelTraceSource (com.amazon.dataprepper.plugins.source.oteltrace.OTelTraceSource)1 ExportTraceServiceRequest (io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest)1 TraceServiceGrpc (io.opentelemetry.proto.collector.trace.v1.TraceServiceGrpc)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 RestHighLevelClient (org.opensearch.client.RestHighLevelClient)1