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

Allow passing owned strings as metric key. #170

Merged
merged 6 commits into from
Feb 3, 2021
Merged

Conversation

tobz
Copy link
Member

@tobz tobz commented Feb 2, 2021

Previously, due to the way the macros were written, users could specify a metric key as either a string literal or an expression that pointed to an owned string, due to the Into<T> implementations for Key and the way the macros handled the input arguments. While not an explicit design goal, this was broken in the rewrite for 0.13: #165

This PR reworks the macros such that they can properly handle either a string literal or owned string as the metric key. Minimal work was required on the Key/KeyData side as we mostly had a sufficient set of from_* methods. The real work is in the macro argument parsing and code generation itself, dealing with the matrix of combinations: is the name static, are the labels static, and all the combinations in thereof.

@tobz tobz linked an issue Feb 2, 2021 that may be closed by this pull request
@tobz tobz added C-core Component: core functionality such as traits, etc. C-macros Component: macros. E-complex Effort: complex. T-enhancement Type: enhancement. labels Feb 2, 2021
@tobz
Copy link
Member Author

tobz commented Feb 3, 2021

CI breakage looks to be related to Alexhuszagh/rust-lexical#55 so I'm trying to get that sorted.

@tobz tobz merged commit 18ff3a1 into main Feb 3, 2021
@tobz tobz deleted the owned_strings_macro_key branch February 3, 2021 03:05
mnpw pushed a commit to mnpw/metrics that referenced this pull request Mar 8, 2024
…_key

Allow passing owned strings as metric key.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-core Component: core functionality such as traits, etc. C-macros Component: macros. E-complex Effort: complex. T-enhancement Type: enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The macros no longer support dynamic keys
1 participant