use of com.microsoft.azure.eventhubs.EventData in project zipkin-azure by openzipkin.
the class ZipkinEventProcessor method onEvents.
@Override
public void onEvents(PartitionContext context, Iterable<EventData> messages) throws ExecutionException, InterruptedException {
// don't issue a write until we checkpoint or exit this callback
List<Span> buffer = new ArrayList<>();
for (EventData data : messages) {
byte[] bytes = data.getBytes();
List<Span> nextSpans = SpanDecoder.DETECTING_DECODER.readSpans(bytes);
buffer.addAll(nextSpans);
if (maybeCheckpoint(context, data, nextSpans.size())) {
collector.accept(buffer, NOOP);
buffer.clear();
}
}
if (!buffer.isEmpty()) {
collector.accept(buffer, NOOP);
}
}
use of com.microsoft.azure.eventhubs.EventData in project zipkin-azure by openzipkin.
the class ZipkinEventProcessorTest method message.
static EventData message(String offset, long sequenceNumber, byte[] message) throws IllegalAccessException, NoSuchFieldException {
EventData data = new EventData(message);
LinkedHashMap<String, Object> sysProps = new LinkedHashMap<>();
sysProps.put("x-opt-offset", offset);
sysProps.put("x-opt-sequence-number", sequenceNumber);
addSystemProperties(data, sysProps);
return data;
}
use of com.microsoft.azure.eventhubs.EventData in project zipkin-azure by openzipkin.
the class ZipkinEventProcessorTest method checkpointsOnBatchSize.
@Test
public void checkpointsOnBatchSize() throws Exception {
EventData event1 = jsonMessageWithThreeSpans("a", 1);
EventData event2 = json2MessageWithThreeSpans("b", 2);
EventData event3 = thriftMessageWithThreeSpans("c", 3);
EventData event4 = json2MessageWithThreeSpans("d", 4);
// We don't expect a checkpoint, yet
processor.onEvents(context, asList(event1, event2, event3));
assertThat(checkpointEvents).isEmpty();
assertThat(logger.messages.poll()).isNull();
// We expect a checkpoint as we completed a batch
processor.onEvents(context, asList(event4));
assertThat(checkpointEvents).containsExactly(event4);
assertThat(logger.messages.poll()).isEqualTo("FINE: Partition 1 checkpointing at d,4");
}
use of com.microsoft.azure.eventhubs.EventData in project zipkin-azure by openzipkin.
the class ZipkinEventProcessorTest method onEvents_singleDatum.
void onEvents_singleDatum(Codec codec) throws ExecutionException, InterruptedException {
List<EventData> messages = asList(new EventData(codec.writeSpans(TestObjects.TRACE)));
processor.onEvents(context, messages);
assertThat(storage.spanStore().getRawTraces()).hasSize(1);
assertThat(storage.spanStore().getRawTraces().get(0)).isEqualTo(TestObjects.TRACE);
}
use of com.microsoft.azure.eventhubs.EventData in project zipkin-azure by openzipkin.
the class ZipkinEventProcessorTest method addSystemProperties.
static void addSystemProperties(EventData data, LinkedHashMap<String, Object> sysProps) throws IllegalAccessException, NoSuchFieldException {
Field field = EventData.class.getDeclaredField("systemProperties");
field.setAccessible(true);
field.set(data, new EventData.SystemProperties(sysProps));
}
Aggregations