Sha256: 3b491704ce70d58bc8d0e8de14d44d4b325f5eec756efcfd1ea94836a49b637b
Contents?: true
Size: 1.07 KB
Versions: 8
Compression:
Stored size: 1.07 KB
Contents
require 'ddtrace/ext/runtime' module Datadog module Runtime # For control groups module Cgroup LINE_REGEX = /^(\d+):([^:]*):(.+)$/ Descriptor = Struct.new( :id, :groups, :path, :controllers ) module_function 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::Logger.log.error("Error while parsing cgroup. Cause: #{e.message} Location: #{e.backtrace.first}") end end end 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 end end end
Version data entries
8 entries across 8 versions & 1 rubygems