mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore(metrics): allow dot in the scope value (#1019)
This commit is contained in:
@ -11,7 +11,7 @@ use crate::{metric::Metric, with_attrs::WithAttrs};
|
||||
/// Metric name regex according to Prometheus data model
|
||||
/// https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels
|
||||
static METRIC_NAME_RE: Lazy<Regex> =
|
||||
Lazy::new(|| Regex::new(r"^[a-zA-Z_:][a-zA-Z0-9_:]*$").unwrap());
|
||||
Lazy::new(|| Regex::new(r"^[a-zA-Z_:.][a-zA-Z0-9_:.]*$").unwrap());
|
||||
|
||||
/// Supported metrics separators
|
||||
const SUPPORTED_SEPARATORS: &[&str] = &[".", "_", ":"];
|
||||
|
||||
@ -24,7 +24,7 @@ struct CustomMetrics4;
|
||||
struct CustomMetrics5;
|
||||
|
||||
#[derive(Metrics)]
|
||||
#[metrics(scope = "some.scope")]
|
||||
#[metrics(scope = "some-scope")]
|
||||
struct CustomMetrics6;
|
||||
|
||||
#[derive(Metrics)]
|
||||
|
||||
@ -29,10 +29,10 @@ error: Value **must** be a string literal.
|
||||
23 | #[metrics(scope = 123)]
|
||||
| ^^^
|
||||
|
||||
error: Value must match regex ^[a-zA-Z_:][a-zA-Z0-9_:]*$
|
||||
error: Value must match regex ^[a-zA-Z_:.][a-zA-Z0-9_:.]*$
|
||||
--> tests/compile-fail/metrics_attr.rs:27:19
|
||||
|
|
||||
27 | #[metrics(scope = "some.scope")]
|
||||
27 | #[metrics(scope = "some-scope")]
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: Duplicate `scope` value provided.
|
||||
|
||||
Reference in New Issue
Block a user