lib/skylight/instrumenter.rb in skylight-5.3.5 vs lib/skylight/instrumenter.rb in skylight-6.0.0.beta

- old
+ new

@@ -29,11 +29,20 @@ # flag on and off directly. def muted=(val) Thread.current[@muted_key] = val end - def muted? + def muted + Thread.current[@muted_key] + end + + def tracing_muted? + Thread.current[@muted_key] == :all + end + + def endpoint_assignment_muted? + # all truthy values will mute endpoint assignment. !!Thread.current[@muted_key] end end attr_reader :uuid, :config, :gc, :extensions, :subscriber @@ -118,24 +127,36 @@ def muted=(val) @trace_info.muted = val end - def muted? - @trace_info.muted? + def muted + @trace_info.muted end - def mute - old_muted = muted? - self.muted = true + def tracing_muted? + muted == :all || muted == true + end + + def endpoint_assignment_muted? + tracing_muted? || muted == :endpoint_assignment + end + + # possible values: + # ignore: :all + # ignore: :endpoint_assignment + # ignore: false | nil + def mute(ignore: :all) + old_muted = muted + self.muted = ignore yield if block_given? ensure self.muted = old_muted end def unmute - old_muted = muted? + old_muted = muted self.muted = false yield if block_given? ensure self.muted = old_muted end @@ -149,11 +170,11 @@ def warnings_silenced?(context) @warnings_silenced && @warnings_silenced[context] end alias disable mute - alias disabled? muted? + alias disabled? tracing_muted? def start! # We do this here since we can't report these issues via Gem install without stopping install entirely. return unless validate_installation @@ -230,10 +251,10 @@ end def instrument(cat, title = nil, desc = nil, meta = nil) raise ArgumentError, "cat is required" unless cat - if muted? + if tracing_muted? return yield if block_given? return end