Class ObservabilityContext.Scope
java.lang.Object
cloud.opencode.base.observability.context.ObservabilityContext.Scope
- All Implemented Interfaces:
AutoCloseable
- Enclosing class:
ObservabilityContext
A scope that restores the previous
ObservabilityContext when closed.
关闭时恢复先前 ObservabilityContext 的 scope。
Intended for use with try-with-resources to ensure proper context cleanup.
旨在与 try-with-resources 一起使用以确保正确的上下文清理。
- Since:
- JDK 25, opencode-base-observability V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Restores the previous context (or removes the current one if there was no previous).
-
Method Details
-
close
public void close()Restores the previous context (or removes the current one if there was no previous). 恢复先前的上下文(如果没有先前的上下文则移除当前的)。Must be called on the same thread that created this Scope via
ObservabilityContext.attach(). Cross-thread close is silently ignored to prevent context corruption.必须在通过
ObservabilityContext.attach()创建此 Scope 的同一线程上调用。 跨线程 close 被静默忽略以防止上下文错乱。- Specified by:
closein interfaceAutoCloseable
-