Module: Datadog::Core::Telemetry::Logging::DatadogStackTrace

Defined in:
lib/datadog/core/telemetry/logging.rb

Overview

Extract datadog stack trace from the exception

Constant Summary collapse

GEM_ROOT =
Pathname.new("#{__dir__}/../../../..").cleanpath.to_s

Class Method Summary collapse

Class Method Details

.from(exception) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/datadog/core/telemetry/logging.rb', line 28

def self.from(exception)
  backtrace = exception.backtrace

  return unless backtrace
  return if backtrace.empty?

  # vendored deps
  vendored_deps = Gem.path.any? { |p| p.start_with?(GEM_ROOT) }

  backtrace.map do |line|
    if !vendored_deps && line.start_with?(GEM_ROOT) ||
        vendored_deps && line.start_with?(GEM_ROOT) && Gem.path.none? { |p| line.start_with?(p) }
      line[GEM_ROOT.length..-1] || ''
    else
      'REDACTED'
    end
  end.join(',')
end