@Target(value={})
public @interface Part
ClassTransaction.naming()
and MethodTransaction.naming()
parameters,
either as a single instance that defines the entire name or an annotation array with the syntax
{@Part(...), @Part(...), @Part(...)} where the concatenation of all parts determines the
name of the transaction.
Part concatenation adds no whitespace between parts, so you might have to introduce text parts for separation, like in
{@Part(Type.CLASS), @Part(text = " "), @Part(Type.PARAMETER)}
To reduce the number of parts, you can add text attributes to non-text parts. In that case, the text will always be appended as a suffix. The example above can be replaced with
{@Part(Type.CLASS, text = " "), @Part(Type.PARAMETER)}
Modifier and Type | Optional Element and Description |
---|---|
java.lang.String |
getterChain
Specifies a getter chain that should be called on an object for name parts of the types
Part.Type.PARAMETER and Part.Type.INSTANCE . |
PackageMode |
packageMode
Specifies the way packages names are converted to text for name parts of the types
Part.Type.CLASS and Part.Type.INSTANCE_CLASS . |
int |
parameterIndex
Specifies the index of the desired parameter name for parts of type
Part.Type.PARAMETER . |
java.lang.String |
text
Specifies the text for a name part of type
Part.Type.TEXT and a suffix for other part types. |
Part.Type |
value
The type of the name part.
|
public abstract Part.Type value
Part.Type.TEXT
, a fixed text name part can be written simply as
@Part(text = "Some text")
For other parts types, if there are no further parameters, call
@Part(Type.CLASS)
If other parameters are required, you must specify value for the type:
@Part(value = Type.CLASS, packageMode = PackageMode.ABBREVIATED)
Part.Type
public abstract java.lang.String text
Part.Type.TEXT
and a suffix for other part types.
For types other than Part.Type.TEXT
, you can add a text suffix to the value of the part.
This can help you to reduce the number of parts. For example:
@MethodTransaction(naming = {@Part(Type.CLASS, text="."), @Part(Type.METHOD)})
public abstract PackageMode packageMode
Part.Type.CLASS
and Part.Type.INSTANCE_CLASS
.
For other types, the parameter has no effect and should not be specified.
By default, package names are not added and only simple class names are used. This serves to keep transaction names short.
PackageMode
public abstract java.lang.String getterChain
Part.Type.PARAMETER
and Part.Type.INSTANCE
.
For other types, the parameter has no effect and should not be specified.
Without a getter chain, the toString() method of the parameter (for Part.Type#PARAMETER) or the instance of the instrumented method (Part.Type#INSTANCE) are called and the result is the value of the name part. With a getter chain, you can call any number of parameter-less methods or fields to replace the original object with the result of the getter chain.
Usage:
For an invocation of getClass(), there are two special fields that are added by perfino to
get the same result as for the Part.Type.CLASS
and Part.Type.INSTANCE_CLASS
naming parts
with their different package modes
:
Exceptional circumstances:
public abstract int parameterIndex
Part.Type.PARAMETER
.
For other types, the parameter has no effect and should not be specified.
By default, the first parameter is used, to use another parameter specify the zero-based index of the parameter.