|
|
|
@ -3,12 +3,13 @@ |
|
|
|
################################# |
|
|
|
################################# |
|
|
|
|
|
|
|
|
|
|
|
mutable struct ProcessCollector <: Collector |
|
|
|
mutable struct ProcessCollector <: Collector |
|
|
|
@const pid_f::Function |
|
|
|
@const pid::Function |
|
|
|
@const system_boot_time::Int |
|
|
|
@const system_boot_time::Int |
|
|
|
@const clock_ticks_per_second::Int |
|
|
|
@const clock_ticks_per_second::Int |
|
|
|
@const pagesize::Int |
|
|
|
@const pagesize::Int |
|
|
|
function ProcessCollector( |
|
|
|
function ProcessCollector( |
|
|
|
registry::Union{CollectorRegistry, Nothing}, pid_f::Function = () -> "self", |
|
|
|
pid::Function = () -> "self"; |
|
|
|
|
|
|
|
registry::Union{CollectorRegistry, Nothing}=DEFAULT_REGISTRY, |
|
|
|
) |
|
|
|
) |
|
|
|
# Read boot time as a way to check if /proc is available and readable |
|
|
|
# Read boot time as a way to check if /proc is available and readable |
|
|
|
system_boot_time = 0 |
|
|
|
system_boot_time = 0 |
|
|
|
@ -44,14 +45,13 @@ mutable struct ProcessCollector <: Collector |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
# Create the collector |
|
|
|
# Create the collector |
|
|
|
procc = new(pid_f, system_boot_time, clock_ticks_per_second, pagesize) |
|
|
|
procc = new(pid, system_boot_time, clock_ticks_per_second, pagesize) |
|
|
|
if registry !== nothing |
|
|
|
if registry !== nothing |
|
|
|
register(registry, procc) |
|
|
|
register(registry, procc) |
|
|
|
end |
|
|
|
end |
|
|
|
return procc |
|
|
|
return procc |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
ProcessCollector(pid_f::Function = () -> "self") = ProcessCollector(DEFAULT_REGISTRY, pid_f) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function metric_names(::ProcessCollector) |
|
|
|
function metric_names(::ProcessCollector) |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
@ -68,7 +68,7 @@ function collect!(metrics::Vector, procc::ProcessCollector) |
|
|
|
procc.system_boot_time == 0 && return metrics |
|
|
|
procc.system_boot_time == 0 && return metrics |
|
|
|
# Fetch the pid |
|
|
|
# Fetch the pid |
|
|
|
pid = try |
|
|
|
pid = try |
|
|
|
strip(string(procc.pid_f())) |
|
|
|
String(strip(string(procc.pid()::Union{AbstractString,Integer})))::String |
|
|
|
catch e |
|
|
|
catch e |
|
|
|
@error "ProcessCollector: could not look up the pid from the lambda" e |
|
|
|
@error "ProcessCollector: could not look up the pid from the lambda" e |
|
|
|
return metrics |
|
|
|
return metrics |
|
|
|
|