diff --git a/docs/src/index.md b/docs/src/index.md index d03880b..2e6a1e4 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -131,6 +131,15 @@ A collector that exports metrics about allocations and garbage collection (for e number of allocations, number of bytes allocated, time spent in garbage collection, etc). These metrics have the `gc_` prefix in their name. +A `GCCollector` is registered automatically with the default registry, see +[Default registry](@ref) for more details. + +#### GCCollector API reference + +```@docs +Prometheus.GCCollector(; kwargs...) +``` + ### ProcessCollector A collector that exports metrics about a running process, for example CPU seconds and diff --git a/src/gc_collector.jl b/src/gc_collector.jl index aa3dda5..f2edbba 100644 --- a/src/gc_collector.jl +++ b/src/gc_collector.jl @@ -12,6 +12,25 @@ mutable struct GCCollector <: Collector end end +""" + Prometheus.GCCollector(; registry=DEFAULT_REGISTRY) + +Create a collector that exports metrics about allocations and garbage collection. + +**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 `GCCollector` is registered automatically with the default registry. + If necessary it can be removed by calling + ```julia + Prometheus.unregister(Prometheus.DEFAULT_REGISTRY, Prometheus.GC_COLLECTOR) + ``` +""" +GCCollector(; kwargs...) + function metric_names(::GCCollector) return ( "gc_alloc_total", "gc_free_total", "gc_alloc_bytes_total",