Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key construction from labels always allocate #49

Closed
jean-airoldie opened this issue Aug 14, 2019 · 2 comments
Closed

Key construction from labels always allocate #49

jean-airoldie opened this issue Aug 14, 2019 · 2 comments

Comments

@jean-airoldie
Copy link
Contributor

Currently creating a key from labels will allocate a vector every time, even if the labels are &'static str.

pub fn from_name_and_labels<N, L>(name: N, labels: L) -> Self

pub trait IntoLabels {

This means that the metrics macros might potentially allocate at every call. Obviously this is not ideal.

A solution from metrics side would be for a Key to be constructible with a label without any allocation. So in the same sense that name is a ScopedString, the labels could something like:
Cow<&'static, [&'static str]>. So for the special case where the labels are a slice of &'static str this would not allocate. I think this would be ideal.

@tobz tobz added the redesign label Aug 3, 2020
@tobz
Copy link
Member

tobz commented Aug 3, 2020

This will be solved by #80 which caches callsite identifiers when labels are entirely static.

@tobz tobz removed the redesign label Sep 16, 2020
@tobz
Copy link
Member

tobz commented Sep 16, 2020

We've reworked how keys are handled in #87, but this is still covered, ultimately, by the caching mechanism introduced in #80, so I'm going to close this.

@tobz tobz closed this as completed Sep 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants