Sha256: 977decaf013ddc02e85e02205d2c306d144de8cdc79f07c668f3d357f10d8008
Contents?: true
Size: 1.57 KB
Versions: 9
Compression:
Stored size: 1.57 KB
Contents
# frozen_string_literal: true module Datadog module Kit # This helper is used to enable core dumps for the current Ruby app. This is useful when debugging native-level # crashes. # # It can be enabled simply by adding `require 'datadog/kit/enable_core_dumps'` to start of the app. module EnableCoreDumps def self.call current_size, maximum_size = Process.getrlimit(:CORE) core_pattern = begin File.read('/proc/sys/kernel/core_pattern').strip rescue '(Could not open /proc/sys/kernel/core_pattern)' end enabled_status = "Maximum size: #{maximum_size} Output pattern: '#{core_pattern}'" if maximum_size <= 0 Kernel.warn("[ddtrace] Could not enable core dumps on crash, maximum size is #{maximum_size} (disabled).") return elsif maximum_size == current_size Kernel.warn("[ddtrace] Core dumps already enabled, nothing to do. #{enabled_status}") return end begin Process.setrlimit(:CORE, maximum_size) rescue => e Kernel.warn( "[ddtrace] Failed to enable core dumps. Cause: #{e.class.name} #{e.message} " \ "Location: #{Array(e.backtrace).first}" ) return end if current_size == 0 Kernel.warn("[ddtrace] Enabled core dumps. #{enabled_status}") else Kernel.warn("[ddtrace] Raised core dump limit. Old size: #{current_size} #{enabled_status}") end end end end end Datadog::Kit::EnableCoreDumps.call
Version data entries
9 entries across 9 versions & 1 rubygems