Skip to content

Commit

Permalink
Merge the consumption metric pushes (#9939)
Browse files Browse the repository at this point in the history
#8564

## Problem

The main and backup consumption metric pushes are completely
independent,
resulting in different event time windows and different idempotency
keys.

## Summary of changes

* Merge the push tasks, but keep chunks the same size.
  • Loading branch information
cloneable authored Nov 30, 2024
1 parent aa4ec11 commit 4abc8e5
Show file tree
Hide file tree
Showing 5 changed files with 181 additions and 181 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions libs/consumption_metrics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,12 @@ impl<'a> IdempotencyKey<'a> {
}
}

/// Split into chunks of 1000 metrics to avoid exceeding the max request size.
pub const CHUNK_SIZE: usize = 1000;

// Just a wrapper around a slice of events
// to serialize it as `{"events" : [ ] }
#[derive(serde::Serialize, Deserialize)]
pub struct EventChunk<'a, T: Clone> {
#[derive(Debug, serde::Serialize, serde::Deserialize, PartialEq)]
pub struct EventChunk<'a, T: Clone + PartialEq> {
pub events: std::borrow::Cow<'a, [T]>,
}
1 change: 1 addition & 0 deletions proxy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ workspace_hack.workspace = true
[dev-dependencies]
camino-tempfile.workspace = true
fallible-iterator.workspace = true
flate2.workspace = true
tokio-tungstenite.workspace = true
pbkdf2 = { workspace = true, features = ["simple", "std"] }
rcgen.workspace = true
Expand Down
4 changes: 0 additions & 4 deletions proxy/src/bin/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,10 +517,6 @@ async fn main() -> anyhow::Result<()> {
if let Some(metrics_config) = &config.metric_collection {
// TODO: Add gc regardles of the metric collection being enabled.
maintenance_tasks.spawn(usage_metrics::task_main(metrics_config));
client_tasks.spawn(usage_metrics::task_backup(
&metrics_config.backup_metric_collection_config,
cancellation_token.clone(),
));
}

if let Either::Left(auth::Backend::ControlPlane(api, _)) = &auth_backend {
Expand Down
Loading

1 comment on commit 4abc8e5

@github-actions
Copy link

@github-actions github-actions bot commented on 4abc8e5 Nov 30, 2024

Choose a reason for hiding this comment

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

7078 tests run: 6760 passed, 0 failed, 318 skipped (full report)


Flaky tests (2)

Postgres 15

Code coverage* (full report)

  • functions: 30.4% (8274 of 27226 functions)
  • lines: 47.8% (65225 of 136507 lines)

* collected from Rust tests only


The comment gets automatically updated with the latest test results
4abc8e5 at 2024-11-30T14:02:10.609Z :recycle:

Please sign in to comment.