use of com.amazon.dataprepper.plugins.prepper.oteltrace.model.RawSpanBuilder in project data-prepper by opensearch-project.
the class OTelTraceRawPrepper method doExecute.
/**
* execute the prepper logic which could potentially modify the incoming record. The level to which the record has
* been modified depends on the implementation
*
* @param records Input records that will be modified/processed
* @return Record modified output records
*/
@Override
public Collection<Record<String>> doExecute(Collection<Record<ExportTraceServiceRequest>> records) {
final List<RawSpan> rawSpans = new LinkedList<>();
for (Record<ExportTraceServiceRequest> ets : records) {
for (ResourceSpans rs : ets.getData().getResourceSpansList()) {
try {
final String serviceName = OTelProtoHelper.getServiceName(rs.getResource()).orElse(null);
final Map<String, Object> resourceAttributes = OTelProtoHelper.getResourceAttributes(rs.getResource());
for (InstrumentationLibrarySpans is : rs.getInstrumentationLibrarySpansList()) {
for (Span sp : is.getSpansList()) {
final RawSpan rawSpan = new RawSpanBuilder().setFromSpan(sp, is.getInstrumentationLibrary(), serviceName, resourceAttributes).build();
processRawSpan(rawSpan, rawSpans);
}
}
} catch (Exception ex) {
LOG.error("Unable to process invalid ResourceSpan {} :", rs, ex);
resourceSpanErrorsCounter.increment();
totalProcessingErrorsCounter.increment();
}
}
}
rawSpans.addAll(getTracesToFlushByGarbageCollection());
return convertRawSpansToJsonRecords(rawSpans);
}
Aggregations