Browse Source

ProcessCollector: add docstring and documentation.

pull/6/head
Fredrik Ekre 2 years ago
parent
commit
5c0103d327
  1. 13
      docs/src/index.md
  2. 28
      src/process_collector.jl

13
docs/src/index.md

@ -11,7 +11,7 @@ Two of the basic concepts of a Prometheus client are [Registries](@ref) and @@ -11,7 +11,7 @@ Two of the basic concepts of a Prometheus client are [Registries](@ref) and
[Collectors](@ref). Registries are collections of collectors, and the collectors are the
units responsible to record and capture metrics. Client libraries implement a default
registry which all collectors implicity register with, so for basic usage there is no need
to interact with a registry (see [Default collector registry](@ref)).
to interact with a registry (see [Default registry](@ref)).
The third important concept is [Exposition](@ref) of the collected metrics. Typically
metrics are exposed over a HTTP server, as in the [Quickstart](@ref)-example just below. See
@ -138,6 +138,15 @@ metrics about I/O operations. Metrics from this collector have the `process_` pr @@ -138,6 +138,15 @@ metrics about I/O operations. Metrics from this collector have the `process_` pr
their name. This collector is only available on Linux since it requires the `/proc` file
system.
A `ProcessCollector` for the current process is registered automatically with the
default registry, see [Default registry](@ref) for more details.
#### ProcessCollector API reference
```@docs
Prometheus.ProcessCollector(::Function; kwargs...)
```
### Custom collectors
RandomCollector
@ -168,7 +177,7 @@ Supported methods: @@ -168,7 +177,7 @@ Supported methods:
## Registries
### Default collector registry
### Default registry
## Exposition

28
src/process_collector.jl

@ -53,6 +53,34 @@ mutable struct ProcessCollector <: Collector @@ -53,6 +53,34 @@ mutable struct ProcessCollector <: Collector
end
end
"""
Prometheus.ProcessCollector(pid; registry=DEFAULT_REGISTRY)
Create a process collector for the process id given by the `pid` function. The collector
exposes metrics about the process' CPU time, start time, memory usage, file usage, and I/O
operations.
**Arguments**
- `pid :: Function`: a function returning a process id as a string or integer for which to
collect metrics. By default the `"self"` pid is used, i.e. the current process.
**Keyword arguments**
- `registry :: Prometheus.CollectorRegistry`: the registry in which to register the
collector. The default registry is used by default. Pass `registry = nothing` to skip
registration.
!!! note
A `ProcessCollector` for the current process is registered automatically with the
default registry. If necessary it can be removed by calling
```julia
Prometheus.unregister(Prometheus.DEFAULT_REGISTRY, Prometheus.PROCESS_COLLECTOR)
```
!!! note
The process collector is currently only available on Linux since it requires the `/proc`
file system. On Windows and macOS this collector will not expose any metrics.
"""
ProcessCollector(::Function; kwargs...)
function metric_names(::ProcessCollector)
return (
"process_cpu_seconds_total", "process_start_time_seconds",

Loading…
Cancel
Save