From 08a71feef88d99e63cdb9c4c8cebb62790749ded Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Mon, 20 Nov 2023 12:20:36 +0100 Subject: [PATCH] NFC: Add Sample inner constructor to enforce correct label-pairing. --- src/Prometheus.jl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Prometheus.jl b/src/Prometheus.jl index e6db058..98be5a8 100644 --- a/src/Prometheus.jl +++ b/src/Prometheus.jl @@ -811,6 +811,15 @@ struct Sample label_names::Union{LabelNames, Nothing} label_values::Union{LabelValues, Nothing} value::Float64 + function Sample( + suffix::Union{String, Nothing}, + label_names::Union{Nothing, LabelNames{N}}, + label_values::Union{Nothing, LabelValues{N}}, + value::Real, + ) where N + @assert((label_names === nothing) === (label_values === nothing)) + return new(suffix, label_names, label_values, value) + end end struct Metric