Module: Datadog::Runtime::Cgroup
- Defined in:
- lib/ddtrace/runtime/cgroup.rb
Overview
For control groups
Defined Under Namespace
Classes: Descriptor
Constant Summary collapse
- LINE_REGEX =
/^(\d+):([^:]*):(.+)$/
Class Method Summary collapse
Class Method Details
.descriptors(process = 'self') ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ddtrace/runtime/cgroup.rb', line 18 def descriptors(process = 'self') [].tap do |descriptors| begin filepath = "/proc/#{process}/cgroup" if File.exist?(filepath) File.open("/proc/#{process}/cgroup").each do |line| line = line.strip descriptors << parse(line) unless line.empty? end end rescue StandardError => e Datadog::Tracer.log.error("Error while parsing cgroup. Cause: #{e.} Location: #{e.backtrace.first}") end end end |
.parse(line) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/ddtrace/runtime/cgroup.rb', line 35 def parse(line) id, groups, path = line.scan(LINE_REGEX).first Descriptor.new(id, groups, path).tap do |descriptor| descriptor.controllers = groups.split(',') unless groups.nil? end end |