Search in sources :

Example 1 with Nullable

use of org.apache.avro.reflect.Nullable in project hypertrace-ingester by hypertrace.

the class EnrichedSpanUtils method getApiEntrySpan.

/**
 * Helper method to find and entryApiEvent by iterate parent-child chain.
 */
@Nullable
public static Event getApiEntrySpan(Event event, Map<ByteBuffer, Event> idToEvent, Map<ByteBuffer, ByteBuffer> childToParent) {
    String apiBoundary = getApiBoundaryType(event);
    if (EnrichedSpanConstants.getValue(BoundaryTypeValue.BOUNDARY_TYPE_VALUE_ENTRY).equals(apiBoundary)) {
        // if current span itself is an api entry span, return same.
        return event;
    } else {
        // current span is not an api entry span, find an ancestor who is an api entry span
        Event parentEvent = idToEvent.get(childToParent.get(event.getEventId()));
        while (parentEvent != null) {
            apiBoundary = getApiBoundaryType(parentEvent);
            if (EnrichedSpanConstants.getValue(BoundaryTypeValue.BOUNDARY_TYPE_VALUE_ENTRY).equals(apiBoundary)) {
                return parentEvent;
            }
            parentEvent = idToEvent.get(childToParent.get(parentEvent.getEventId()));
        }
    }
    // oops, we didn't find the any api entry span in the parent-child chain
    return null;
}
Also used : Event(org.hypertrace.core.datamodel.Event) Nullable(org.apache.avro.reflect.Nullable)

Aggregations

Nullable (org.apache.avro.reflect.Nullable)1 Event (org.hypertrace.core.datamodel.Event)1