Sha256: cf4a7caf18b40c7df8bcf0c46daeaf02848d20c8f21eb46b43f83ee0a8e72ea2
Contents?: true
Size: 1.07 KB
Versions: 10
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::Tracer.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
10 entries across 10 versions & 2 rubygems