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:
    • Constructor Detail

      • HttpServerTracer

        protected HttpServerTracer()
      • HttpServerTracer

        protected HttpServerTracer​(io.opentelemetry.api.OpenTelemetry openTelemetry)
    • Method Detail

      • startSpan

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

        protected io.opentelemetry.context.Context customizeContext​(io.opentelemetry.context.Context context,
                                                                    REQUEST request)
        Override in subclass to customize context that is returned by startSpan.
      • 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).
      • onConnection

        protected void onConnection​(io.opentelemetry.api.trace.SpanBuilder spanBuilder,
                                    CONNECTION connection)
      • onRequest

        protected void onRequest​(io.opentelemetry.api.trace.SpanBuilder spanBuilder,
                                 REQUEST request)
      • onConnectionAndRequest

        protected void onConnectionAndRequest​(io.opentelemetry.api.trace.SpanBuilder spanBuilder,
                                              CONNECTION connection,
                                              REQUEST request)
      • peerPort

        protected abstract @Nullable Integer peerPort​(CONNECTION connection)
      • peerHostIP

        protected abstract @Nullable String peerHostIP​(CONNECTION connection)
      • getGetter

        protected abstract io.opentelemetry.context.propagation.TextMapGetter<REQUEST> getGetter()
      • requestHeader

        protected abstract @Nullable String requestHeader​(REQUEST request,
                                                          String name)
      • responseStatus

        protected abstract int responseStatus​(RESPONSE response)
      • attachServerContext

        protected abstract void attachServerContext​(io.opentelemetry.context.Context context,
                                                    STORAGE storage)
        Stores given context in the given request-response-loop storage in implementation specific way.
      • isRelativeUrl

        protected boolean isRelativeUrl​(String url)