Package org.jmxtrans.embedded
Class ResultNameStrategy
java.lang.Object
org.jmxtrans.embedded.ResultNameStrategy
public class ResultNameStrategy extends Object
Build a QueryResult.name from a collected metric (QueryAttribute, Query).
Build name must be escaped to be compatible with all OutputWriter.
The approach is to escape non alpha-numeric chars.
Expressions support '#' based keywords (e.g.
#hostname#) and with '%' based variables mapped to objectname properties.
| Function | Description | Sample |
|---|---|---|
#hostname# |
localhost - hostname InetAddress.getHostName() |
TODO |
#reversed_hostname# |
reversed localhost - hostname InetAddress.getHostName() |
|
#escaped_hostname# |
localhost - hostname InetAddress.getHostName() with '.' replaced by '_' |
TODO |
#canonical_hostname# |
localhost - canonical hostname InetAddress.getCanonicalHostName() |
server1.ecommerce.mycompany.com |
#reversed_canonical_hostname# |
reversed localhost - canonical hostname InetAddress.getCanonicalHostName() |
com.mycompany.ecommerce.server1 |
#escaped_canonical_hostname# |
localhost - canonical hostname InetAddress.getCanonicalHostName() with '.' replaced by '_' |
server1_ecommerce_mycompany_com |
#hostaddress# |
localhost - hostaddress InetAddress.getHostAddress() |
TODO |
#escaped_hostname# |
localhost - hostaddress InetAddress.getHostAddress() with '.' replaced by '_' |
TODO |
- Author:
- Cyrille Le Clerc
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classResultNameStrategy.Builderstatic classResultNameStrategy.StaticEvaluator -
Field Summary
Fields Modifier and Type Field Description static StringREPLACE_DOTS_IN_OBJECT_NAME -
Constructor Summary
Constructors Constructor Description ResultNameStrategy() -
Method Summary
Modifier and Type Method Description protected StringBuilder_getResultName(Query query, ObjectName objectName, QueryAttribute queryAttribute)static ResultNameStrategy.Builderbuilder()protected StringescapeObjectName(ObjectName objectName)Transforms an ObjectName into a plain String only composed of (a-z, A-Z, '_').Map<String,Callable<String>>getExpressionEvaluators()StringgetResultName(Query query, ObjectName objectName, QueryAttribute queryAttribute)StringgetResultName(Query query, ObjectName objectName, QueryAttribute queryAttribute, String key)voidregisterExpressionEvaluator(String expression, String value)Registers an expression evaluator with a static value.voidregisterExpressionEvaluator(String expression, Callable<String> evaluator)Registers an expression evaluator with a static value.StringresolveExpression(String expression)Replace all the '#' based keywords (e.g.protected StringresolveExpression(String expression, ObjectName exactObjectName)
-
Field Details
-
REPLACE_DOTS_IN_OBJECT_NAME
- See Also:
- Constant Field Values
-
-
Constructor Details
-
ResultNameStrategy
public ResultNameStrategy()
-
-
Method Details
-
getResultName
-
getResultName
public String getResultName(Query query, ObjectName objectName, QueryAttribute queryAttribute, String key) -
_getResultName
protected StringBuilder _getResultName(Query query, ObjectName objectName, QueryAttribute queryAttribute) -
resolveExpression
Replace all the '#' based keywords (e.g.#hostname#) by their value.- Parameters:
expression- the expression to resolve (e.g."servers.#hostname#.")- Returns:
- the resolved expression (e.g.
"servers.tomcat5")
-
resolveExpression
-
escapeObjectName
Transforms an ObjectName into a plain String only composed of (a-z, A-Z, '_'). '_' is the escape char for not compliant chars. -
registerExpressionEvaluator
Registers an expression evaluator with a static value. -
registerExpressionEvaluator
Registers an expression evaluator with a static value. -
getExpressionEvaluators
-
builder
-