From e8ee11853b597a5ff64c8cf5580b650557f74143 Mon Sep 17 00:00:00 2001 From: Nikita Mathur Date: Thu, 25 Jul 2024 21:43:08 +0530 Subject: [PATCH] Telemetry log messages improved for clarity of calls (#7104) Signed-off-by: Nik08 --- lib/inspec/utils/telemetry.rb | 5 ++--- lib/inspec/utils/telemetry/base.rb | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/inspec/utils/telemetry.rb b/lib/inspec/utils/telemetry.rb index c22d927c6..4e1632f03 100644 --- a/lib/inspec/utils/telemetry.rb +++ b/lib/inspec/utils/telemetry.rb @@ -23,6 +23,7 @@ module Inspec Inspec::Telemetry::RunContextProbe.under_automate? || license&.license_type&.downcase == "commercial" + Inspec::Log.debug "Determined telemetry operation is not applicable and hence aborting it." return Inspec::Telemetry::Null end @@ -37,7 +38,7 @@ module Inspec end def self.license - Inspec::Log.debug "Fetching license context for telemetry" + Inspec::Log.debug "Fetching license context for telemetry check" @license = ChefLicensing.license_context end @@ -45,7 +46,6 @@ module Inspec # These class methods make it convenient to call from anywhere within the InSpec codebase. ###### def self.run_starting(opts) - Inspec::Log.debug "Initiating telemetry for InSpec" @@config ||= opts[:conf] instance.run_starting(opts) rescue StandardError => e @@ -55,7 +55,6 @@ module Inspec def self.run_ending(opts) @@config ||= opts[:conf] instance.run_ending(opts) - Inspec::Log.debug "Finishing telemetry for InSpec" rescue StandardError => e Inspec::Log.debug "Encountered error in Telemetry end run call -> #{e.message}" end diff --git a/lib/inspec/utils/telemetry/base.rb b/lib/inspec/utils/telemetry/base.rb index ded362fe4..f6ddcb28b 100644 --- a/lib/inspec/utils/telemetry/base.rb +++ b/lib/inspec/utils/telemetry/base.rb @@ -36,6 +36,7 @@ module Inspec end def run_starting(_opts = {}) + Inspec::Log.debug "Initiating telemetry for InSpec" @scratch ||= {} @scratch[:features] ||= [] @scratch[:run_start_time] = Time.now.getutc.iso8601 @@ -103,6 +104,7 @@ module Inspec end Inspec::Log.debug "Final data for telemetry upload -> #{payload}" + Inspec::Log.debug "Finishing telemetry for InSpec" # Return payload object for testing payload end