Skip to content

Commit 7f677bf

Browse files
committed
feat(deployer): add more tracing events
1 parent 3d5c55b commit 7f677bf

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

deployer/src/handlers/mod.rs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use shuttle_common::project::ProjectName;
1919
use shuttle_common::LogItem;
2020
use tower_http::auth::RequireAuthorizationLayer;
2121
use tower_http::trace::TraceLayer;
22-
use tracing::{debug, debug_span, error, field, trace, Span};
22+
use tracing::{debug, debug_span, error, field, instrument, trace, Span};
2323
use tracing_opentelemetry::OpenTelemetrySpanExt;
2424
use uuid::Uuid;
2525

@@ -121,6 +121,7 @@ pub fn make_router(
121121
.layer(Extension(project_name))
122122
}
123123

124+
#[instrument(skip_all)]
124125
async fn list_services(
125126
Extension(persistence): Extension<Persistence>,
126127
) -> Result<Json<Vec<shuttle_common::models::service::Response>>> {
@@ -134,9 +135,10 @@ async fn list_services(
134135
Ok(Json(services))
135136
}
136137

138+
#[instrument(skip(persistence))]
137139
async fn get_service(
138140
Extension(persistence): Extension<Persistence>,
139-
Path((_project_name, service_name)): Path<(String, String)>,
141+
Path((project_name, service_name)): Path<(String, String)>,
140142
) -> Result<Json<shuttle_common::models::service::Detailed>> {
141143
if let Some(service) = persistence.get_service_by_name(&service_name).await? {
142144
let deployments = persistence
@@ -171,10 +173,11 @@ async fn get_service(
171173
}
172174
}
173175

176+
#[instrument(skip_all, fields(%project_name, %service_name))]
174177
async fn get_service_summary(
175178
Extension(persistence): Extension<Persistence>,
176179
Extension(proxy_fqdn): Extension<FQDN>,
177-
Path((_, service_name)): Path<(String, String)>,
180+
Path((project_name, service_name)): Path<(String, String)>,
178181
) -> Result<Json<shuttle_common::models::service::Summary>> {
179182
if let Some(service) = persistence.get_service_by_name(&service_name).await? {
180183
let deployment = persistence
@@ -201,10 +204,11 @@ async fn get_service_summary(
201204
}
202205
}
203206

207+
#[instrument(skip_all, fields(%project_name, %service_name))]
204208
async fn post_service(
205209
Extension(persistence): Extension<Persistence>,
206210
Extension(deployment_manager): Extension<DeploymentManager>,
207-
Path((_project_name, service_name)): Path<(String, String)>,
211+
Path((project_name, service_name)): Path<(String, String)>,
208212
Query(params): Query<HashMap<String, String>>,
209213
mut stream: BodyStream,
210214
) -> Result<Json<shuttle_common::models::deployment::Response>> {
@@ -243,10 +247,11 @@ async fn post_service(
243247
Ok(Json(deployment.into()))
244248
}
245249

250+
#[instrument(skip_all, fields(%project_name, %service_name))]
246251
async fn delete_service(
247252
Extension(persistence): Extension<Persistence>,
248253
Extension(deployment_manager): Extension<DeploymentManager>,
249-
Path((_project_name, service_name)): Path<(String, String)>,
254+
Path((project_name, service_name)): Path<(String, String)>,
250255
) -> Result<Json<shuttle_common::models::service::Detailed>> {
251256
if let Some(service) = persistence.get_service_by_name(&service_name).await? {
252257
let old_deployments = persistence
@@ -285,9 +290,10 @@ async fn delete_service(
285290
}
286291
}
287292

293+
#[instrument(skip_all, fields(%project_name, %deployment_id))]
288294
async fn get_deployment(
289295
Extension(persistence): Extension<Persistence>,
290-
Path((_project_name, deployment_id)): Path<(String, Uuid)>,
296+
Path((project_name, deployment_id)): Path<(String, Uuid)>,
291297
) -> Result<Json<shuttle_common::models::deployment::Response>> {
292298
if let Some(deployment) = persistence.get_deployment(&deployment_id).await? {
293299
Ok(Json(deployment.into()))
@@ -296,10 +302,11 @@ async fn get_deployment(
296302
}
297303
}
298304

305+
#[instrument(skip_all, fields(%project_name, %deployment_id))]
299306
async fn delete_deployment(
300307
Extension(deployment_manager): Extension<DeploymentManager>,
301308
Extension(persistence): Extension<Persistence>,
302-
Path((_project_name, deployment_id)): Path<(String, Uuid)>,
309+
Path((project_name, deployment_id)): Path<(String, Uuid)>,
303310
) -> Result<Json<shuttle_common::models::deployment::Response>> {
304311
if let Some(deployment) = persistence.get_deployment(&deployment_id).await? {
305312
deployment_manager.kill(deployment.id).await;
@@ -310,9 +317,10 @@ async fn delete_deployment(
310317
}
311318
}
312319

320+
#[instrument(skip_all, fields(%project_name, %deployment_id))]
313321
async fn get_logs(
314322
Extension(persistence): Extension<Persistence>,
315-
Path((_project_name, deployment_id)): Path<(String, Uuid)>,
323+
Path((project_name, deployment_id)): Path<(String, Uuid)>,
316324
) -> Result<Json<Vec<LogItem>>> {
317325
if let Some(deployment) = persistence.get_deployment(&deployment_id).await? {
318326
Ok(Json(
@@ -389,9 +397,10 @@ async fn logs_websocket_handler(mut s: WebSocket, persistence: Persistence, id:
389397
let _ = s.close().await;
390398
}
391399

400+
#[instrument(skip_all, fields(%project_name, %service_name))]
392401
async fn get_secrets(
393402
Extension(persistence): Extension<Persistence>,
394-
Path((_project_name, service_name)): Path<(String, String)>,
403+
Path((project_name, service_name)): Path<(String, String)>,
395404
) -> Result<Json<Vec<secret::Response>>> {
396405
if let Some(service) = persistence.get_service_by_name(&service_name).await? {
397406
let keys = persistence

deployer/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ pub async fn start(
3737
args.artifacts_path,
3838
);
3939

40-
for existing_deployment in persistence.get_all_runnable_deployments().await.unwrap() {
40+
let runnable_deployments = persistence.get_all_runnable_deployments().await.unwrap();
41+
info!(count = %runnable_deployments.len(), "enqueuing runnable deployments");
42+
for existing_deployment in runnable_deployments {
4143
let built = Built {
4244
id: existing_deployment.id,
4345
service_name: existing_deployment.service_name,
@@ -56,7 +58,7 @@ pub async fn start(
5658
);
5759
let make_service = router.into_make_service();
5860

59-
info!("Binding to and listening at address: {}", args.api_address);
61+
info!(address=%args.api_address, "Binding to and listening at address");
6062

6163
axum::Server::bind(&args.api_address)
6264
.serve(make_service)

0 commit comments

Comments
 (0)