/** * Extracts a {@code SpanContext} from a JSON object. * <p> * The span context will be read from a JSON object under key <em>span-context</em>. * * @param tracer The Tracer to use for extracting the context. * @param jsonObject The JSON object to extract the context from. * @return The context or {@code null} if the given JSON object does not contain a context. * @throws NullPointerException if any of the parameters are {@code null}. */ public static SpanContext extractSpanContext(final Tracer tracer, final JsonObject jsonObject) { Objects.requireNonNull(tracer); Objects.requireNonNull(jsonObject); final Object spanContextContainer = jsonObject.getValue(JSON_KEY_SPAN_CONTEXT); return spanContextContainer instanceof JsonObject ? tracer.extract(Format.Builtin.TEXT_MAP, new JsonObjectExtractAdapter((JsonObject) spanContextContainer)) : null; } }