File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
cookbooks/boxcutter_chef/files/config Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change 33
44module Boxcutter
55 class MetricsHandler < ::Chef ::Handler
6+ FORCE_METRICS_COLLECTOR = '/var/chef/chef-force-metrics-collector' . freeze
7+
68 def initialize ( path : '/var/chef/reports' , filename : 'chef-run-metrics.json' )
79 @path = path
810 @filename = filename
@@ -61,8 +63,24 @@ def write_metrics
6163 'updated_resources_count' => run_status . updated_resources . count ,
6264 }
6365
66+ if taste_tester? && !force_metrics_collector?
67+ Chef ::Log . info (
68+ 'boxcutter_chef: metrics_handler - In taste tester mode. Metrics collector not running.' +
69+ "To override, touch #{ FORCE_METRICS_COLLECTOR } " ,
70+ )
71+ return
72+ end
73+
6474 File . open ( metrics_path , 'w' ) { |f | f . write ( JSON . pretty_generate ( out ) ) }
65- Chef ::Log . info ( "wrote chef run metrics to #{ metrics_path } " )
75+ Chef ::Log . info ( "boxcutter_chef: metrics_hander - wrote chef run metrics to #{ metrics_path } " )
76+ end
77+
78+ def taste_tester?
79+ !Chef ::Config [ :chef_server_url ] . start_with? ( 'chefzero://' )
80+ end
81+
82+ def force_metrics_collector?
83+ File . exist? ( FORCE_METRICS_COLLECTOR )
6684 end
6785 end
6886end
You can’t perform that action at this time.
0 commit comments