// Path: opentracing-jaxrs2/src/main/java/io/opentracing/contrib/jaxrs2/internal/URIUtils.java
// public class URIUtils {
//     private URIUtils() {}
// 
//     /**
//      * Returns path of given URI. If the first character of path is '/' then it is removed.
//      *
//      * @param uri
//      * @return path or null
//      */
//     public static String path(URI uri) {
//         String path = uri.getPath();
//         if (path != null && path.startsWith("/")) {
//             path = path.substring(1);
//         }
// 
//         return path;
//     }
// 
//     /**
//      * Returns string representation of supplied URL.
//      *
//      * @param uri
//      * @return string URL or null
//      */
//     public static String url(URI uri) {
//         String urlStr = null;
//         try {
//             URL url = uri.toURL();
//             urlStr = url.toString();
//         } catch (MalformedURLException e) {
//             // ignoring returning null
//         }
// 
//         return urlStr;
//     }
// }


import io.opentracing.Span;
import io.opentracing.contrib.jaxrs2.internal.URIUtils;
import io.opentracing.tag.Tags;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerResponseContext;
package io.opentracing.contrib.jaxrs2.server;


/**
 * @author Pavol Loffay
 */
public interface ServerSpanDecorator {

    /**
     * Decorate span by incoming object.
     *
     * @param requestContext
     * @param span
     */
    void decorateRequest(ContainerRequestContext requestContext, Span span);

    /**
     * Decorate spans by outgoing object.
     *
     * @param responseContext
     * @param span
     */
    void decorateResponse(ContainerResponseContext responseContext, Span span);

    /**
     * Adds standard tags: {@link io.opentracing.tag.Tags#SPAN_KIND},
     * {@link io.opentracing.tag.Tags#HTTP_METHOD}, {@link io.opentracing.tag.Tags#HTTP_URL} and
     * {@link io.opentracing.tag.Tags#HTTP_STATUS}
     */
    ServerSpanDecorator STANDARD_TAGS = new ServerSpanDecorator() {
        @Override
        public void decorateRequest(ContainerRequestContext requestContext, Span span) {
            Tags.COMPONENT.set(span, "jaxrs");
            Tags.HTTP_METHOD.set(span, requestContext.getMethod());

// Path: opentracing-jaxrs2/src/main/java/io/opentracing/contrib/jaxrs2/internal/URIUtils.java
// public class URIUtils {
//     private URIUtils() {}
// 
//     /**
//      * Returns path of given URI. If the first character of path is '/' then it is removed.
//      *
//      * @param uri
//      * @return path or null
//      */
//     public static String path(URI uri) {
//         String path = uri.getPath();
//         if (path != null && path.startsWith("/")) {
//             path = path.substring(1);
//         }
// 
//         return path;
//     }
// 
//     /**
//      * Returns string representation of supplied URL.
//      *
//      * @param uri
//      * @return string URL or null
//      */
//     public static String url(URI uri) {
//         String urlStr = null;
//         try {
//             URL url = uri.toURL();
//             urlStr = url.toString();
//         } catch (MalformedURLException e) {
//             // ignoring returning null
//         }
// 
//         return urlStr;
//     }
// }


// Path: opentracing-jaxrs2/src/main/java/io/opentracing/contrib/jaxrs2/server/ServerSpanDecorator.java
import io.opentracing.Span;
import io.opentracing.contrib.jaxrs2.internal.URIUtils;
import io.opentracing.tag.Tags;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerResponseContext;

package io.opentracing.contrib.jaxrs2.server;


/**
 * @author Pavol Loffay
 */
public interface ServerSpanDecorator {

    /**
     * Decorate span by incoming object.
     *
     * @param requestContext
     * @param span
     */
    void decorateRequest(ContainerRequestContext requestContext, Span span);

    /**
     * Decorate spans by outgoing object.
     *
     * @param responseContext
     * @param span
     */
    void decorateResponse(ContainerResponseContext responseContext, Span span);

    /**
     * Adds standard tags: {@link io.opentracing.tag.Tags#SPAN_KIND},
     * {@link io.opentracing.tag.Tags#HTTP_METHOD}, {@link io.opentracing.tag.Tags#HTTP_URL} and
     * {@link io.opentracing.tag.Tags#HTTP_STATUS}
     */
    ServerSpanDecorator STANDARD_TAGS = new ServerSpanDecorator() {
        @Override
        public void decorateRequest(ContainerRequestContext requestContext, Span span) {
            Tags.COMPONENT.set(span, "jaxrs");
            Tags.HTTP_METHOD.set(span, requestContext.getMethod());

            String url = URIUtils.url(requestContext.getUriInfo().getRequestUri());