<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <br>
    <font face="Calibri">Right, you may find what you need is already in
      place, or you may find that you can spend time on higher-level
      functions.  In particular, see:<br>
      <br>
    </font><tt>MetricsService:</tt><tt><br>
    </tt><tt>&lt;T&gt; Observable&lt;T&gt; findGaugeData(String
      tenantId, MetricId id, Long start, Long end,</tt><tt> </tt><tt>Func1&lt;Observable&lt;DataPoint&lt;Double&gt;&gt;,
      Observable&lt;T&gt;&gt;... funcs);</tt><tt><br>
    </tt><font face="Calibri"><br>
    </font><tt>Aggregate</tt><font face="Calibri">:<br>
      predefined functions.<br>
      <br>
      Here is an example snippen from 
      org.hawkular.alerts.external.metrics.Manager to gather multiple
      aggregates in one call and determine the range:<br>
      <br>
    </font><tt>                    case range: {</tt><br>
    <tt>                        Iterator&lt;Double&gt; iterator =
      metrics.findGaugeData(tenantId, metricId, start, end,</tt><br>
    <tt>                                Aggregate.Min, Aggregate.Max)</tt><br>
    <tt>                               
      .toBlocking().toIterable().iterator();</tt><br>
    <tt>                        Double min = iterator.next();</tt><br>
    <tt>                        Double max = iterator.next();</tt><br>
    <tt>                        value = max - min;</tt><br>
    <tt>                        break;</tt><br>
    <tt>                    }</tt><br>
    <font face="Calibri"><br>
      <br>
      -Jay<br>
    </font><br>
    <div class="moz-cite-prefix">On 7/21/2015 10:43 AM, John Sanda
      wrote:<br>
    </div>
    <blockquote
      cite="mid:B78A0D31-20D3-446F-8DE9-B538D76819A6@redhat.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      Keep the following in mind. Since the core metrics API is now
      built on RxJava, function params and return types should probably
      be rx.Observable. Some of the work described below may already be
      covered by the work Jay did for HWKMETRICS-144 which involved
      adding min/max/avg functions. To be honest, I think functions like
      min/max/avg are poor candidates for some of the changes being
      discussed because they are so simple. Here is our avg function,
      <div class=""><br class="">
      </div>
      <div class="">   
        Func1&lt;Observable&lt;DataPoint&lt;Double&gt;&gt;,
        Observable&lt;Double&gt;&gt; Average = data -&gt;
        <div class="">           
          MathObservable.averageDouble(data.map(DataPoint::getValue));</div>
        <div class=""><br class="">
        </div>
        <div class="">For other, more involved functions, I think we
          should look first at the core operators in Rx.Observable and
          then maybe consider custom operators[1].</div>
        <div class=""><br class="">
        </div>
        <div class="">[1] <a moz-do-not-send="true"
href="https://github.com/ReactiveX/RxJava/wiki/Implementing-Your-Own-Operators"
            class="">https://github.com/ReactiveX/RxJava/wiki/Implementing-Your-Own-Operators</a></div>
        <div class=""><br class="">
          <div>
            <blockquote type="cite" class="">
              <div class="">On Jul 21, 2015, at 5:43 AM, Thomas
                Segismont &lt;<a moz-do-not-send="true"
                  href="mailto:tsegismo@redhat.com" class="">tsegismo@redhat.com</a>&gt;
                wrote:</div>
              <br class="Apple-interchange-newline">
              <div class="">Hi,<br class="">
                <br class="">
                I have looked at Aakarsh's repo:<br class="">
                <a moz-do-not-send="true"
                  href="https://github.com/Akki5/hawkular_plugin/"
                  class="">https://github.com/Akki5/hawkular_plugin/</a><br
                  class="">
                <br class="">
                It's a good start with an interface describing a doubles
                to double <br class="">
                function, a classloader for implementation loading and a
                set of initial <br class="">
                implementations.<br class="">
                <br class="">
                In order to integrate this work into Metrics, I think we
                should follow <br class="">
                the following steps:<br class="">
                <br class="">
                =====<br class="">
                #1 Change the contract<br class="">
                <br class="">
                Doubles to double works great for avg/min/max/...
                functions on gauge <br class="">
                metrics. But we need to consider other metric types.<br
                  class="">
                <br class="">
                Also, the interface should not only accept data point
                values, but whole <br class="">
                data points. Because some functions need the timestamp
                to compute the <br class="">
                result. % of up availability is a good example.<br
                  class="">
                <br class="">
                And functions may return different types: Double, Long,
                AvailabilityType.<br class="">
                <br class="">
                #2 Update configuration options to let the user set a
                plugins directory<br class="">
                <br class="">
                Metrics doc needs will have to be updated.<br class="">
                <br class="">
                #3 Create a function repository for each metric type<br
                  class="">
                <br class="">
                We can build on JDK's service loader + Aakarsh's
                classloader implementation.<br class="">
                <br class="">
                #4 Add builtin aggregate functions<br class="">
                <br class="">
                Extract existing Metrics code (min, max, avg, % of up
                avail, downtime <br class="">
                duration) into builtin functions.<br class="">
                <br class="">
                #5 Document the process of implementing a pluggable
                function<br class="">
                <br class="">
                We need to think about function naming as well. Should
                we use a prefix <br class="">
                to identify a builtin function?<br class="">
                =====<br class="">
                <br class="">
                I will start another thread to discuss REST and Core API
                data query changes.<br class="">
                <br class="">
                Thoughts?<br class="">
                <br class="">
                Thanks,<br class="">
                Thomas<br class="">
                _______________________________________________<br
                  class="">
                hawkular-dev mailing list<br class="">
                <a class="moz-txt-link-abbreviated" href="mailto:hawkular-dev@lists.jboss.org">hawkular-dev@lists.jboss.org</a><br class="">
                <a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/hawkular-dev">https://lists.jboss.org/mailman/listinfo/hawkular-dev</a><br
                  class="">
              </div>
            </blockquote>
          </div>
          <br class="">
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
hawkular-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:hawkular-dev@lists.jboss.org">hawkular-dev@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/hawkular-dev">https://lists.jboss.org/mailman/listinfo/hawkular-dev</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>