Skip to content

Commit

Permalink
ref(metric-meta): Add support for metric metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Dav1dde committed Nov 22, 2023
1 parent 4d133f5 commit 605c257
Show file tree
Hide file tree
Showing 23 changed files with 687 additions and 23 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog


## Unreleased

- Add support for metric metadata. ([#2751](https://github.com/getsentry/relay/pull/2751))

## 23.11.1

**Features**:
Expand Down
8 changes: 6 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ debug = true

[workspace.dependencies]
anyhow = "1.0.66"
chrono = { version = "0.4.29", default-features = false, features = [
chrono = { version = "0.4.31", default-features = false, features = [
"std",
"serde",
] }
clap = { version = "4.4.6" }
criterion = "0.5"
futures = { version = "0.3", default-features = false, features = ["std"] }
insta = { version = "1.31.0", features = ["json", "redactions", "ron"] }
hash32 = "0.3.1"
hashbrown = "0.13.2"
itertools = "0.10.5"
once_cell = "1.13.1"
rand = "0.8.5"
Expand Down
3 changes: 3 additions & 0 deletions relay-dynamic-config/src/feature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ pub enum Feature {
/// Enable processing profiles
#[serde(rename = "organizations:profiling")]
Profiling,
/// Enable metric metadata.
#[serde(rename = "organizations:metric-meta")]
MetricMeta,

/// Deprecated, still forwarded for older downstream Relays.
#[serde(rename = "organizations:transaction-name-mark-scrubbed-as-sanitized")]
Expand Down
5 changes: 4 additions & 1 deletion relay-metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,21 @@ publish = false
[dependencies]
bytecount = "0.6.0"
fnv = "1.0.7"
hash32 = "0.3.1"
hash32 = { workspace = true }
hashbrown = { workspace = true }
itertools = { workspace = true }
relay-base-schema = { path = "../relay-base-schema" }
relay-common = { path = "../relay-common" }
relay-log = { path = "../relay-log" }
relay-redis = { path = "../relay-redis" }
relay-statsd = { path = "../relay-statsd" }
relay-system = { path = "../relay-system" }
serde = { workspace = true }
serde_json = { workspace = true }
smallvec = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["time"] }
chrono = { workspace = true }

[dev-dependencies]
criterion = { workspace = true }
Expand Down
11 changes: 10 additions & 1 deletion relay-metrics/src/aggregatorservice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize};
use crate::aggregator::{self, AggregatorConfig, ShiftKey};
use crate::bucket::Bucket;
use crate::statsd::{MetricCounters, MetricHistograms};
use crate::{BucketValue, DistributionValue};
use crate::{BucketValue, DistributionValue, MetricMeta};

/// Interval for the flush cycle of the [`AggregatorService`].
const FLUSH_INTERVAL: Duration = Duration::from_millis(100);
Expand Down Expand Up @@ -589,6 +589,15 @@ impl MergeBuckets {
}
}

/// TODO: lol
#[derive(Debug)]
pub struct AddMetricMeta {
/// The project key.
pub project_key: ProjectKey,
/// The metadata.
pub meta: MetricMeta,
}

#[cfg(test)]
mod tests {

Expand Down
3 changes: 2 additions & 1 deletion relay-metrics/src/bucket.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::borrow::Cow;
use std::collections::{BTreeMap, BTreeSet};
use std::iter::FusedIterator;
use std::{fmt, mem};
Expand Down Expand Up @@ -416,7 +417,7 @@ fn parse_mri(string: &str, ty: MetricType) -> Option<MetricResourceIdentifier> {

Some(MetricResourceIdentifier {
ty,
name,
name: Cow::Borrowed(name),
namespace: raw_namespace.parse().ok()?,
unit,
})
Expand Down
2 changes: 2 additions & 0 deletions relay-metrics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,13 @@ pub mod aggregator;

mod aggregatorservice;
mod bucket;
mod meta;
mod protocol;
mod router;
mod statsd;

pub use aggregatorservice::*;
pub use bucket::*;
pub use meta::*;
pub use protocol::*;
pub use router::*;
Loading

0 comments on commit 605c257

Please sign in to comment.