java.lang.Object
io.opentelemetry.javaagent.instrumentation.opentelemetryapi.context.AgentContextStorage
All Implemented Interfaces:
application.io.opentelemetry.context.ContextStorage, AutoCloseable

public class AgentContextStorage extends Object implements application.io.opentelemetry.context.ContextStorage, AutoCloseable
ContextStorage which stores the Context in the user's application inside the Context in the agent. This allows for context interaction to be maintained between the app and agent.

This storage allows for implicit parenting of context to exist between the agent and application by storing the concrete application context in the agent context and returning a wrapper which accesses into this stored concrete context.

This storage also makes sure that OpenTelemetry objects are shared within the context. To do this, it recognizes the keys for OpenTelemetry objects (e.g, Span, Baggage) and always stores and retrieves them from the agent context, even when accessed from the application. All other accesses are to the concrete application context.

  • Method Summary

    Modifier and Type
    Method
    Description
    application.io.opentelemetry.context.Scope
    attach(application.io.opentelemetry.context.Context toAttach)
     
    void
     
    application.io.opentelemetry.context.Context
     
    static io.opentelemetry.context.Context
    getAgentContext(application.io.opentelemetry.context.Context applicationContext)
     
    static application.io.opentelemetry.context.Context
    newContextWrapper(io.opentelemetry.context.Context agentContext, application.io.opentelemetry.context.Context applicationContext)
     
    application.io.opentelemetry.context.Context
     
    static application.io.opentelemetry.context.Context
    toApplicationContext(io.opentelemetry.context.Context agentContext)
     
    static Function<? super application.io.opentelemetry.context.ContextStorage,? extends application.io.opentelemetry.context.ContextStorage>
     
    static application.io.opentelemetry.context.Context
    wrapRootContext(application.io.opentelemetry.context.Context rootContext)
     

    Methods inherited from class java.lang.Object

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

    • wrapRootContext

      public static application.io.opentelemetry.context.Context wrapRootContext(application.io.opentelemetry.context.Context rootContext)
    • wrap

      public static Function<? super application.io.opentelemetry.context.ContextStorage,? extends application.io.opentelemetry.context.ContextStorage> wrap()
    • getAgentContext

      public static io.opentelemetry.context.Context getAgentContext(application.io.opentelemetry.context.Context applicationContext)
    • toApplicationContext

      public static application.io.opentelemetry.context.Context toApplicationContext(io.opentelemetry.context.Context agentContext)
    • newContextWrapper

      public static application.io.opentelemetry.context.Context newContextWrapper(io.opentelemetry.context.Context agentContext, application.io.opentelemetry.context.Context applicationContext)
    • attach

      public application.io.opentelemetry.context.Scope attach(application.io.opentelemetry.context.Context toAttach)
      Specified by:
      attach in interface application.io.opentelemetry.context.ContextStorage
    • current

      public application.io.opentelemetry.context.Context current()
      Specified by:
      current in interface application.io.opentelemetry.context.ContextStorage
    • root

      public application.io.opentelemetry.context.Context root()
      Specified by:
      root in interface application.io.opentelemetry.context.ContextStorage
    • close

      public void close() throws Exception
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception