Module: MetrixWire::Instrument::SourceLocation
- Defined in:
- lib/metrixwire/instrument/source_location.rb
Overview
Finds the nearest application caller frame (file.rb:42) for a span, so the dashboard can point at the line that issued a query / HTTP call. Skips the SDK's own frames and common vendor/stdlib paths. Best-effort — returns nil rather than throwing.
Constant Summary collapse
- SKIP =
%r{/metrixwire/|/gems/|/ruby/\d|/lib/ruby/|<internal:}.freeze
Class Method Summary collapse
Class Method Details
.nearest ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/metrixwire/instrument/source_location.rb', line 14 def nearest return nil unless MetrixWire.capture_source? caller_locations(2, 40)&.each do |loc| path = loc.absolute_path || loc.path next if path.nil? next if SKIP.match?(path) return "#{File.basename(path)}:#{loc.lineno}" end nil rescue StandardError nil end |