Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions packages/edge/infra/edge-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ s3-util.workspace = true
edge-monolith-workflow-worker.workspace = true
pegboard-ws.workspace = true

# Singleton
pegboard-usage-metrics-publish.workspace = true

# API
api-edge-monolith-public.workspace = true
api-edge-monolith-edge.workspace = true
20 changes: 10 additions & 10 deletions packages/edge/infra/guard/core/src/proxy_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,11 @@ impl ProxyService {
self.handle_http_request(req, target).await
};

let status = match &res {
Ok(resp) => resp.status().as_u16().to_string(),
Err(_) => "error".to_string(),
};

// Record metrics
let duration_secs = start_time.elapsed().as_secs_f64();
metrics::PROXY_REQUEST_DURATION
Expand All @@ -691,16 +696,11 @@ impl ProxyService {
res
};

let status = match &res {
Ok(resp) => resp.status().as_u16().to_string(),
Err(err) => {
metrics::PROXY_REQUEST_ERROR
.with_label_values(&[&err.to_string()])
.inc();

"error".to_string()
}
};
if let Err(err) = &res {
metrics::PROXY_REQUEST_ERROR
.with_label_values(&[&err.to_string()])
.inc();
}

res
}
Expand Down
40 changes: 20 additions & 20 deletions packages/edge/infra/guard/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,35 @@ name = "rivet_guard"
path = "src/lib.rs"

[dependencies]
rivet-guard-core.workspace = true
tokio.workspace = true
anyhow.workspace = true
tracing.workspace = true
uuid = { version = "1.3", features = ["v4"] }
serde_json = "1.0"
chirp-client.workspace = true
chirp-workflow.workspace = true
clap = { version = "4.3", features = ["derive"] }
rivet-config.workspace = true
rivet-logs.workspace = true
rivet-runtime.workspace = true
rivet-pools.workspace = true
rivet-metrics.workspace = true
cluster.workspace = true
fdb-util.workspace = true
foundationdb.workspace = true
futures = "0.3.30"
game-namespace-resolve-name-id = { path = "../../../../core/services/game/ops/namespace-resolve-name-id" }
global-error.workspace = true
cluster.workspace = true
chirp-workflow.workspace = true
chirp-client.workspace = true
rivet-connection.workspace = true
regex = "1.10.3"
once_cell = "1.19.0"
pegboard.workspace = true
fdb-util.workspace = true
foundationdb.workspace = true
rustls-pemfile = "2.0.0"
rustls = { version = "0.23.25" }
regex = "1.10.3"
rivet-cache.workspace = true
rivet-config.workspace = true
rivet-connection.workspace = true
rivet-guard-core.workspace = true
rivet-logs.workspace = true
rivet-metrics.workspace = true
rivet-pools.workspace = true
rivet-runtime.workspace = true
route = { path = "../../../../core/services/route" }
game-namespace-resolve-name-id = { path = "../../../../core/services/game/ops/namespace-resolve-name-id" }
rustls = { version = "0.23.25" }
rustls-pemfile = "2.0.0"
serde_json = "1.0"
tokio.workspace = true
tracing.workspace = true
types-proto = { path = "../../../../common/types-proto/core", package = "types-proto" }
uuid = { version = "1.3", features = ["v4"] }

[dev-dependencies]
uuid = { version = "1.3", features = ["v4", "fast-rng"] }
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ pub async fn run_from_env(
env_usage.memory += actor.resources.memory_mib as u64;
}

// Clear old metrics because they will never be set to 0 (due to no actors being present and thus no
// metrics update)
pegboard::metrics::ENV_CPU_USAGE.reset();
pegboard::metrics::ENV_MEMORY_USAGE.reset();

// Insert metrics
for ((env_id, client_flavor), usage) in usage_by_env_and_flavor {
pegboard::metrics::ENV_CPU_USAGE
Expand Down
Loading