Class AppServerBridge


  • public class AppServerBridge
    extends Object
    Helper container for Context attributes for transferring certain information between servlet integration and app-server server handler integrations.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Class<?> getCallDepthKey()
      Class used as key in CallDepthThreadLocalMap for counting servlet invocation depth in Servlet3Advice and Servlet2Advice.
      static Throwable getException​(io.opentelemetry.context.Context context)
      Get exception that happened during servlet invocation.
      static io.opentelemetry.context.Context init​(io.opentelemetry.context.Context ctx)
      Attach AppServerBridge to context.
      static io.opentelemetry.context.Context init​(io.opentelemetry.context.Context ctx, boolean shouldRecordException)
      Attach AppServerBridge to context.
      static void recordException​(io.opentelemetry.context.Context context, Throwable exception)
      Record exception that happened during servlet invocation so that app server instrumentation can add it to server span.
    • Method Detail

      • init

        public static io.opentelemetry.context.Context init​(io.opentelemetry.context.Context ctx)
        Attach AppServerBridge to context.
        Parameters:
        ctx - server context
        Returns:
        new context with AppServerBridge attached.
      • init

        public static io.opentelemetry.context.Context init​(io.opentelemetry.context.Context ctx,
                                                            boolean shouldRecordException)
        Attach AppServerBridge to context.
        Parameters:
        ctx - server context
        shouldRecordException - whether servlet integration should record exception thrown during servlet invocation in server span. Use false on servers where exceptions thrown during servlet invocation are propagated to the method where server span is closed and can be added to server span there and true otherwise.
        Returns:
        new context with AppServerBridge attached.
      • recordException

        public static void recordException​(io.opentelemetry.context.Context context,
                                           Throwable exception)
        Record exception that happened during servlet invocation so that app server instrumentation can add it to server span.
        Parameters:
        context - server context
        exception - exception that happened during servlet invocation
      • getException

        @Nullable
        public static Throwable getException​(io.opentelemetry.context.Context context)
        Get exception that happened during servlet invocation.
        Parameters:
        context - server context
        Returns:
        exception that happened during servlet invocation
      • getCallDepthKey

        public static Class<?> getCallDepthKey()
        Class used as key in CallDepthThreadLocalMap for counting servlet invocation depth in Servlet3Advice and Servlet2Advice. We can not use helper classes like Servlet3Advice and Servlet2Advice for determining call depth of server invocation because they can be injected into multiple class loaders.
        Returns:
        class used as a key in CallDepthThreadLocalMap for counting servlet invocation depth