Skip to content

Commit a77924b

Browse files
Add encode_descriptor and encode_metric
1 parent 4a6d40a commit a77924b

3 files changed

Lines changed: 301 additions & 43 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## Unreleased
8+
9+
### Added
10+
11+
- Added `encoding::text::encode_descriptor` and `encoding::text::encode_metric`
12+
for custom registries that need to compose descriptors, samples and EOF
13+
markers independently.
14+
- Added `EncodeMetric` forwarding for `Arc<T: EncodeMetric>`.
15+
716
## [0.24.1]
817

918
### Added

src/encoding.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,24 @@ impl EncodeMetric for Box<dyn EncodeMetric> {
7171
fn metric_type(&self) -> MetricType {
7272
self.deref().metric_type()
7373
}
74+
75+
fn is_empty(&self) -> bool {
76+
self.deref().is_empty()
77+
}
78+
}
79+
80+
impl<T: EncodeMetric + ?Sized> EncodeMetric for Arc<T> {
81+
fn encode(&self, encoder: MetricEncoder) -> Result<(), std::fmt::Error> {
82+
self.deref().encode(encoder)
83+
}
84+
85+
fn metric_type(&self) -> MetricType {
86+
self.deref().metric_type()
87+
}
88+
89+
fn is_empty(&self) -> bool {
90+
self.deref().is_empty()
91+
}
7492
}
7593

7694
/// Encoder for a Metric Descriptor.

0 commit comments

Comments
 (0)