Class TtlAgent
The configuration/arguments for TTL agent
Configure TTL agent via agent arguments, format is k1:v1,k2:v2
. Below is available configuration keys.
Disable inheritable for thread pool
Enable "disable inheritable" for thread pool, config by key ttl.agent.disable.inheritable.for.thread.pool
.
When no configuration for this key, default does not enabled. Since version 2.10.1
.
- rewrite the
ThreadFactory
constructor parameter ofThreadPoolExecutor
toDisableInheritableThreadFactory
by util methodgetDisableInheritableThreadFactory
. - rewrite the
ForkJoinPool.ForkJoinWorkerThreadFactory
constructor parameter ofForkJoinPool
toDisableInheritableForkJoinWorkerThreadFactory
by util methodgetDisableInheritableForkJoinWorkerThreadFactory
.
TransmittableThreadLocal
.
Configuration example:
-javaagent:/path/to/transmittable-thread-local-2.x.y.jar=ttl.agent.disable.inheritable.for.thread.pool:true
The log configuration
The log of TTL Java Agent is config by keyttl.agent.logger
. Since version 2.6.0
.
ttl.agent.logger : STDERR
only log tostderr
when error. This is default, when no/unrecognized configuration for keyttl.agent.logger
.ttl.agent.logger : STDOUT
Log tostdout
, more info thanttl.agent.logger:STDERR
; This is needed when developing.
configuration example:
-javaagent:/path/to/transmittable-thread-local-2.x.y.jar
-javaagent:/path/to/transmittable-thread-local-2.x.y.jar=ttl.agent.logger:STDOUT
Enable/disable TimerTask class decoration
Enable/disable TimerTask class decoration is config by keyttl.agent.enable.timer.task
.
Since version 2.7.0
.
When no configuration for this key, default is enabled.
Note: Since version 2.11.2
the default value is true
(enable TimerTask class decoration);
Before version 2.11.1
default value is false
.
Configuration example:
-javaagent:/path/to/transmittable-thread-local-2.x.y.jar=ttl.agent.enable.timer.task:false
-javaagent:/path/to/transmittable-thread-local-2.x.y.jar=ttl.agent.enable.timer.task:true
Multi key configuration example
-javaagent:/path/to/transmittable-thread-local-2.x.y.jar=ttl.agent.logger:STDOUT,ttl.agent.disable.inheritable.for.thread.pool:true
About boot classpath for TTL agent
NOTE: Sincev2.6.0
, TTL agent jar will auto add self to boot classpath
.
But you should NOT modify the downloaded TTL jar file name in the maven repo(eg: transmittable-thread-local-2.x.y.jar
).if you modified the downloaded TTL agent jar file name(eg:
ttl-foo-name-changed.jar
),
you must add TTL agent jar to boot classpath
manually
by java option -Xbootclasspath/a:path/to/ttl-foo-name-changed.jar
.
The implementation of auto adding self agent jar to boot classpath
use
the Boot-Class-Path
property of manifest file(META-INF/MANIFEST.MF
) in the TTL Java Agent Jar:
- Boot-Class-Path
- A list of paths to be searched by the bootstrap class loader. Paths represent directories or libraries (commonly referred to as JAR or zip libraries on many platforms). These paths are searched by the bootstrap class loader after the platform specific mechanisms of locating a class have failed. Paths are searched in the order listed.
More info about Boot-Class-Path
see
The mechanism for instrumentation.
- Since:
- 0.9.0
- Author:
- Jerry Lee (oldratlee at gmail dot com)
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Whether disable inheritable for thread pool is enhanced by ttl agent, checkisTtlAgentLoaded()
first.static boolean
Whether timer task is enhanced by ttl agent, checkisTtlAgentLoaded()
first.static boolean
Whether TTL agent is loaded.static void
premain
(String agentArgs, Instrumentation inst) Entrance method of TTL Java Agent.
-
Method Details
-
premain
Entrance method of TTL Java Agent.- See Also:
-
Logger
Logger.TTL_AGENT_LOGGER_KEY
Logger.STDERR
Logger.STDOUT
-
isTtlAgentLoaded
public static boolean isTtlAgentLoaded()Whether TTL agent is loaded.- Since:
- 2.9.0
-
isDisableInheritableForThreadPool
public static boolean isDisableInheritableForThreadPool()Whether disable inheritable for thread pool is enhanced by ttl agent, checkisTtlAgentLoaded()
first.- Since:
- 2.10.1
- See Also:
-
TtlExecutors.getDefaultDisableInheritableThreadFactory()
TtlExecutors.getDisableInheritableThreadFactory(java.util.concurrent.ThreadFactory)
DisableInheritableThreadFactory
TtlForkJoinPoolHelper.getDefaultDisableInheritableForkJoinWorkerThreadFactory()
TtlForkJoinPoolHelper.getDisableInheritableForkJoinWorkerThreadFactory(java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory)
DisableInheritableForkJoinWorkerThreadFactory
-
isEnableTimerTask
public static boolean isEnableTimerTask()Whether timer task is enhanced by ttl agent, checkisTtlAgentLoaded()
first.- Since:
- 2.10.1
-