Class AgentContextStorage
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 TypeMethodDescriptionapplication.io.opentelemetry.context.Scopeattach(application.io.opentelemetry.context.Context toAttach) voidclose()application.io.opentelemetry.context.Contextcurrent()static io.opentelemetry.context.ContextgetAgentContext(application.io.opentelemetry.context.Context applicationContext) static application.io.opentelemetry.context.ContextnewContextWrapper(io.opentelemetry.context.Context agentContext, application.io.opentelemetry.context.Context applicationContext) application.io.opentelemetry.context.Contextroot()static application.io.opentelemetry.context.ContexttoApplicationContext(io.opentelemetry.context.Context agentContext) static Function<? super application.io.opentelemetry.context.ContextStorage,? extends application.io.opentelemetry.context.ContextStorage> wrap()static application.io.opentelemetry.context.ContextwrapRootContext(application.io.opentelemetry.context.Context rootContext)
-
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:
attachin interfaceapplication.io.opentelemetry.context.ContextStorage
-
current
public application.io.opentelemetry.context.Context current()- Specified by:
currentin interfaceapplication.io.opentelemetry.context.ContextStorage
-
root
public application.io.opentelemetry.context.Context root()- Specified by:
rootin interfaceapplication.io.opentelemetry.context.ContextStorage
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-