Class ServletContextPath

java.lang.Object
io.opentelemetry.javaagent.bootstrap.servlet.ServletContextPath

public final class ServletContextPath extends Object
The context key here is used to propagate the servlet context path throughout the request, so that routing framework instrumentation that updates the span name with a more specific route can prepend the servlet context path in front of that route.

This needs to be in the instrumentation-api module, instead of injected as a helper class into the different modules that need it, in order to make sure that there is only a single instance of the context key, since otherwise instrumentation across different class loaders would use different context keys and not be able to share the servlet context path.

  • Method Summary

    Modifier and Type
    Method
    Description
    static <REQUEST> io.opentelemetry.context.Context
    init(io.opentelemetry.context.Context context, Function<REQUEST,String> contextPathExtractor, REQUEST request)
     
    static String
    prepend(io.opentelemetry.context.Context context, String spanName)
    Returns a concatenation of a servlet context path stored in the given context and a given spanName.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • init

      public static <REQUEST> io.opentelemetry.context.Context init(io.opentelemetry.context.Context context, Function<REQUEST,String> contextPathExtractor, REQUEST request)
    • prepend

      public static String prepend(io.opentelemetry.context.Context context, String spanName)
      Returns a concatenation of a servlet context path stored in the given context and a given spanName. If there is no servlet path stored in the context, returns spanName.