/** * Injects a {@code SpanContext} into a JSON object. * <p> * The span context will be injected into a new JSON object under key <em>span-context</em>. * * @param tracer The Tracer to use for injecting the context. * @param spanContext The context to inject. * @param jsonObject The JSON object to inject the context into. * @throws NullPointerException if any of the parameters are {@code null}. */ public static void injectSpanContext(final Tracer tracer, final SpanContext spanContext, final JsonObject jsonObject) { Objects.requireNonNull(tracer); Objects.requireNonNull(spanContext); Objects.requireNonNull(jsonObject); final JsonObject spanContextJson = new JsonObject(); jsonObject.put(JSON_KEY_SPAN_CONTEXT, spanContextJson); tracer.inject(spanContext, Format.Builtin.TEXT_MAP, new JsonObjectInjectAdapter(spanContextJson)); }