From a865e6bd2f225ce95fa41622ec44dfcfccad08b4 Mon Sep 17 00:00:00 2001 From: Spencer McElmurry Date: Mon, 9 Jul 2018 16:22:49 -0700 Subject: [PATCH] (POOLER-34) Ship clone request to ready time to metrics (#277) * (POOLER-34) Ship clone request to ready time to metrics Before, we were already capturing this metric but we failed to ship it anywhere. This ships the appropriate metric as `time_to_ready_state` Dashboards can be found in grafana. * Add spec test to ensure metric is being shipped properly on move_pending_vm_to_ready call. --- lib/vmpooler/pool_manager.rb | 2 +- spec/unit/pool_manager_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/vmpooler/pool_manager.rb b/lib/vmpooler/pool_manager.rb index 06a5ebb..15e2dfb 100644 --- a/lib/vmpooler/pool_manager.rb +++ b/lib/vmpooler/pool_manager.rb @@ -102,7 +102,7 @@ module Vmpooler # last boot time is displayed in API, and used by alarming script $redis.hset('vmpooler__lastboot', pool, Time.now) - + $metrics.timing("time_to_ready_state.#{pool}", finish) $logger.log('s', "[>] [#{pool}] '#{vm}' moved from 'pending' to 'ready' queue") end end diff --git a/spec/unit/pool_manager_spec.rb b/spec/unit/pool_manager_spec.rb index 513e015..97196f0 100644 --- a/spec/unit/pool_manager_spec.rb +++ b/spec/unit/pool_manager_spec.rb @@ -217,6 +217,14 @@ EOT subject.move_pending_vm_to_ready(vm, pool, host) end + it 'should receive time_to_ready_state metric' do + redis.hset("vmpooler__vm__#{vm}", 'clone',Time.now.to_s) + expect(metrics).to receive(:timing).with(/time_to_ready_state\./,/0/) + + subject.move_pending_vm_to_ready(vm, pool, host) + end + + it 'should set the boot time in redis' do redis.hset("vmpooler__vm__#{vm}", 'clone',Time.now.to_s) expect(redis.hget('vmpooler__boot__' + Date.today.to_s, pool + ':' + vm)).to be_nil