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());
}
}
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);
}
}
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());
}
}
Aggregations