Browse Source

GCCollector: user keyword arguments for construction.

pull/6/head
Fredrik Ekre 2 years ago
parent
commit
2bb0c3aa06
  1. 2
      src/Prometheus.jl
  2. 2
      src/gc_collector.jl
  3. 2
      test/runtests.jl

2
src/Prometheus.jl

@ -630,7 +630,7 @@ include("process_collector.jl")
# Default registry and collectors # Default registry and collectors
const DEFAULT_REGISTRY = CollectorRegistry() const DEFAULT_REGISTRY = CollectorRegistry()
const GC_COLLECTOR = GCCollector(DEFAULT_REGISTRY) const GC_COLLECTOR = GCCollector(; registry=DEFAULT_REGISTRY)
const PROCESS_COLLECTOR = ProcessCollector(DEFAULT_REGISTRY) const PROCESS_COLLECTOR = ProcessCollector(DEFAULT_REGISTRY)
end # module Prometheus end # module Prometheus

2
src/gc_collector.jl

@ -3,7 +3,7 @@
############################ ############################
mutable struct GCCollector <: Collector mutable struct GCCollector <: Collector
function GCCollector(registry::Union{CollectorRegistry, Nothing}=DEFAULT_REGISTRY) function GCCollector(; registry::Union{CollectorRegistry, Nothing}=DEFAULT_REGISTRY)
gcc = new() gcc = new()
if registry !== nothing if registry !== nothing
register(registry, gcc) register(registry, gcc)

2
test/runtests.jl

@ -281,7 +281,7 @@ end
@testset "Prometheus.GCCollector" begin @testset "Prometheus.GCCollector" begin
r = Prometheus.CollectorRegistry() r = Prometheus.CollectorRegistry()
c = Prometheus.GCCollector(r) c = Prometheus.GCCollector(; registry=r)
@test c in r.collectors @test c in r.collectors
# Record before and after stats and test that the metrics are in between # Record before and after stats and test that the metrics are in between
old_stats = Base.gc_num() old_stats = Base.gc_num()

Loading…
Cancel
Save