All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
-
ConstCounter::new
now requires specifying the type of literal arguments, like this:ConstCounter::new(42u64);
. See PR 173. -
Update
prost
dependencies tov0.12
. See PR 198. -
Implement
Atomic<u64>
forAtomicU64
for gauges. See PR 226. -
Implement
EnableLabelValue
forbool
. See PR 237
-
Support
i32
/f32
forGauge
andu32
/f32
forCounter
/CounterWithExemplar
. See PR 173 and PR 216. -
Supoort
Arc<String>
forEncodeLabelValue
. See PR 217. -
Added
get
method toFamily
. See PR 234.
- Don't prepend
,
when encoding empty family label set. See PR 175.
-
Added
encode_registry
andencode_eof
functions totext
module. See PR 205. -
Support all platforms with 32 bit atomics lacking 64 bit atomics. See PR 203.
- Added
Gauge<u32, AtomicU32>
implementation. See PR 191.
- Added
EncodeLabelValue
andEncodeLabelKey
implementations forArc
,Rc
, andBox
. See PR 188.
- Simplify
Collector
trait
by enablingCollector::collect
to encode metrics directly with aDescriptorEncoder
. See PR 149 for details.
- Added
sub_registry_with_labels
method toRegistry
. See PR 145. - Added
with_labels
andwith_prefix_and_labels
constructors toRegistry
. See PR 147.
- Implement
EncodeLabelValue
forOption<T>
. See PR 137.
- Replace
impl EncodeMetric for RefCell<T>
with a new typeConstFamily
implementingEncodeMetric
.
-
Introduce
Collector
abstraction allowing users to provide additional metrics and their description on each scrape. See PR 82. -
Introduce a
#[prometheus(flatten)]
attribute which can be used when derivingEncodeLabelSet
, allowing a nested struct to be flattened during encoding. See PR 118.For example:
#[derive(EncodeLabelSet, Hash, Clone, Eq, PartialEq, Debug)] struct CommonLabels { a: u64, b: u64, } #[derive(EncodeLabelSet, Hash, Clone, Eq, PartialEq, Debug)] struct Labels { unique: u64, #[prometheus(flatten)] common: CommonLabels, }
Would be encoded as:
my_metric{a="42",b="42",unique="42"} 42
- Fix label encoding in protobuf feature. See PR 123.
This is a large release including multiple breaking changes. Major user-facing improvement of this release is support for the OpenMetrics Protobuf format.
-
Don't box before registering.
registry.register( "my_metric", "This is my metric", - Box::new(my_metric.clone()), + my_metric.clone(), );
-
Gauge uses
i64
instead ofu64
.my_gauge - .set(42u64); + .set(42i64);
-
Derive
EncodeLabelSet
forstruct
andEncodeLabelValue
forenum
instead of justEncode
for all and requireDebug
.- #[derive(Clone, Hash, PartialEq, Eq, Encode)] + #[derive(Clone, Hash, PartialEq, Eq, EncodeLabelSet, Debug)] struct Labels { path: String, method: Method, some_number: u64, } - #[derive(Clone, Hash, PartialEq, Eq, Encode)] + #[derive(Clone, Hash, PartialEq, Eq, EncodeLabelValue, Debug)] enum Method { Get, #[allow(dead_code)] Put, }
-
Encode as utf-8 and not as
[u8]
.- let mut buffer = vec![]; + let mut buffer = String::new(); encode(&mut buffer, ®istry).unwrap();
For details on each of these, see changelog entries below.
- Added support for the OpenMetrics protobuf format. See PR 83.
- Added a
remove
method toFamily
to allow the removal of a specified label set from a family. See PR 85. - Added a
clear
method toFamily
to allow the removal of all label sets from a family. See PR 85. - Impl
TypedMetric
forCounterWithExemplar
andHistogramWithExemplar
, so that they can be used withFamily
. See PR 96.
- Always use dynamic dispatch on
Registry
, i.e. remove generic type parameterM
fromRegistry
. See PR 105. - Refactor encoding. See PR 105.
- Introducing separate traits to encode
- value (e.g.
EncodeCounterValue
) - label set (
EncodeLabelSet
), derivable for structs viaprometheus-client-derive-encode
- label (
EncodeLabel
) - label key (
EncodeLabelKey
) - label value (
EncodeLabelValue
), derivable for enums viaprometheus-client-derive-encode
- value (e.g.
- Encode as UTF-8 strings, not bytes. I.e. use
std::fmt::Write
instead ofstd::io::Write
.
- Introducing separate traits to encode
- Use signed integers for
Gauge
for compliance with OpenMetrics protobuf format. See PR 105.
- Fix race condition in
Family::get_or_create
. See PR 102.
-
Use
parking_lot
instead ofstd::sync::*
.Before
proemtheus-client
would use theowning_ref
crate to map the target of astd::sync::RwLockReadGuard
.owning_ref
has multiple unsoundness issues, see https://rustsec.org/advisories/RUSTSEC-2022-0040.html. Instead of replacingowning_ref
with a similar crate, we switch to locking viaparking_lot
which supports the above mapping natively.
- Updates to Rust 2021 Edition. See PR 65.
- Added a
with_prefix
method toRegistry
to allow initializing a registry with a prefix. See PR 70. - Added
Debug
implementations on most public types that were missing them. See PR 71. - Added example for actix-web framework. See PR 76.
- Remove
Add
trait implementation for a private type which lead to compile time conflicts with existingAdd
implementations e.g. onString
. See PR 69.
- Require
Registry
default generic typeSendEncodeMetric
to beSync
. See PR 58.
- Expose
Encoder
methods. See PR 41.
- Use
AtomicU32
on platforms that don't supportAtomicU64
. See PR 42.
- Release as
prometheus-client
andprometheus-client-derive-text-encode
.
- Implement
Gauge::dec
andGauge::dec_by
. See PR 30.
Note: This was initially released as v0.12.1
but later on yanked due to it
including a breaking change. See PR 24 for details.
- Allow family to use constructors that do not coerce to function pointers. See PR 21.
- Add
Registry::sub_registry_with_label
. See PR 20.
- Rename
Registry::sub_registry
toRegistry::sub_registry_with_prefix
. See PR 20.
- Do not separate labels with spaces.
- Encode Info metric labels.
- Add support for OpenMetrics Info metrics (see PR 18).
- Implement
Encode
foru32
.
-
Update to prometheus-client-derive-text-encode v0.1.1 which handles keyword identifiers aka raw identifiers
- Added
metrics::histogram::linear_buckets
. #13
- Renamed
metrics::histogram::exponential_series
tometrics::histogram::exponential_buckets
. #13