Annotation Type Part
-
@Target({}) public @interface Part
Specifies a single part of a transaction name.Part
is used in theClassTransaction.naming()
andMethodTransaction.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 parameters 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)}
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.String
getterChain
Specifies a getter chain that should be called on an object for name parts of the typesPart.Type.PARAMETER
andPart.Type.INSTANCE
.PackageMode
packageMode
Specifies the way packages names are converted to text for name parts of the typesPart.Type.CLASS
andPart.Type.INSTANCE_CLASS
.int
parameterIndex
Specifies the index of the desired parameter name for parts of typePart.Type.PARAMETER
.java.lang.String
text
Specifies the text for a name part of typePart.Type.TEXT
and a suffix for other part types.Part.Type
value
The type of the name part.
-
-
-
Element Detail
-
value
Part.Type value
The type of the name part. Different types require different parameters. Since the default type isPart.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)
- See Also:
Part.Type
- Default:
- com.perfino.annotation.Part.Type.TEXT
-
-
-
text
java.lang.String text
Specifies the text for a name part of typePart.Type.TEXT
and a suffix for other part types. For types other thanPart.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)})
- Default:
- ""
-
-
-
packageMode
PackageMode packageMode
Specifies the way packages names are converted to text for name parts of the typesPart.Type.CLASS
andPart.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.
- See Also:
PackageMode
- Default:
- com.perfino.annotation.PackageMode.NONE
-
-
-
getterChain
java.lang.String getterChain
Specifies a getter chain that should be called on an object for name parts of the typesPart.Type.PARAMETER
andPart.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 a single field, just specify the plain field name, e.g. "fieldName"
- For a single method call, just specify the method name with parentheses, e.g. "getterName()"
-
For a chain of method calls and field accesses, concatenate them with a dot, e.g.
"getterNameOne().field.getterNameTwo()"
.
For an invocation of
getClass()
, there are two special fields that are added by perfino to get the same result as for thePart.Type.CLASS
andPart.Type.INSTANCE_CLASS
naming parts with their differentpackage modes
:- With
getClass().simpleName
, the simple name of the class is added. For example,com.mycorp.MyClass
becomesMyClass
. -
With
getClass().abbrevName
, the abbreviated package names are added. For example,com.mycorp.MyClass
becomesc.m.MyClass
.
Exceptional circumstances:
-
If part of a getter chain operates on a primitive type (like an
int
value), the method will be called on the primitive wrapper class (likejava.lang.Integer
). -
If part of a getter chain operates on a
null
value, processing of the getter chain will stop and the value of the name part will be set to the string "null". -
If an exception occurs while a getter chain is evaluated, the name part will be set to the empty value.
The exception will not be logged unless you pass the system property
perfino.logUser=10
in the monitored VM. See the debug section in the package overview for more information on logging.
- Default:
- ""
-
-
-
parameterIndex
int parameterIndex
Specifies the index of the desired parameter name for parts of typePart.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.
- Default:
- 0
-
-