Skip to content

Commit dafb35b

Browse files
committed
ref(metric-meta): Add support for metric metadata
1 parent 4d133f5 commit dafb35b

23 files changed

+805
-50
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
4+
## Unreleased
5+
6+
- Add support for metric metadata. ([#2751](https://github.com/getsentry/relay/pull/2751))
7+
38
## 23.11.1
49

510
**Features**:

Cargo.lock

+6-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ debug = true
1515

1616
[workspace.dependencies]
1717
anyhow = "1.0.66"
18-
chrono = { version = "0.4.29", default-features = false, features = [
18+
chrono = { version = "0.4.31", default-features = false, features = [
1919
"std",
2020
"serde",
2121
] }
2222
clap = { version = "4.4.6" }
2323
criterion = "0.5"
2424
futures = { version = "0.3", default-features = false, features = ["std"] }
2525
insta = { version = "1.31.0", features = ["json", "redactions", "ron"] }
26+
hash32 = "0.3.1"
27+
hashbrown = "0.13.2"
2628
itertools = "0.10.5"
2729
once_cell = "1.13.1"
2830
rand = "0.8.5"

relay-dynamic-config/src/feature.rs

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ pub enum Feature {
3333
/// Enable processing profiles
3434
#[serde(rename = "organizations:profiling")]
3535
Profiling,
36+
/// Enable metric metadata.
37+
#[serde(rename = "organizations:metric-meta")]
38+
MetricMeta,
3639

3740
/// Deprecated, still forwarded for older downstream Relays.
3841
#[serde(rename = "organizations:transaction-name-mark-scrubbed-as-sanitized")]

relay-metrics/Cargo.toml

+7-1
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,27 @@ edition = "2021"
99
license-file = "../LICENSE.md"
1010
publish = false
1111

12+
[features]
13+
redis = ["relay-redis/impl"]
14+
1215
[dependencies]
1316
bytecount = "0.6.0"
1417
fnv = "1.0.7"
15-
hash32 = "0.3.1"
18+
hash32 = { workspace = true }
19+
hashbrown = { workspace = true }
1620
itertools = { workspace = true }
1721
relay-base-schema = { path = "../relay-base-schema" }
1822
relay-common = { path = "../relay-common" }
1923
relay-log = { path = "../relay-log" }
24+
relay-redis = { path = "../relay-redis", optional = true }
2025
relay-statsd = { path = "../relay-statsd" }
2126
relay-system = { path = "../relay-system" }
2227
serde = { workspace = true }
2328
serde_json = { workspace = true }
2429
smallvec = { workspace = true }
2530
thiserror = { workspace = true }
2631
tokio = { workspace = true, features = ["time"] }
32+
chrono = { workspace = true }
2733

2834
[dev-dependencies]
2935
criterion = { workspace = true }

relay-metrics/src/bucket.rs

+1-24
Original file line numberDiff line numberDiff line change
@@ -399,29 +399,6 @@ fn parse_gauge(string: &str) -> Option<GaugeValue> {
399399
})
400400
}
401401

402-
/// Parses an MRI from a string and a separate type.
403-
///
404-
/// The given string must be a part of the MRI, including the following components:
405-
/// - (optional) The namespace. If missing, it is defaulted to `"custom"`
406-
/// - (required) The metric name.
407-
/// - (optional) The unit. If missing, it is defaulted to "none".
408-
///
409-
/// The metric type is never part of this string and must be supplied separately.
410-
fn parse_mri(string: &str, ty: MetricType) -> Option<MetricResourceIdentifier> {
411-
let (name_and_namespace, unit) = protocol::parse_name_unit(string)?;
412-
413-
let (raw_namespace, name) = name_and_namespace
414-
.split_once('/')
415-
.unwrap_or(("custom", name_and_namespace));
416-
417-
Some(MetricResourceIdentifier {
418-
ty,
419-
name,
420-
namespace: raw_namespace.parse().ok()?,
421-
unit,
422-
})
423-
}
424-
425402
/// Parses tags in the format `tag1,tag2:value`.
426403
///
427404
/// Tag values are optional. For tags with missing values, an empty `""` value is assumed.
@@ -640,7 +617,7 @@ impl Bucket {
640617
let (mri_str, values_str) = components.next()?.split_once(':')?;
641618
let ty = components.next().and_then(|s| s.parse().ok())?;
642619

643-
let mri = parse_mri(mri_str, ty)?;
620+
let mri = MetricResourceIdentifier::parse_with_type(mri_str, ty).ok()?;
644621
let value = match ty {
645622
MetricType::Counter => BucketValue::Counter(parse_counter(values_str)?),
646623
MetricType::Distribution => BucketValue::Distribution(parse_distribution(values_str)?),

relay-metrics/src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,17 @@ pub mod aggregator;
7272

7373
mod aggregatorservice;
7474
mod bucket;
75+
mod meta;
7576
mod protocol;
77+
#[cfg(feature = "redis")]
78+
mod redis_meta;
7679
mod router;
7780
mod statsd;
7881

7982
pub use aggregatorservice::*;
8083
pub use bucket::*;
84+
pub use meta::*;
8185
pub use protocol::*;
86+
#[cfg(feature = "redis")]
87+
pub use redis_meta::*;
8288
pub use router::*;

0 commit comments

Comments
 (0)