Class HttpServerTracer<REQUEST,​RESPONSE,​CONNECTION,​STORAGE>

  • Type Parameters:
    REQUEST - - The specific type for HTTP requests
    RESPONSE - - The specific type for HTTP responses
    CONNECTION - - The specific type of HTTP connection, used to get peer address information and HTTP flavor.
    STORAGE - - Implementation specific storage type for attaching/getting the server context. Use Void if your subclass does not have an implementation specific storage need.

    public abstract class HttpServerTracer<REQUEST,​RESPONSE,​CONNECTION,​STORAGE>
    extends BaseTracer
    Base class for implementing Tracers for HTTP servers. It has 3 types that must be specified by subclasses:
    • Field Detail

      • CONTEXT_ATTRIBUTE

        public static final String CONTEXT_ATTRIBUTE
    • Constructor Detail

      • HttpServerTracer

        public HttpServerTracer()
      • HttpServerTracer

        public HttpServerTracer​(io.opentelemetry.api.trace.Tracer tracer)
    • Method Detail

      • startSpan

        public io.opentelemetry.context.Context startSpan​(REQUEST request,
                                                          CONNECTION connection,
                                                          @Nullable STORAGE storage,
                                                          String spanName,
                                                          long startTimestamp)
      • end

        public void end​(io.opentelemetry.context.Context context,
                        RESPONSE response)
        Convenience method. Delegates to end(Context, Object, long), passing timestamp value of -1.
      • end

        public void end​(io.opentelemetry.context.Context context,
                        RESPONSE response,
                        long timestamp)
      • endExceptionally

        public void endExceptionally​(io.opentelemetry.context.Context context,
                                     Throwable throwable,
                                     RESPONSE response,
                                     long timestamp)
        If response is null, the http.status_code will be set to 500 and the Span status will be set to StatusCode.ERROR.
      • getServerSpan

        public io.opentelemetry.api.trace.Span getServerSpan​(STORAGE storage)
      • getServerContext

        public abstract @Nullable io.opentelemetry.context.Context getServerContext​(STORAGE storage)
        Returns context stored to the given request-response-loop storage by attachServerContext(Context, Object).