metron-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JonZeolla <...@git.apache.org>
Subject [GitHub] metron pull request #873: METRON-1367 Stellar should have some instrumentati...
Date Mon, 18 Dec 2017 00:30:58 GMT
Github user JonZeolla commented on a diff in the pull request:

    https://github.com/apache/metron/pull/873#discussion_r157385625
  
    --- Diff: metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/common/shell/StellarExecutor.java
---
    @@ -289,7 +293,25 @@ public Object execute(String expression) {
         VariableResolver variableResolver = new MapVariableResolver(Maps.transformValues(variables,
result -> result.getResult())
                                                                    , Collections.emptyMap());
         StellarProcessor processor = new StellarProcessor();
    -    return processor.parse(expression, variableResolver, functionResolver, context);
    +    StackWatch watch = new StackWatch("execute");
    +    watch.startTime(expression);
    +    context.setWatch(watch);
    +    try {
    +      return processor.parse(expression, variableResolver, functionResolver, context);
    +    } finally {
    +      watch.stopTime();
    +      final StringBuffer buff = new StringBuffer();
    +      watch.visit(((level, node) -> {
    +        for (int i = 0; i < level; i++) {
    +          buff.append("-");
    +        }
    +        buff.append("->");
    +        buff.append(node.getName()).append(" : ").append(node.getTime()).append("ms :
").
    +            append(node.getNanoTime()).append("ns").append("\n");
    +      }));
    +      lastTiming = Optional.of(buff.toString());
    +      context.clearWatch();
    +    }
    --- End diff --
    
    That makes sense, just looking to limit the effect here.


---

Mime
View raw message