Skip to content

Commit

Permalink
Revert "fix: remove trace from ops (#780)" (#805)
Browse files Browse the repository at this point in the history
<!-- Please make sure there is an issue that this PR is correlated to. -->

## Changes

<!-- If there are frontend changes, please include screenshots. -->
  • Loading branch information
NathanFlurry committed May 31, 2024
1 parent f4f2734 commit ef2a041
Show file tree
Hide file tree
Showing 38 changed files with 320 additions and 264 deletions.
489 changes: 246 additions & 243 deletions gen/secrets.baseline.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lib/api-helper/build/src/macro_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ pub async fn __with_ctx<A: auth::ApiAuth + Send>(
ts,
ts,
(),
Vec::new(),
);

// Create auth
Expand Down
4 changes: 0 additions & 4 deletions lib/chirp/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,6 @@ impl Client {
pub fn ts(&self) -> i64 {
self.ts
}

pub fn trace(&self) -> &[chirp::TraceEntry] {
&self.trace
}
}

impl Drop for Client {
Expand Down
1 change: 1 addition & 0 deletions lib/chirp/worker/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,7 @@ where
ts,
req_ts,
req_body,
trace,
),
dont_log_body,
allow_recursive,
Expand Down
1 change: 1 addition & 0 deletions lib/chirp/worker/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ impl TestCtx {
rivet_util::timestamp::now(),
rivet_util::timestamp::now(),
(),
Vec::new(),
);

Ok(TestCtx {
Expand Down
8 changes: 2 additions & 6 deletions lib/connection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl Connection {
&self,
parent_req_id: Uuid,
ray_id: Uuid,
trace_entry: chirp_client::TraceEntry,
trace: Vec<chirp_client::TraceEntry>,
) -> GlobalResult<Connection> {
// Not the same as the operation ctx's ts because this cannot be overridden by debug start ts
let ts = rivet_util::timestamp::now();
Expand All @@ -41,11 +41,7 @@ impl Connection {
parent_req_id,
ray_id,
ts,
{
let mut x = self.client.trace().to_vec();
x.push(trace_entry);
x
},
trace,
chirp_perf::PerfCtxInner::new(redis_cache, ts, parent_req_id, ray_id),
),
self.pools.clone(),
Expand Down
49 changes: 38 additions & 11 deletions lib/operation/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ where
ts: i64,
req_ts: i64,
body: B,
// Trace of all requests not including this request. The client does include
// this request in the trace, though.
trace: Vec<chirp_client::TraceEntry>,
}

impl<B> OperationContext<B>
Expand All @@ -55,6 +58,7 @@ where
ts: i64,
req_ts: i64,
body: B,
trace: Vec<chirp_client::TraceEntry>,
) -> Self {
OperationContext {
name,
Expand All @@ -65,6 +69,7 @@ where
ts,
req_ts,
body,
trace,
}
}

Expand Down Expand Up @@ -131,25 +136,46 @@ where
/// Adds trace and correctly wraps `Connection` (and subsequently `chirp_client::Client`).
fn wrap<O: Operation>(&self, body: O::Request) -> GlobalResult<OperationContext<O::Request>> {
let ray_id = Uuid::new_v4();
let trace_entry = chirp_client::TraceEntry {
context_name: self.name.clone(),
req_id: Some(self.req_id.into()),
ts: rivet_util::timestamp::now(),
run_context: match rivet_util::env::run_context() {
rivet_util::env::RunContext::Service => chirp_client::RunContext::Service,
rivet_util::env::RunContext::Test => chirp_client::RunContext::Test,
} as i32,
// Add self to new operation's trace
let trace = {
let mut x = self.trace.clone();
x.push(chirp_client::TraceEntry {
context_name: self.name.clone(),
req_id: Some(self.req_id.into()),
ts: rivet_util::timestamp::now(),
run_context: match rivet_util::env::run_context() {
rivet_util::env::RunContext::Service => chirp_client::RunContext::Service,
rivet_util::env::RunContext::Test => chirp_client::RunContext::Test,
} as i32,
});
x
};

Ok(OperationContext {
name: O::NAME.to_string(),
timeout: O::TIMEOUT,
conn: self.conn.wrap(self.req_id, ray_id, trace_entry)?,
conn: self.conn.wrap(self.req_id, ray_id, {
let mut x = trace.clone();

// Add new operation's trace to its connection (and chirp client)
x.push(chirp_client::TraceEntry {
context_name: O::NAME.to_string(),
req_id: Some(self.req_id.into()),
ts: rivet_util::timestamp::now(),
run_context: match rivet_util::env::run_context() {
rivet_util::env::RunContext::Service => chirp_client::RunContext::Service,
rivet_util::env::RunContext::Test => chirp_client::RunContext::Test,
} as i32,
});

x
})?,
req_id: self.req_id,
ray_id,
ts: util::timestamp::now(),
req_ts: self.req_ts,
body,
trace,
})
}

Expand All @@ -165,6 +191,7 @@ where
ts: self.ts,
req_ts: self.req_ts,
body: (),
trace: self.trace.clone(),
}
}

Expand Down Expand Up @@ -204,11 +231,11 @@ where
}

pub fn trace(&self) -> &[chirp_client::TraceEntry] {
self.conn.trace()
&self.trace
}

pub fn test(&self) -> bool {
self.trace()
self.trace
.iter()
.any(|x| x.run_context == chirp_client::RunContext::Test as i32)
}
Expand Down
1 change: 1 addition & 0 deletions svc/api/admin/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ impl Ctx {
util::timestamp::now(),
util::timestamp::now(),
(),
Vec::new(),
);

Ctx { op_ctx }
Expand Down
1 change: 1 addition & 0 deletions svc/api/auth/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
// util::timestamp::now(),
// util::timestamp::now(),
// (),
// Vec::new(),
// );

// let (user_id, user_token) = Self::issue_user_token(&op_ctx).await;
Expand Down
1 change: 1 addition & 0 deletions svc/api/cf-verification/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
// util::timestamp::now(),
// util::timestamp::now(),
// (),
// Vec::new(),
// );

// let http_client = rivet_cf_verification::Config::builder()
Expand Down
1 change: 1 addition & 0 deletions svc/api/cloud/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
// util::timestamp::now(),
// util::timestamp::now(),
// (),
// Vec::new(),
// );

// // Create temp team
Expand Down
1 change: 1 addition & 0 deletions svc/api/group/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ impl Ctx {
util::timestamp::now(),
util::timestamp::now(),
(),
Vec::new(),
);

let (_user_id, user_token) = Self::issue_user_token(&op_ctx).await;
Expand Down
1 change: 1 addition & 0 deletions svc/api/identity/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
// util::timestamp::now(),
// util::timestamp::now(),
// (),
// Vec::new(),
// );

// let (primary_region_id, _) = Self::setup_region(&op_ctx).await;
Expand Down
1 change: 1 addition & 0 deletions svc/api/job/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
// util::timestamp::now(),
// util::timestamp::now(),
// (),
// Vec::new(),
// );

// let nomad_config = nomad_util::config_from_env().unwrap();
Expand Down
1 change: 1 addition & 0 deletions svc/api/kv/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
// util::timestamp::now(),
// util::timestamp::now(),
// (),
// Vec::new(),
// );

// let (primary_region_id, _) = Self::setup_region(&op_ctx).await;
Expand Down
1 change: 1 addition & 0 deletions svc/api/matchmaker/tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ impl Ctx {
util::timestamp::now(),
util::timestamp::now(),
(),
Vec::new(),
);

let (primary_region_id, primary_region_name_id) = Self::setup_region(&op_ctx).await;
Expand Down
1 change: 1 addition & 0 deletions svc/api/portal/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ impl Ctx {
util::timestamp::now(),
util::timestamp::now(),
(),
Vec::new(),
);

let (_user_id, user_token) = Self::issue_user_token(&op_ctx).await;
Expand Down
1 change: 1 addition & 0 deletions svc/api/status/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
// util::timestamp::now(),
// util::timestamp::now(),
// (),
// Vec::new(),
// );

// let http_client = rivet_status::Config::builder()
Expand Down
1 change: 1 addition & 0 deletions svc/api/traefik-provider/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ impl Ctx {
util::timestamp::now(),
util::timestamp::now(),
(),
Vec::new(),
);

Ctx { op_ctx }
Expand Down
1 change: 1 addition & 0 deletions svc/pkg/build/standalone/default-create/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ pub async fn run_from_env() -> GlobalResult<()> {
util::timestamp::now(),
util::timestamp::now(),
(),
Vec::new(),
);

for build in DEFAULT_BUILDS {
Expand Down
1 change: 1 addition & 0 deletions svc/pkg/cluster/standalone/datacenter-tls-renew/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub async fn run_from_env(pools: rivet_pools::Pools) -> GlobalResult<()> {
util::timestamp::now(),
util::timestamp::now(),
(),
Vec::new(),
);

let updated_datacenter_ids = rivet_pools::utils::crdb::tx(&ctx.crdb().await?, |tx| {
Expand Down
1 change: 1 addition & 0 deletions svc/pkg/cluster/standalone/default-update/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ pub async fn run_from_env(use_autoscaler: bool) -> GlobalResult<()> {
util::timestamp::now(),
util::timestamp::now(),
(),
Vec::new(),
);

// Read config from env
Expand Down
1 change: 1 addition & 0 deletions svc/pkg/cluster/standalone/gc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub async fn run_from_env(ts: i64, pools: rivet_pools::Pools) -> GlobalResult<()
util::timestamp::now(),
util::timestamp::now(),
(),
Vec::new(),
);

let datacenter_ids = rivet_pools::utils::crdb::tx(&ctx.crdb().await?, |tx| {
Expand Down
1 change: 1 addition & 0 deletions svc/pkg/cluster/standalone/metrics-publish/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub async fn run_from_env(_ts: i64, pools: rivet_pools::Pools) -> GlobalResult<(
util::timestamp::now(),
util::timestamp::now(),
(),
Vec::new(),
);

let servers = select_servers(&ctx).await?;
Expand Down
1 change: 1 addition & 0 deletions svc/pkg/job/standalone/gc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub async fn run_from_env(ts: i64, pools: rivet_pools::Pools) -> GlobalResult<()
ts,
ts,
(),
Vec::new(),
);

// Find jobs to stop.
Expand Down
1 change: 1 addition & 0 deletions svc/pkg/linode/standalone/gc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub async fn run_from_env(pools: rivet_pools::Pools) -> GlobalResult<()> {
util::timestamp::now(),
util::timestamp::now(),
(),
Vec::new(),
);

let dc_rows = sql_fetch_all!(
Expand Down
1 change: 1 addition & 0 deletions svc/pkg/load-test/standalone/api-cloud/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub async fn run_from_env(_ts: i64) -> GlobalResult<()> {
util::timestamp::now(),
util::timestamp::now(),
(),
Vec::new(),
);

// Create temp team
Expand Down
1 change: 1 addition & 0 deletions svc/pkg/load-test/standalone/mm-sustain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub async fn run_from_env(_ts: i64) -> GlobalResult<()> {
util::timestamp::now(),
util::timestamp::now(),
(),
Vec::new(),
);

// Region
Expand Down
1 change: 1 addition & 0 deletions svc/pkg/load-test/standalone/mm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ pub async fn run_from_env(_ts: i64) -> GlobalResult<()> {
util::timestamp::now(),
util::timestamp::now(),
(),
Vec::new(),
);

// Setup
Expand Down
1 change: 1 addition & 0 deletions svc/pkg/load-test/standalone/sqlx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub async fn run_from_env(_ts: i64) -> GlobalResult<()> {
util::timestamp::now(),
util::timestamp::now(),
(),
Vec::new(),
);

let mut interval = tokio::time::interval(std::time::Duration::from_millis(100));
Expand Down
1 change: 1 addition & 0 deletions svc/pkg/load-test/standalone/watch-requests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub async fn run_from_env(_ts: i64) -> GlobalResult<()> {
util::timestamp::now(),
util::timestamp::now(),
(),
Vec::new(),
);

// Create temp team
Expand Down
1 change: 1 addition & 0 deletions svc/pkg/mm/standalone/gc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub async fn run_from_env(ts: i64, pools: rivet_pools::Pools) -> GlobalResult<()
ts,
ts,
(),
Vec::new(),
);
let redis_mm = ctx.redis_mm().await?;

Expand Down
1 change: 1 addition & 0 deletions svc/pkg/telemetry/standalone/beacon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub async fn run_from_env(ts: i64) -> GlobalResult<()> {
util::timestamp::now(),
util::timestamp::now(),
(),
Vec::new(),
);

if std::env::var("RIVET_TELEMETRY_DISABLE")
Expand Down
1 change: 1 addition & 0 deletions svc/pkg/upload/standalone/provider-fill/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub async fn run_from_env() -> GlobalResult<()> {
util::timestamp::now(),
util::timestamp::now(),
(),
Vec::new(),
);

let Ok(backfill_provider) = std::env::var("S3_BACKFILL_PROVIDER") else {
Expand Down
1 change: 1 addition & 0 deletions svc/pkg/user/standalone/delete-pending/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub async fn run_from_env(ts: i64) -> GlobalResult<()> {
util::timestamp::now(),
util::timestamp::now(),
(),
Vec::new(),
);

let user_ids = sql_fetch_all!(
Expand Down
1 change: 1 addition & 0 deletions svc/pkg/user/standalone/search-user-gc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub async fn run_from_env(ts: i64) -> GlobalResult<()> {
util::timestamp::now(),
util::timestamp::now(),
(),
Vec::new(),
);

let mut total_removed = 0;
Expand Down
Loading

0 comments on commit ef2a041

Please sign in to comment.