Skip to content

Commit eeb9b08

Browse files
committed
fix: fix pb metrics standalone (#2518)
<!-- Please make sure there is an issue that this PR is correlated to. --> ## Changes <!-- If there are frontend changes, please include screenshots. -->
1 parent 1e6fef3 commit eeb9b08

File tree

6 files changed

+33
-14
lines changed

6 files changed

+33
-14
lines changed

packages/common/chirp-workflow/core/src/db/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ pub trait Database: Send {
299299
) -> WorkflowResult<()>;
300300
}
301301

302+
#[derive(Debug)]
302303
pub struct WorkflowData {
303304
pub workflow_id: Uuid,
304305
input: Box<serde_json::value::RawValue>,

packages/edge/services/pegboard/src/keys/client.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,9 @@ pub struct ActorSubspaceKey {
299299

300300
impl ActorSubspaceKey {
301301
fn new(client_id: Uuid) -> Self {
302-
ActorSubspaceKey { client_id: Some(client_id) }
302+
ActorSubspaceKey {
303+
client_id: Some(client_id),
304+
}
303305
}
304306

305307
fn entire() -> Self {

packages/edge/services/pegboard/src/metrics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ lazy_static::lazy_static! {
4444
&["env_id", "flavor"],
4545
*REGISTRY,
4646
).unwrap();
47-
47+
4848
pub static ref ENV_MEMORY_USAGE: IntGaugeVec = register_int_gauge_vec_with_registry!(
4949
"pegboard_env_memory_usage",
5050
"Total MiB of memory used by an environment.",

packages/edge/services/pegboard/src/ops/actor/get.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,21 +117,20 @@ pub async fn pegboard_actor_get(ctx: &OperationCtx, input: &Input) -> GlobalResu
117117

118118
let actor_data = futures_util::stream::iter(actors_with_wf_ids)
119119
.map(|(actor_id, workflow_id)| async move {
120-
let pool = &match ctx.sqlite_for_workflow(workflow_id).await {
120+
let pool = match ctx.sqlite_for_workflow(workflow_id).await {
121121
Ok(x) => x,
122122
Err(err)
123123
if matches!(
124124
err.as_workflow_error(),
125125
Some(WorkflowError::WorkflowNotFound)
126126
) =>
127127
{
128-
// Workflow is complete
129-
return GlobalResult::Ok(None);
130-
}
131-
Err(err) => {
132-
return GlobalResult::Err(err);
128+
tracing::warn!(?actor_id, ?workflow_id, "actor workflow not found");
129+
return Ok(None);
133130
}
131+
res => res?,
134132
};
133+
let pool = &pool;
135134

136135
let (actor_row, port_ingress_rows, port_host_rows, port_proxied_rows) = tokio::try_join!(
137136
sql_fetch_one!(

packages/edge/services/pegboard/src/workflows/client/mod.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ pub async fn pegboard_client(ctx: &mut WorkflowCtx, input: &Input) -> GlobalResu
106106
config,
107107
system,
108108
}),
109-
activity(UpdateMetricsInput { client_id, flavor, clear: false }),
109+
activity(UpdateMetricsInput {
110+
client_id,
111+
flavor,
112+
clear: false,
113+
}),
110114
))
111115
.await?;
112116
}
@@ -118,7 +122,11 @@ pub async fn pegboard_client(ctx: &mut WorkflowCtx, input: &Input) -> GlobalResu
118122
client_id,
119123
events: events.clone(),
120124
}),
121-
activity(UpdateMetricsInput { client_id, flavor, clear: false }),
125+
activity(UpdateMetricsInput {
126+
client_id,
127+
flavor,
128+
clear: false,
129+
}),
122130
))
123131
.await?;
124132

@@ -243,7 +251,12 @@ pub async fn pegboard_client(ctx: &mut WorkflowCtx, input: &Input) -> GlobalResu
243251
})
244252
.await?;
245253

246-
ctx.activity(UpdateMetricsInput { client_id: input.client_id, flavor: input.flavor, clear: true }).await?;
254+
ctx.activity(UpdateMetricsInput {
255+
client_id: input.client_id,
256+
flavor: input.flavor,
257+
clear: true,
258+
})
259+
.await?;
247260

248261
let actors = ctx
249262
.activity(FetchRemainingActorsInput {
@@ -675,7 +688,11 @@ pub async fn handle_commands(
675688
activity(InsertCommandsInput {
676689
commands: raw_commands.clone(),
677690
}),
678-
activity(UpdateMetricsInput { client_id, flavor, clear: false }),
691+
activity(UpdateMetricsInput {
692+
client_id,
693+
flavor,
694+
clear: false,
695+
}),
679696
))
680697
.await?;
681698

packages/edge/services/pegboard/standalone/usage-metrics-publish/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub async fn run_from_env(
3232
.wrap_new("pegboard-usage-metrics-publish");
3333
let cache = rivet_cache::CacheInner::from_env(&config, pools.clone())?;
3434
let ctx = StandaloneCtx::new(
35-
db::DatabaseCrdbNats::from_pools(pools.clone())?,
35+
db::DatabaseFdbSqliteNats::from_pools(pools.clone())?,
3636
config,
3737
rivet_connection::Connection::new(client, pools, cache),
3838
"pegboard-usage-metrics-publish",
@@ -68,7 +68,7 @@ pub async fn run_from_env(
6868
.try_collect::<Vec<_>>()
6969
.await
7070
})
71-
.custom_instrument(tracing::info_span!("client_fetch_remaining_actors_tx"))
71+
.custom_instrument(tracing::info_span!("fetch_running_actors_tx"))
7272
.await?;
7373

7474
let actors_res = ctx

0 commit comments

Comments
 (0)