chore(metrics): allow dot in the scope value (#1019)

This commit is contained in:
Roman Krasiuk
2023-01-25 10:44:09 +02:00
committed by GitHub
parent 2ae88b01df
commit d0f752fc5d
3 changed files with 4 additions and 4 deletions

View File

@ -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] = &[".", "_", ":"];

View File

@ -24,7 +24,7 @@ struct CustomMetrics4;
struct CustomMetrics5;
#[derive(Metrics)]
#[metrics(scope = "some.scope")]
#[metrics(scope = "some-scope")]
struct CustomMetrics6;
#[derive(Metrics)]

View File

@ -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.