Package com.newrelic.api.agent
Interface Token
-
public interface Token
Tokens are passed between threads to link asynchronous units of work to the originatingTransaction
associated with the token. This results in two or more pieces of work being tied together into a singleTransaction
. A token is created by a call toTransaction.getToken()
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
expire()
Invalidates the token, making it unable to link work together in aTransaction
.boolean
isActive()
Checks if a token is valid and can be used to link work to the originatingTransaction
associated with the token.boolean
link()
Links the work being done on the current thread back to the originatingTransaction
associated with the token.boolean
linkAndExpire()
Links the work being done on the current thread back to the originatingTransaction
associated with the token and expires the token.
-
-
-
Method Detail
-
link
boolean link()
Links the work being done on the current thread back to the originatingTransaction
associated with the token. Linking alone does not start tracing work on the thread. To begin tracing work on methods that should be included in the transaction, you should use the @Trace(async = true) annotation.- Returns:
- True if the current thread has been linked to the token's transaction. False if the token has been expired or if you are trying to link within the @Trace(dispatcher = true) transaction where the token was created.
- Since:
- 3.37.0
-
expire
boolean expire()
Invalidates the token, making it unable to link work together in aTransaction
. When a token is expired it can no longer be used. If aToken
is not explicitly expired it will be timed out according to thetoken_timeout
value which is user configurable in the yaml file or by a Java system property. When all tokens are expired the transaction will be allowed to finish.- Returns:
- True if the token was found and expired.
- Since:
- 3.37.0
-
linkAndExpire
boolean linkAndExpire()
Links the work being done on the current thread back to the originatingTransaction
associated with the token and expires the token. If linking fails for any reason the token will still be expired. This provides an alternative to separately callinglink()
andexpire()
.- Returns:
- True if the current thread has been linked to the token's transaction and the token has been expired, false otherwise. Note: The token will be expired (if found) even if the result of this call is "false".
- Since:
- 3.37.0
-
isActive
boolean isActive()
Checks if a token is valid and can be used to link work to the originatingTransaction
associated with the token.- Returns:
- True if the token is active and can be used, false if the token has been expired.
- Since:
- 3.37.0
-
-