module Skylight::Core::Instrumentable::ClassMethods
Public Instance Methods
broken!()
click to toggle source
# File lib/skylight/core/instrumentable.rb, line 178 def broken! return unless instrumenter instrumenter.broken! end
config()
click to toggle source
# File lib/skylight/core/instrumentable.rb, line 193 def config return unless instrumenter instrumenter.config end
correlation_header()
click to toggle source
# File lib/skylight/core/instrumentable.rb, line 26 def correlation_header nil end
disable() { || ... }
click to toggle source
Temporarily disable
# File lib/skylight/core/instrumentable.rb, line 184 def disable unless instrumenter return yield if block_given? return end instrumenter.disable { yield } end
done(span, meta = nil)
click to toggle source
End a span
# File lib/skylight/core/instrumentable.rb, line 173 def done(span, meta = nil) return unless instrumenter instrumenter.done(span, meta) end
enable_normalizer(*names)
click to toggle source
# File lib/skylight/core/instrumentable.rb, line 34 def enable_normalizer(*names) Skylight::Core::Normalizers.enable(*names) end
instrument(opts = DEFAULT_OPTIONS) { || ... }
click to toggle source
Instrument
# File lib/skylight/core/instrumentable.rb, line 117 def instrument(opts = DEFAULT_OPTIONS, &block) unless instrumenter return yield if block_given? return end if opts.is_a?(Hash) category = opts[:category] || DEFAULT_CATEGORY title = opts[:title] desc = opts[:description] meta = opts[:meta] if opts.key?(:annotations) warn "call to #instrument included deprecated annotations" end else category = DEFAULT_CATEGORY title = opts.to_s desc = nil meta = nil end instrumenter.instrument(category, title, desc, meta, &block) end
instrumenter()
click to toggle source
# File lib/skylight/core/instrumentable.rb, line 22 def instrumenter defined?(@instrumenter) && @instrumenter end
instrumenter_class()
click to toggle source
# File lib/skylight/core/instrumentable.rb, line 18 def instrumenter_class Skylight::Core::Instrumenter end
mute() { || ... }
click to toggle source
# File lib/skylight/core/instrumentable.rb, line 141 def mute unless instrumenter return yield if block_given? return end instrumenter.mute do yield if block_given? end end
muted?()
click to toggle source
# File lib/skylight/core/instrumentable.rb, line 163 def muted? instrumenter&.muted? end
probe(*args)
click to toggle source
# File lib/skylight/core/instrumentable.rb, line 30 def probe(*args) Skylight::Core::Probes.probe(*args) end
span_correlation_header(span)
click to toggle source
# File lib/skylight/core/instrumentable.rb, line 167 def span_correlation_header(span) return unless instrumenter instrumenter.span_correlation_header(span) end
spawn_shutdown_thread!()
click to toggle source
Runs the shutdown procedure in the background. This should do little more than unsubscribe from all ActiveSupport::Notifications
# File lib/skylight/core/instrumentable.rb, line 200 def spawn_shutdown_thread! @shutdown_thread || const_get(:LOCK).synchronize do @shutdown_thread ||= Thread.new { @instrumenter&.shutdown } end end
start!(config = nil)
click to toggle source
Start instrumenting
# File lib/skylight/core/instrumentable.rb, line 39 def start!(config = nil) return instrumenter if instrumenter const_get(:LOCK).synchronize do return instrumenter if instrumenter config ||= {} config = config_class.load(config) unless config.is_a?(config_class) @instrumenter = instrumenter_class.new(config).start! end rescue => e level, message = if e.is_a?(ConfigError) [:warn, format("Unable to start Instrumenter due to a configuration error: %<message>s", message: e.message)] else [:error, format("Unable to start Instrumenter; msg=%<message>s; class=%<klass>s", message: e.message, klass: e.class)] end if config && config.respond_to?("log_#{level}") && config.respond_to?(:log_trace) config.send("log_#{level}", message) config.log_trace e.backtrace.join("\n") else warn "[#{name.upcase}] #{message}" end false end
started?()
click to toggle source
# File lib/skylight/core/instrumentable.rb, line 69 def started? !!instrumenter end
stop!()
click to toggle source
Stop instrumenting
# File lib/skylight/core/instrumentable.rb, line 74 def stop! t { "stop!" } const_get(:LOCK).synchronize do t { "stop! synchronized" } return unless instrumenter # This is only really helpful for getting specs to pass. @instrumenter.current_trace = nil @instrumenter.shutdown @instrumenter = nil end end
trace(endpoint = nil, cat = nil, title = nil, meta: nil, segment: nil, component: nil) { || ... }
click to toggle source
Start a trace
# File lib/skylight/core/instrumentable.rb, line 95 def trace(endpoint = nil, cat = nil, title = nil, meta: nil, segment: nil, component: nil) unless instrumenter return yield if block_given? return end if instrumenter.poisoned? spawn_shutdown_thread! return yield if block_given? return end cat ||= DEFAULT_CATEGORY if block_given? instrumenter.trace(endpoint, cat, title, nil, meta: meta, segment: segment, component: component) { |tr| yield tr } else instrumenter.trace(endpoint, cat, title, nil, meta: meta, segment: segment, component: component) end end
tracing?()
click to toggle source
Check tracing
# File lib/skylight/core/instrumentable.rb, line 89 def tracing? t { "checking tracing?; thread=#{Thread.current.object_id}" } instrumenter && instrumenter.current_trace end
unmute() { || ... }
click to toggle source
# File lib/skylight/core/instrumentable.rb, line 152 def unmute unless instrumenter return yield if block_given? return end instrumenter.unmute do yield if block_given? end end