Class ExecutionListener.Builder
- Enclosing class:
ExecutionListener
- Since:
- 19.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionCreates a new execution listener using the current builder configuration and attaches it to an engine.collectExceptions
(boolean enabled) Collect additional execution event data about errors.collectInputValues
(boolean enabled) Collect additional execution event data for input values.collectReturnValue
(boolean enabled) Collect additional execution event data about return values.expressions
(boolean enabled) Include program locations that are marked as expressions.onEnter
(Consumer<ExecutionEvent> listener) Set a listener that is notified when an execution of an element is entered.onReturn
(Consumer<ExecutionEvent> listener) Set a listener that is notified when an execution of an element was entered and completed.rootNameFilter
(Predicate<String> predicate) Set an addition filter execution events by root name.roots
(boolean enabled) Include program locations that are marked as root of a function, method or closure.sourceFilter
(Predicate<Source> predicate) Set an addition filter that filters execution events by source.statements
(boolean enabled) Include program locations that are marked as statements.
-
Method Details
-
onEnter
Set a listener that is notified when an execution of an element is entered.- Since:
- 19.0
-
onReturn
Set a listener that is notified when an execution of an element was entered and completed.- Since:
- 19.0
-
sourceFilter
Set an addition filter that filters execution events by source. By default all sources are included. Source predicates must be stable, i.e. always return the same result for a source. The filter predicate may be invoked on multiple threads at the same time.- Parameters:
predicate
- the source predicate that returnstrue
for a source to be included andfalse
otherwise.- Since:
- 19.0
-
rootNameFilter
Set an addition filter execution events by root name. By default all root names are included. Root name predicates must be stable and always return the same result for source. The filter predicate may be invoked on multiple threads at the same time.- Since:
- 19.0
-
roots
Include program locations that are marked as root of a function, method or closure. By default no source elements are included.- Parameters:
enabled
-true
if enabled, elsefalse
- Since:
- 19.0
- See Also:
-
statements
Include program locations that are marked as statements. By default no source elements are included.- Parameters:
enabled
-true
if enabled, elsefalse
- Since:
- 19.0
- See Also:
-
expressions
Include program locations that are marked as expressions. By default no source elements are included.- Parameters:
enabled
-true
if enabled, elsefalse
- Since:
- 19.0
- See Also:
-
collectInputValues
Collect additional execution event data for input values. The input values may be accessed inOnReturn
events withExecutionEvent.getInputValues()
.If additional event data is collected then the peak performance overhead of execution listeners is significant. It is not recommended to collect additional event data when running production workloads.
- Parameters:
enabled
-true
if enabled, elsefalse
- Since:
- 19.0
-
collectReturnValue
Collect additional execution event data about return values. The return value may be accessed inOnReturn
events withExecutionEvent.getReturnValue()
.If additional event data is collected then the peak performance overhead of execution listeners is significant. It is not recommended to collect additional event data when running production workloads.
- Parameters:
enabled
-true
if enabled, elsefalse
- Since:
- 19.0
-
collectExceptions
Collect additional execution event data about errors. The error may be accessed inOnReturn
events withExecutionEvent.getException()
.If additional event data is collected then the peak performance overhead of execution listeners is significant. It is not recommended to collect additional event data when running production workloads.
- Parameters:
enabled
-true
if enabled, elsefalse
- Since:
- 19.0
-
attach
Creates a new execution listener using the current builder configuration and attaches it to an engine. The same builder configuration may be used to attach multiple listeners.Execution listeners cannot be attached to engines that were statically looked up using
Context.
. For security reasons only the originalgetCurrent()
.getEngine()
creator
of the context or engine is allowed to perform this action.Attaching
andclosing
execution listeners are expensive operations and typically require to traverse through all loaded code. Code that was previously optimized will be deoptimized in the process. It is most efficient to attach an execution listener before any code is executed and let execution listeners automatically close with the engine.- Parameters:
engine
- the engine to attach to- Returns:
- the attached closable execution listener.
- Throws:
PolyglotException
- if one of the provided filter predicate fails.- Since:
- 19.0
-