Module: Skylight::Core::Instrumentable::ClassMethods
- Defined in:
- lib/skylight/core/instrumentable.rb
Instance Method Summary collapse
- #broken! ⇒ Object
- #config ⇒ Object
- #correlation_header ⇒ Object
-
#disable ⇒ Object
Temporarily disable.
-
#done(span, meta = nil) ⇒ Object
End a span.
- #enable_normalizer(*names) ⇒ Object
-
#instrument(opts = DEFAULT_OPTIONS, &block) ⇒ Object
Instrument.
- #instrumenter ⇒ Object
- #instrumenter_class ⇒ Object
- #probe(*args) ⇒ Object
- #span_correlation_header(span) ⇒ Object
-
#start!(config = nil) ⇒ Object
Start instrumenting.
-
#stop! ⇒ Object
Stop instrumenting.
-
#trace(endpoint = nil, cat = nil, title = nil, meta = nil) ⇒ Object
Start a trace.
-
#tracing? ⇒ Boolean
Check tracing.
Instance Method Details
#broken! ⇒ Object
139 140 141 142 |
# File 'lib/skylight/core/instrumentable.rb', line 139 def broken! return unless instrumenter instrumenter.broken! end |
#config ⇒ Object
154 155 156 157 |
# File 'lib/skylight/core/instrumentable.rb', line 154 def config return unless instrumenter instrumenter.config end |
#correlation_header ⇒ Object
28 29 30 |
# File 'lib/skylight/core/instrumentable.rb', line 28 def correlation_header nil end |
#disable ⇒ Object
Temporarily disable
145 146 147 148 149 150 151 152 |
# File 'lib/skylight/core/instrumentable.rb', line 145 def disable unless instrumenter return yield if block_given? return end instrumenter.disable { yield } end |
#done(span, meta = nil) ⇒ Object
End a span
134 135 136 137 |
# File 'lib/skylight/core/instrumentable.rb', line 134 def done(span, =nil) return unless instrumenter instrumenter.done(span, ) end |
#enable_normalizer(*names) ⇒ Object
36 37 38 |
# File 'lib/skylight/core/instrumentable.rb', line 36 def enable_normalizer(*names) Skylight::Core::Normalizers.enable(*names) end |
#instrument(opts = DEFAULT_OPTIONS, &block) ⇒ Object
Instrument
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/skylight/core/instrumentable.rb', line 104 def instrument(opts = DEFAULT_OPTIONS, &block) unless instrumenter return yield if block_given? return end if Hash === opts category = opts[:category] || DEFAULT_CATEGORY title = opts[:title] desc = opts[:description] = opts[:meta] if opts.key?(:annotations) warn "call to #instrument included deprecated annotations" end else category = DEFAULT_CATEGORY title = opts.to_s desc = nil = nil end instrumenter.instrument(category, title, desc, , &block) end |
#instrumenter ⇒ Object
24 25 26 |
# File 'lib/skylight/core/instrumentable.rb', line 24 def instrumenter @instrumenter end |
#instrumenter_class ⇒ Object
20 21 22 |
# File 'lib/skylight/core/instrumentable.rb', line 20 def instrumenter_class Skylight::Core::Instrumenter end |
#probe(*args) ⇒ Object
32 33 34 |
# File 'lib/skylight/core/instrumentable.rb', line 32 def probe(*args) Skylight::Core::Probes.probe(*args) end |
#span_correlation_header(span) ⇒ Object
128 129 130 131 |
# File 'lib/skylight/core/instrumentable.rb', line 128 def span_correlation_header(span) return unless instrumenter instrumenter.span_correlation_header(span) end |
#start!(config = nil) ⇒ Object
Start instrumenting
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/skylight/core/instrumentable.rb', line 41 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, = if e.is_a? ConfigError [:warn, sprintf("Unable to start Instrumenter due to a configuration error: %s", e.)] else [:error, sprintf("Unable to start Instrumenter; msg=%s; class=%s", e., e.class)] end if config && config.respond_to?("log_#{level}") && config.respond_to?(:log_trace) config.send("log_#{level}", ) config.log_trace e.backtrace.join("\n") else warn "[#{name.upcase}] #{}" end false end |
#stop! ⇒ Object
Stop instrumenting
69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/skylight/core/instrumentable.rb', line 69 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) ⇒ Object
Start a trace
90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/skylight/core/instrumentable.rb', line 90 def trace(endpoint=nil, cat=nil, title=nil, =nil) unless instrumenter return yield if block_given? return end if block_given? instrumenter.trace(endpoint, cat || DEFAULT_CATEGORY, title, nil, ) { yield } else instrumenter.trace(endpoint, cat || DEFAULT_CATEGORY, title, nil, ) end end |
#tracing? ⇒ Boolean
Check tracing
84 85 86 87 |
# File 'lib/skylight/core/instrumentable.rb', line 84 def tracing? t { "checking tracing?; thread=#{Thread.current.object_id}"} instrumenter && instrumenter.current_trace end |