pub struct CounterGroup<L: Labels, N: CounterValue = u64> { /* private fields */ }Expand description
A Counter for each combination of the labels L.
Implementations§
Source§impl<L: Labels, N: CounterValue> CounterGroup<L, N>
impl<L: Labels, N: CounterValue> CounterGroup<L, N>
Sourcepub const fn new(name: &'static str) -> Self
pub const fn new(name: &'static str) -> Self
Declares the counter group name: a letter, then letters, digits, _, ., - and /. It must be a string literal: Encore reads it from the source.
Makes the counter shared between services, under one name in the app, rather than the declaring service’s own: each service that records to it is recorded as using it. See scope.
Sourcepub const fn global(self) -> Self
pub const fn global(self) -> Self
Makes the counter the whole app’s: any code may record to it, a library outside every service too, and who does is not recorded. See scope.
Sourcepub const fn unit(self, unit: &'static str) -> Self
pub const fn unit(self, unit: &'static str) -> Self
What the counter measures in, as exported: "s", "By", "{request}".
Sourcepub const fn description(self, description: &'static str) -> Self
pub const fn description(self, description: &'static str) -> Self
What the counter measures, for one without a doc comment.
Sourcepub const fn tag(self, _key: &'static str, _value: &'static str) -> Self
pub const fn tag(self, _key: &'static str, _value: &'static str) -> Self
Tags the counter with key and value: key/value classification, such as .tag("data", "pii"), for policies to read. One call per tag, each with its own key. Encore reads them from the source, so both are string literals. A key is lowercase letters, digits, _ and -, starting with a letter and not with encore, which is kept for Encore’s own tags; a value is the same characters, or empty. Each is at most 63 characters, and a counter has at most 32 tags.
Not to be confused with the labels a group’s records carry: a tag classifies the metric itself, and is never recorded.
Sourcepub fn with(&self, labels: &L) -> Counter<N>
pub fn with(&self, labels: &L) -> Counter<N>
The counter for labels. Worth keeping where it is used often: making it takes the labels’ attributes.
Sourcepub fn reference(&self) -> &Self
pub fn reference(&self) -> &Self
The group itself, to hand to other code: a function that takes a &CounterGroup<L> records to whichever it is given.
A metric is otherwise used where it is declared, by name, which is how Encore sees which service records to it. Passing one on says so explicitly, and counts as recording to it.
Source§impl<L: Labels, N: CounterValue> CounterGroup<L, N>
impl<L: Labels, N: CounterValue> CounterGroup<L, N>
Sourcepub const fn named(name: &'static str) -> Self
pub const fn named(name: &'static str) -> Self
Binds the shared or global counter group name declared elsewhere — by another service, possibly in another language — rather than declaring one. Its labels and scope are the declaration’s, and it takes its unit, description and buckets: it has no options of its own. It is exported as name, never prefixed with a service’s name. The name must be a string literal: Encore reads it from the source.
Auto Trait Implementations§
impl<L, N = u64> !Freeze for CounterGroup<L, N>
impl<L, N = u64> !RefUnwindSafe for CounterGroup<L, N>
impl<L, N = u64> !UnwindSafe for CounterGroup<L, N>
impl<L, N> Forget for CounterGroup<L, N>
impl<L, N> Move for CounterGroup<L, N>
impl<L, N> Send for CounterGroup<L, N>
impl<L, N> Sync for CounterGroup<L, N>
impl<L, N> Unpin for CounterGroup<L, N>
impl<L, N> UnsafeUnpin for CounterGroup<L, N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request