Class StructuredDeploymentTracing
- java.lang.Object
-
- org.glassfish.internal.deployment.analysis.StructuredDeploymentTracing
-
- All Implemented Interfaces:
AutoCloseable
public final class StructuredDeploymentTracing extends Object implements AutoCloseable
Refined deployment tracing facility for structured capture of stages of deployment. The trace consists of multiple , which represent time periods of execution. Stages can be nested. This nesting is represented byTraceContext
, where we expect that in the hierarchy there is at most one active context per level. At instantiation time,APPLICATION
context is created as top-level one. The process finishes by invokingclose()
, which finishes the top-level context. There is set of methods that match the interface of formerDeploymentTracing
class, and methods, that allow spans to be obtained, and then finished by invokingDeploymentSpan.close()
method, or via try-with-resources, as they areAutoCloseable
.- Author:
- Patrik Dudits
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addApplicationMark(DeploymentTracing.Mark mark)
Compatibility withDeploymentTracing
.void
addContainerMark(String name, DeploymentTracing.ContainerMark mark)
Compatibility withDeploymentTracing
.void
addModuleMark(String moduleName, DeploymentTracing.ModuleMark mark)
Compatibility withDeploymentTracing
.void
close()
Finish the tracing by closing the root context.static StructuredDeploymentTracing
create(String appName)
Create new instance for applicationstatic StructuredDeploymentTracing
createDisabled(String appName)
Create disabled instance.boolean
isEnabled()
static StructuredDeploymentTracing
load(DeploymentContext context)
void
print(PrintStream out)
void
print(PrintWriter out)
Compatibility withDeploymentTracing
.DeploymentTracing
register(DeploymentContext deploymentContext)
SpanSequence
startSequence(Enum<?> action)
SpanSequence
startSequence(Enum<?> action, String componentName)
DeploymentSpan
startSpan(Enum<?> action)
Start a new span that will be finished by invoking itsDeploymentSpan.close()
methodDeploymentSpan
startSpan(Enum<?> action, String componentName)
Start a new span that will be finished by invoking itsDeploymentSpan.close()
methodDeploymentSpan
startSpan(TraceContext.Level level, String contextName, Enum<?> action)
Switch to new context and start a span.DeploymentSpan
startSpan(TraceContext.Level level, String contextName, Enum<?> action, String componentName)
Switch to new context and start a span.TraceContext
switchToContext(TraceContext.Level level, String name)
Switch to new context.
-
-
-
Method Detail
-
create
public static StructuredDeploymentTracing create(String appName)
Create new instance for application- Parameters:
appName
-- Returns:
- new instance
-
createDisabled
public static StructuredDeploymentTracing createDisabled(String appName)
Create disabled instance. If tracing is disabled, only root context is captured. Marks do nothing, and dummy span is returned fromstartSpan
.- Parameters:
appName
-- Returns:
-
load
public static StructuredDeploymentTracing load(DeploymentContext context)
-
startSpan
public DeploymentSpan startSpan(Enum<?> action)
Start a new span that will be finished by invoking itsDeploymentSpan.close()
method- Parameters:
action
- action being performed- Returns:
- closeable span
-
startSpan
public DeploymentSpan startSpan(Enum<?> action, String componentName)
Start a new span that will be finished by invoking itsDeploymentSpan.close()
method- Parameters:
action
- action being performedcomponentName
- optional component the action is performed upon- Returns:
- closeable span
-
startSpan
public DeploymentSpan startSpan(TraceContext.Level level, String contextName, Enum<?> action)
Switch to new context and start a span.- Parameters:
level
- context levelcontextName
- context nameaction
- action being performed- Returns:
- new span
- See Also:
switchToContext(TraceContext.Level, String)
,startSpan(TraceContext.Level, String, Enum, String)
-
startSpan
public DeploymentSpan startSpan(TraceContext.Level level, String contextName, Enum<?> action, String componentName)
Switch to new context and start a span.- Parameters:
level
- context levelcontextName
- context nameaction
- action being performedcomponentName
- optional component on which the action is being performed- Returns:
- new span
- See Also:
switchToContext(TraceContext.Level, String)
,startSpan(TraceContext.Level, String, Enum, String)
-
startSequence
public SpanSequence startSequence(Enum<?> action)
-
startSequence
public SpanSequence startSequence(Enum<?> action, String componentName)
-
switchToContext
public TraceContext switchToContext(TraceContext.Level level, String name)
Switch to new context. If context on level specified parameter is already a parent of current context, the context stack will pop to that level. If name of context then doesn't match, a new sibling context is created, and previous one is closed. If given level is not parent of current context, child context is created.- Parameters:
level
- Level of the new contextname
- Name of the level- Returns:
- current context. For user this object is unusally uninteresting
-
addModuleMark
public void addModuleMark(String moduleName, DeploymentTracing.ModuleMark mark)
Compatibility withDeploymentTracing
. Creates span that starts at end of previous span, and ends now.- Parameters:
mark
-
-
close
public void close()
Finish the tracing by closing the root context.- Specified by:
close
in interfaceAutoCloseable
-
isEnabled
public boolean isEnabled()
-
register
public DeploymentTracing register(DeploymentContext deploymentContext)
-
print
public void print(PrintWriter out)
Compatibility withDeploymentTracing
. Finishes tracing and prints out tabular lists of spans
-
print
public void print(PrintStream out)
-
addApplicationMark
public void addApplicationMark(DeploymentTracing.Mark mark)
Compatibility withDeploymentTracing
. Creates span that starts at end of previous span, and ends now.- Parameters:
mark
-
-
addContainerMark
public void addContainerMark(String name, DeploymentTracing.ContainerMark mark)
Compatibility withDeploymentTracing
. Creates span that starts at end of previous span, and ends now.- Parameters:
mark
-
-
-