use of com.amazon.dataprepper.plugins.source.oteltrace.OTelTraceSource in project data-prepper by opensearch-project.
the class ZipkinOpenSearchToOtel method setUpOtelTraceSource.
public static OTelTraceSource setUpOtelTraceSource() {
final HashMap<String, Object> integerHashMap = new HashMap<>();
integerHashMap.put("request_timeout", 1);
final OTelTraceSource SOURCE = new OTelTraceSource(null, null, null);
SOURCE.start(getBuffer());
return SOURCE;
}
use of com.amazon.dataprepper.plugins.source.oteltrace.OTelTraceSource 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);
}
}
Aggregations