// Path: opentracing-jaxrs2/src/main/java/io/opentracing/contrib/jaxrs2/internal/SpanWrapper.java
// public static final String PROPERTY_NAME = SpanWrapper.class.getName() + ".activeSpanWrapper";
// 
// Path: opentracing-jaxrs2/src/main/java/io/opentracing/contrib/jaxrs2/internal/CastUtils.java
// public class CastUtils {
//     private static final Logger log = Logger.getLogger(CastUtils.class.getName());
// 
//     private CastUtils() {}
// 
//     /**
//      * Casts given object to the given class.
//      *
//      * @param object
//      * @param clazz
//      * @param <T>
//      * @return casted object, or null if there is any error
//      */
//     public static <T> T cast(Object object, Class<T> clazz) {
//         if (object == null || clazz == null) {
//             return null;
//         }
// 
//         try {
//             return clazz.cast(object);
//         } catch (ClassCastException ex) {
//             log.severe("Cannot cast to " + clazz.getName());
//             return null;
//         }
//     }
// }
// 
// Path: opentracing-jaxrs2/src/main/java/io/opentracing/contrib/jaxrs2/internal/SpanWrapper.java
// public class SpanWrapper {
// 
//     public static final String PROPERTY_NAME = SpanWrapper.class.getName() + ".activeSpanWrapper";
// 
//     private Scope scope;
//     private Span span;
//     private AtomicBoolean finished = new AtomicBoolean();
// 
//     public SpanWrapper(Span span, Scope scope) {
//         this.span = span;
//         this.scope = scope;
// 
//     }
// 
//     public Span get() {
//         return span;
//     }
// 
//     public Scope getScope() {
//         return scope;
//     }
// 
//     public void finish() {
//         if (finished.compareAndSet(false, true)) {
//             span.finish();
//         }
//     }
// 
//     public boolean isFinished() {
//         return finished.get();
//     }
// }


import static io.opentracing.contrib.jaxrs2.internal.SpanWrapper.PROPERTY_NAME;
import io.opentracing.Span;
import io.opentracing.SpanContext;
import io.opentracing.Tracer;
import io.opentracing.contrib.jaxrs2.internal.CastUtils;
import io.opentracing.contrib.jaxrs2.internal.SpanWrapper;
import io.opentracing.noop.NoopScopeManager.NoopScope;
import io.opentracing.propagation.Format;
import io.opentracing.tag.Tags;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Priority;
import javax.ws.rs.Priorities;
import javax.ws.rs.client.ClientRequestContext;
import javax.ws.rs.client.ClientRequestFilter;
import javax.ws.rs.client.ClientResponseContext;
import javax.ws.rs.client.ClientResponseFilter;
import org.eclipse.microprofile.opentracing.Traced;
        if (parentSpanContext != null) {
            spanBuilder.ignoreActiveSpan()
                .asChildOf(parentSpanContext);
        }

        /**
         * Do not create Scope - there is no way to deactivate it on UnknownHostException
         */
        final Span span = spanBuilder.start();

        if (spanDecorators != null) {
            for (ClientSpanDecorator decorator: spanDecorators) {
                decorator.decorateRequest(requestContext, span);
            }
        }

        if (log.isLoggable(Level.FINEST)) {
            log.finest("Starting client span");
        }

        tracer.inject(span.context(), Format.Builtin.HTTP_HEADERS, new ClientHeadersInjectTextMap(requestContext.getHeaders()));
        requestContext.setProperty(PROPERTY_NAME, new SpanWrapper(span, new NoopScope() {
            @Override
            public void close() {
            }
        }));
    }

    @Override
    public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException {
// Path: opentracing-jaxrs2/src/main/java/io/opentracing/contrib/jaxrs2/internal/SpanWrapper.java
// public static final String PROPERTY_NAME = SpanWrapper.class.getName() + ".activeSpanWrapper";
// 
// Path: opentracing-jaxrs2/src/main/java/io/opentracing/contrib/jaxrs2/internal/CastUtils.java
// public class CastUtils {
//     private static final Logger log = Logger.getLogger(CastUtils.class.getName());
// 
//     private CastUtils() {}
// 
//     /**
//      * Casts given object to the given class.
//      *
//      * @param object
//      * @param clazz
//      * @param <T>
//      * @return casted object, or null if there is any error
//      */
//     public static <T> T cast(Object object, Class<T> clazz) {
//         if (object == null || clazz == null) {
//             return null;
//         }
// 
//         try {
//             return clazz.cast(object);
//         } catch (ClassCastException ex) {
//             log.severe("Cannot cast to " + clazz.getName());
//             return null;
//         }
//     }
// }
// 
// Path: opentracing-jaxrs2/src/main/java/io/opentracing/contrib/jaxrs2/internal/SpanWrapper.java
// public class SpanWrapper {
// 
//     public static final String PROPERTY_NAME = SpanWrapper.class.getName() + ".activeSpanWrapper";
// 
//     private Scope scope;
//     private Span span;
//     private AtomicBoolean finished = new AtomicBoolean();
// 
//     public SpanWrapper(Span span, Scope scope) {
//         this.span = span;
//         this.scope = scope;
// 
//     }
// 
//     public Span get() {
//         return span;
//     }
// 
//     public Scope getScope() {
//         return scope;
//     }
// 
//     public void finish() {
//         if (finished.compareAndSet(false, true)) {
//             span.finish();
//         }
//     }
// 
//     public boolean isFinished() {
//         return finished.get();
//     }
// }


// Path: opentracing-jaxrs2/src/main/java/io/opentracing/contrib/jaxrs2/client/ClientTracingFilter.java
import static io.opentracing.contrib.jaxrs2.internal.SpanWrapper.PROPERTY_NAME;
import io.opentracing.Span;
import io.opentracing.SpanContext;
import io.opentracing.Tracer;
import io.opentracing.contrib.jaxrs2.internal.CastUtils;
import io.opentracing.contrib.jaxrs2.internal.SpanWrapper;
import io.opentracing.noop.NoopScopeManager.NoopScope;
import io.opentracing.propagation.Format;
import io.opentracing.tag.Tags;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Priority;
import javax.ws.rs.Priorities;
import javax.ws.rs.client.ClientRequestContext;
import javax.ws.rs.client.ClientRequestFilter;
import javax.ws.rs.client.ClientResponseContext;
import javax.ws.rs.client.ClientResponseFilter;
import org.eclipse.microprofile.opentracing.Traced;

        if (parentSpanContext != null) {
            spanBuilder.ignoreActiveSpan()
                .asChildOf(parentSpanContext);
        }

        /**
         * Do not create Scope - there is no way to deactivate it on UnknownHostException
         */
        final Span span = spanBuilder.start();

        if (spanDecorators != null) {
            for (ClientSpanDecorator decorator: spanDecorators) {
                decorator.decorateRequest(requestContext, span);
            }
        }

        if (log.isLoggable(Level.FINEST)) {
            log.finest("Starting client span");
        }

        tracer.inject(span.context(), Format.Builtin.HTTP_HEADERS, new ClientHeadersInjectTextMap(requestContext.getHeaders()));
        requestContext.setProperty(PROPERTY_NAME, new SpanWrapper(span, new NoopScope() {
            @Override
            public void close() {
            }
        }));
    }

    @Override
    public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException {
        SpanWrapper spanWrapper = CastUtils