From bb8c98053434e5aa0de09b0a2a0fbe35e69542f3 Mon Sep 17 00:00:00 2001 From: drebs Date: Tue, 17 Oct 2017 02:21:23 -0200 Subject: Add benchmark status to dashboard. A "benchmarks" widget is added, together with a update job. The job queries the benchmarks.leap.se website and shows current benchmarking status and outliers. It's a simple start for something that can get more complex depending on identified needs. --- dashboards/dashboard.erb | 6 ++++-- jobs/update_benchmark.rb | 16 ++++++++++++++++ widgets/benchmarks/benchmarks.coffee | 15 +++++++++++++++ widgets/benchmarks/benchmarks.html | 23 +++++++++++++++++++++++ widgets/benchmarks/benchmarks.scss | 13 +++++++++++++ 5 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 jobs/update_benchmark.rb create mode 100644 widgets/benchmarks/benchmarks.coffee create mode 100644 widgets/benchmarks/benchmarks.html create mode 100644 widgets/benchmarks/benchmarks.scss diff --git a/dashboards/dashboard.erb b/dashboards/dashboard.erb index 619d594..baa57d9 100644 --- a/dashboards/dashboard.erb +++ b/dashboards/dashboard.erb @@ -1,7 +1,6 @@ -
  • +
  • -
  • @@ -9,6 +8,9 @@
    +
  • +
    +
  • diff --git a/jobs/update_benchmark.rb b/jobs/update_benchmark.rb new file mode 100644 index 0000000..8e98db3 --- /dev/null +++ b/jobs/update_benchmark.rb @@ -0,0 +1,16 @@ +require "json" +require "net/http" +require "uri" + +outliers_uri = URI.parse("https://benchmarks.leap.se/outliers.json") +is_benchmarked_uri = URI.parse("https://benchmarks.leap.se/is-benchmarked.html") + +SCHEDULER.every '5m', :first_in => 0 do |job| + response = Net::HTTP.get(outliers_uri) + outliers = JSON.parse(response) + + response = Net::HTTP.get(is_benchmarked_uri) + benchmarked = response.gsub /<[^>]+>/, '' + + send_event('benchmarks', { "good": outliers["good"].length, "bad": outliers["bad"].length, "is-benchmarked-status": benchmarked}) +end diff --git a/widgets/benchmarks/benchmarks.coffee b/widgets/benchmarks/benchmarks.coffee new file mode 100644 index 0000000..1d47b7c --- /dev/null +++ b/widgets/benchmarks/benchmarks.coffee @@ -0,0 +1,15 @@ +class Dashing.Benchmarks extends Dashing.Widget + + ready: -> + # This is fired when the widget is done being rendered + + onData: (data) -> + # Handle incoming data + # You can access the html node of this widget with `@node` + # Example: $(@node).fadeOut().fadeIn() will make the node flash each time data comes in. + + @accessor 'hasBadOutliers', -> + @get('bad') > 0 + + @accessor 'hasGoodOutliers', -> + @get('good') > 0 diff --git a/widgets/benchmarks/benchmarks.html b/widgets/benchmarks/benchmarks.html new file mode 100644 index 0000000..d7dda1c --- /dev/null +++ b/widgets/benchmarks/benchmarks.html @@ -0,0 +1,23 @@ +

    + +

     

    + +

    Current Status

    + +

    + + + +

    + +

     

    + +

    Recent Outliers

    + +

    + + / + +

    + +

    diff --git a/widgets/benchmarks/benchmarks.scss b/widgets/benchmarks/benchmarks.scss new file mode 100644 index 0000000..7acfe24 --- /dev/null +++ b/widgets/benchmarks/benchmarks.scss @@ -0,0 +1,13 @@ +.widget-benchmarks { + background-color: black; +} + +.good { + color: green; + font-weight: bold; +} + +.bad { + color: #d93c38; + font-weight: bold; +} -- cgit v1.2.3