|
prom 0.1.0
Client-independent C++23 Prometheus/OpenMetrics metric abstraction
|
Error model for prom: ErrorCode, Error, expected, Exception.
More...
#include <cstdint>#include <expected>#include <stdexcept>#include <string>#include <string_view>#include <utility>

Go to the source code of this file.
Classes | |
| struct | prom::Error |
| A validation failure: a machine code plus a human message. More... | |
| class | prom::Exception |
Thrown by the throwing Registry factories when a spec fails validation. More... | |
Namespaces | |
| namespace | prom |
Typedefs | |
| template<class T > | |
| using | prom::expected = std::expected< T, Error > |
std::expected<T, Error> — the result type of the Registry::try_* family. | |
Enumerations | |
| enum class | prom::ErrorCode : std::uint8_t { prom::InvalidMetricName , prom::InvalidLabelName , prom::EmptyHelp , prom::InvalidBuckets , prom::InvalidQuantiles , prom::EmptyStateSet , prom::RegistrationFailed } |
| Why a metric definition or registration was rejected. More... | |
Functions | |
| constexpr std::string_view | prom::to_string (const ErrorCode code) noexcept |
Human-readable spelling of an ErrorCode. | |
Error model for prom: ErrorCode, Error, expected, Exception.
Policy. Definition and registration of a metric validate their inputs. The throwing factories on Registry (counter, gauge, ...) raise a prom::Exception on bad input; their noexcept mirrors (try_counter, ...) return a prom::expected instead. Once a metric exists, every mutation is noexcept — invalid samples (a negative counter increment, a NaN observation, a unit-kind mismatch) are dropped and logged rather than thrown. The no-client path never throws because a metric always resolves to at least the NullAdapter.