src/main/java/com/github/gquintana/metrics/util/SqlObjectNameFactory.java
@Override
    public ObjectName createName(String type, String domain, String name) {
        Matcher matcher = PATTERN.matcher(name);
        ObjectName objectName = null;
        if (matcher.matches()) {
            String className = matcher.group(1);
            String database  = matcher.group(2);
            String sql       = matcher.group(3);
            String event     = matcher.group(4);
            Hashtable<String, String> props = new Hashtable<>();
            props.put("class", className);
            props.put("database", database);
            if (sql!=null) {
                // , and \ are not allowed
                props.put("sql", sql.replaceAll("[:=*?,\\n\\\\]", " ").replaceAll("[\\s]+", " "));
            }
            if (event!=null) {
                props.put("event", event);
            }
            if (type!=null) {
                props.put("metricType", type);
            }
            try {
                objectName = new ObjectName(domain, props);
            } catch (MalformedObjectNameException malformedObjectNameException) {
            }
        } 
        if (objectName == null) {
            objectName = defaultObjectFactory.createName(type, domain, name);
        }
        return objectName;
    }
@Override
    public ObjectName createName(String type, String domain, String name) {
        Matcher matcher = PATTERN.matcher(name);
        ObjectName objectName = null;
        if (matcher.matches()) {
            String className = matcher.group(1);
            String database  = matcher.group(2);
            String sql       = matcher.group(3);
            String event     = matcher.group(4);
            Hashtable<String, String> props = new Hashtable<>();
            props.put("class", className);
            props.put("database", database);
            if (sql!=null) {
                // , and \ are not allowed
                props.put("sql", sql.replaceAll("[:=*?,\\n\\\\]", " ").replaceAll("[\\s]+", " "));
            }
            if (event!=null) {
                props.put("event", event);
            }
            if (type!=null) {
                props.put("metricType", type);
            }
            try {
                objectName = new ObjectName(domain, props);
            } catch (MalformedObjectNameException malformedObjectNameException) {
            }
        } 
        if (objectName == null) {
            objectName = defaultObjectFactory.createName(type, domain, name);
        }
        return objectName;
    }
@ Override public ObjectName createName ( String type , String domain , String name ) { Matcher matcher = PATTERN . matcher ( name ) ; ObjectName objectName = null ; if ( matcher . matches ( ) ) { String className = matcher . group ( 1 ) ; String database = matcher . group ( 2 ) ; String sql = matcher . group ( 3 ) ; String event = matcher . group ( 4 ) ; Hashtable < String , String > props = new Hashtable <> ( ) ; props . put ( "class" , className ) ; props . put ( "database" , database ) ; if ( sql != null ) { // , and \ are not allowed props . put ( "sql" , sql . replaceAll ( "[:=*?,\\n\\\\]" , " " ) . replaceAll ( "[\\s]+" , " " ) ) ; } if ( event != null ) { props . put ( "event" , event ) ; } if ( type != null ) { props . put ( "metricType" , type ) ; } try { objectName = new ObjectName ( domain , props ) ; } catch ( MalformedObjectNameException malformedObjectNameException ) { } } if ( objectName == null ) { objectName = defaultObjectFactory . createName ( type , domain , name ) ; } return objectName ; }
Event
Event