Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased

**Breaking Changes**:

- Use a much more mature (dog)statsd backend, with proper support for unix sockets and reservoir sampling.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Use a much more mature (dog)statsd backend, with proper support for unix sockets and reservoir sampling.
- Use a more mature (dog)statsd backend, with proper support for unix sockets and reservoir sampling.

Let's be nice to the old backend

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair, I was mostly referring to my botched version of the udp socket implementation, statsdproxy served us well!

Due to the new backend, all sampling and tag filtering configuration options have been removed. ([#5675](https://github.com/getsentry/relay/pull/5675))

**Bug Fixes**:

- Prevent minidump compression bomb. ([#5613](https://github.com/getsentry/relay/pull/5613))
Expand Down
148 changes: 120 additions & 28 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -545,15 +545,6 @@ dependencies = [
"libbz2-rs-sys",
]

[[package]]
name = "cadence"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3075f133bee430b7644c54fb629b9b4420346ffa275a45c81a6babe8b09b4f51"
dependencies = [
"crossbeam-channel",
]

[[package]]
name = "cast"
version = "0.3.0"
Expand Down Expand Up @@ -1313,6 +1304,12 @@ dependencies = [
"cfg-if",
]

[[package]]
name = "endian-type"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d"

[[package]]
name = "enum-as-inner"
version = "0.6.1"
Expand Down Expand Up @@ -2709,6 +2706,51 @@ dependencies = [
"autocfg",
]

[[package]]
name = "metrics"
version = "0.24.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d5312e9ba3771cfa961b585728215e3d972c950a3eed9252aa093d6301277e8"
dependencies = [
"ahash",
"portable-atomic",
]

[[package]]
name = "metrics-exporter-dogstatsd"
version = "0.9.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "961f3712d8a7cfe14caaf74c3af503fe701cee6439ff49a7a3ebd04bf49c0502"
dependencies = [
"bytes",
"itoa",
"metrics",
"metrics-util",
"ryu",
"thiserror 2.0.17",
"tracing",
]

[[package]]
name = "metrics-util"
version = "0.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdfb1365fea27e6dd9dc1dbc19f570198bc86914533ad639dae939635f096be4"
dependencies = [
"aho-corasick",
"crossbeam-epoch",
"crossbeam-utils",
"hashbrown 0.16.1",
"indexmap",
"metrics",
"ordered-float",
"quanta",
"radix_trie",
"rand 0.9.2",
"rand_xoshiro",
"sketches-ddsketch",
]

[[package]]
name = "mimalloc"
version = "0.1.48"
Expand Down Expand Up @@ -2884,6 +2926,15 @@ version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"

[[package]]
name = "nibble_vec"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77a5d83df9f36fe23f0c3648c6bbb8b0298bb5f1939c8f2704431371f4b84d43"
dependencies = [
"smallvec",
]

[[package]]
name = "nix"
version = "0.29.0"
Expand Down Expand Up @@ -3254,6 +3305,15 @@ dependencies = [
"thiserror 2.0.17",
]

[[package]]
name = "ordered-float"
version = "5.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f4779c6901a562440c3786d08192c6fbda7c1c2060edd10006b05ee35d10f2d"
dependencies = [
"num-traits",
]

[[package]]
name = "os_info"
version = "3.9.0"
Expand Down Expand Up @@ -3762,6 +3822,21 @@ dependencies = [
"cc",
]

[[package]]
name = "quanta"
version = "0.12.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3ab5a9d756f0d97bdc89019bd2e4ea098cf9cde50ee7564dde6b81ccc8f06c7"
dependencies = [
"crossbeam-utils",
"libc",
"once_cell",
"raw-cpuid",
"wasi 0.11.0+wasi-snapshot-preview1",
"web-sys",
"winapi",
]

[[package]]
name = "quick-error"
version = "1.2.3"
Expand Down Expand Up @@ -3794,6 +3869,16 @@ dependencies = [
"scheduled-thread-pool",
]

[[package]]
name = "radix_trie"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c069c179fcdc6a2fe24d8d18305cf085fdbd4f922c041943e203685d6a1c58fd"
dependencies = [
"endian-type",
"nibble_vec",
]

[[package]]
name = "rand"
version = "0.8.5"
Expand Down Expand Up @@ -3871,6 +3956,15 @@ dependencies = [
"rand_core 0.9.3",
]

[[package]]
name = "rand_xoshiro"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f703f4665700daf5512dcca5f43afa6af89f09db47fb56be587f80636bda2d41"
dependencies = [
"rand_core 0.9.3",
]

[[package]]
name = "range-map"
version = "0.2.0"
Expand All @@ -3880,6 +3974,15 @@ dependencies = [
"num-traits",
]

[[package]]
name = "raw-cpuid"
version = "11.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "498cd0dc59d73224351ee52a95fee0f1a617a2eae0e7d9d720cc622c73a54186"
dependencies = [
"bitflags 2.9.4",
]

[[package]]
name = "rayon"
version = "1.10.0"
Expand Down Expand Up @@ -4747,12 +4850,9 @@ dependencies = [
name = "relay-statsd"
version = "26.2.1"
dependencies = [
"cadence",
"crossbeam-channel",
"parking_lot",
"rand 0.9.2",
"metrics",
"metrics-exporter-dogstatsd",
"relay-log",
"statsdproxy",
]

[[package]]
Expand Down Expand Up @@ -5619,6 +5719,12 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d"

[[package]]
name = "sketches-ddsketch"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1e9a774a6c28142ac54bb25d25562e6bcf957493a184f15ad4eebccb23e410a"

[[package]]
name = "slab"
version = "0.4.9"
Expand Down Expand Up @@ -5919,20 +6025,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"

[[package]]
name = "statsdproxy"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ad88f372ad4e60c8235f74feb2fcc047377c55b1872d0b9247b8a6aed8dcba9"
dependencies = [
"anyhow",
"cadence",
"crc32fast",
"log",
"rand 0.8.5",
"thread_local",
]

[[package]]
name = "string_cache"
version = "0.8.7"
Expand Down
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ brotli = "7.0.0"
bytecount = "0.6.9"
bytes = "1.10.1"
bzip2 = "0.6.0"
cadence = "1.6.0"
chrono = { version = "0.4.42", default-features = false, features = [
"std",
"serde",
Expand All @@ -106,7 +105,6 @@ cmake = "0.1.54"
console = "0.15.11"
cookie = "0.18.1"
criterion = "0.5.1"
crossbeam-channel = "0.5.15"
data-encoding = "2.9.0"
deadpool = "0.12.3"
debugid = "0.8.0"
Expand Down Expand Up @@ -144,6 +142,8 @@ mimalloc = { version = "0.1.48", features = ["v3"] }
mime = "0.3.17"
minidump = "0.26.0"
multer = "3.1.0"
metrics = "0.24.3"
metrics-exporter-dogstatsd = "0.9.6"
num-traits = "0.2.19"
num_cpus = "1.17.0"
objectstore-client = "0.0.18"
Expand Down Expand Up @@ -205,7 +205,6 @@ smallvec = { version = "1.15.1", features = ["serde"] }
socket2 = "0.6.2"
sqlparser = "0.60.0"
sqlx = { version = "0.8.6", default-features = false }
statsdproxy = { version = "0.4.1", default-features = false }
symbolic-common = { version = "12.12.3", default-features = false }
symbolic-unreal = { version = "12.12.3", default-features = false }
syn = { version = "2.0.106" }
Expand Down
2 changes: 1 addition & 1 deletion relay-cardinality/src/redis/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl Inner {
.extract_if(|scope, cache| cache.current_slot < scope.active_slot(ts))
.count()
});
metric!(counter(CardinalityLimiterCounters::RedisCacheVacuum) += expired as i64);
metric!(counter(CardinalityLimiterCounters::RedisCacheVacuum) += expired as u64);
}
}

Expand Down
22 changes: 5 additions & 17 deletions relay-cardinality/src/redis/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
CardinalityLimit,
limiter::{Entry, EntryId, Scoping},
redis::quota::{PartialQuotaScoping, QuotaScoping},
statsd::{CardinalityLimiterCounters, CardinalityLimiterSets},
statsd::CardinalityLimiterCounters,
};

/// Internal state combining relevant entries for the respective quotas.
Expand All @@ -27,16 +27,14 @@ pub struct LimitState<'a> {

/// The original cardinality limit.
cardinality_limit: &'a CardinalityLimit,
/// The original/full scoping.
scoping: Scoping,
/// Amount of cache hits.
cache_hits: i64,
cache_hits: u64,
/// Amount of cache misses.
cache_misses: i64,
cache_misses: u64,
/// Amount of accepts,
accepts: i64,
accepts: u64,
/// Amount of rejections.
rejections: i64,
rejections: u64,
}

impl<'a> LimitState<'a> {
Expand All @@ -49,7 +47,6 @@ impl<'a> LimitState<'a> {
scopes: BTreeMap::new(),
limit: cardinality_limit.limit,
cardinality_limit,
scoping,
cache_hits: 0,
cache_misses: 0,
accepts: 0,
Expand Down Expand Up @@ -161,15 +158,6 @@ impl Drop for LimitState<'_> {
id = &self.cardinality_limit.id,
passive = passive,
);

let organization_id = self.scoping.organization_id;
let status = if self.rejections > 0 { "limited" } else { "ok" };
metric!(
set(CardinalityLimiterSets::Organizations) = organization_id.value() as i64,
id = &self.cardinality_limit.id,
passive = passive,
status = status,
)
}
}

Expand Down
24 changes: 1 addition & 23 deletions relay-cardinality/src/statsd.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use relay_statsd::TimerMetric;
#[cfg(feature = "redis")]
use relay_statsd::{CounterMetric, DistributionMetric, SetMetric};
use relay_statsd::{CounterMetric, DistributionMetric};

/// Counter metrics for the Relay Cardinality Limiter.
#[cfg(feature = "redis")]
Expand Down Expand Up @@ -113,25 +113,3 @@ impl DistributionMetric for CardinalityLimiterDistributions {
}
}
}

#[cfg(feature = "redis")]
pub enum CardinalityLimiterSets {
/// Set containing all organizations which have had any metric sent through the cardinality
/// limiter.
///
/// This metric is tagged with:
/// - `id`: The id of the enforced limit.
/// - `status`: Wether the organization was cardinality limited.
#[cfg(feature = "redis")]
Organizations,
}

#[cfg(feature = "redis")]
impl SetMetric for CardinalityLimiterSets {
fn name(&self) -> &'static str {
match *self {
#[cfg(feature = "redis")]
Self::Organizations => "cardinality.limiter.organizations",
}
}
}
Loading
Loading