public static SourceInfo getSourceInfo ( String tenantId , Span serverSpan , SpanCache spanCache ) { String clientSpanId = SpanUniqueIdGenerator . getClientId ( serverSpan . getId ( ) ) ; if ( spanCache != null && clientSpanId != null ) { Span clientSpan = spanCache . get ( tenantId , clientSpanId ) ; // Work up span hierarchy until find a server span, or top level span Span rootOrServerSpan = findRootOrServerSpan ( tenantId , clientSpan , spanCache ) ; if ( rootOrServerSpan != null ) { // Build source information SourceInfo si = new SourceInfo ( ) ; if ( clientSpan . getDuration ( ) != null ) { si . setDuration ( clientSpan . getDuration ( ) ) ; } if ( clientSpan . getTimestamp ( ) != null ) { si . setTimestamp ( clientSpan . getTimestamp ( ) ) ; } si . setTraceId ( clientSpan . getTraceId ( ) ) ; si . setFragmentId ( clientSpan . getId ( ) ) ; si . getProperties ( ) . addAll ( clientSpan . binaryAnnotationMapping ( ) . getProperties ( ) ) ; si . setHostAddress ( clientSpan . ipv4 ( ) ) ; if ( clientSpan . service ( ) != null ) { si . getProperties ( ) . add ( new Property ( Constants . PROP_SERVICE_NAME , clientSpan . service ( ) ) ) ; } si . setId ( clientSpan . getId ( ) ) ; si . setMultipleConsumers ( false ) ; URL url = rootOrServerSpan . url ( ) ; si . setEndpoint ( new EndpointRef ( ( url != null ? url . getPath ( ) : null ) , SpanDeriverUtil . deriveOperation ( rootOrServerSpan ) , ! rootOrServerSpan . serverSpan ( ) ) ) ; return si ; } } return null ; }
This method attempts to derive the Source Information for the supplied server span . If the information is not available then a null will be returned which can be used to trigger a retry attempt if appropriate .