feat(telemetry): instrument key operations with #[instrument] spans
- auth: login, 2FA, register, password reset/forgot, email change, deletion sweep - git: info_refs / upload+receive pack, and the ssh git process driver - chat: message send plus reminder and outbound webhook sweeps - ci: scheduler sweeps, runner reap, outbound delivery, schedule discovery and retention prune - pulls merge, search index run, import job processing all spans use skip_all so request payloads never land in span fields
ZhenYi committed
Modified lib/auth/src/services/email.rs lib/auth/src/services/email.rs +2 −0 View lib/auth/src/services/email.rs
@@ -370,6 +370,7 @@
370370 })
371371 }
372372
373 #[tracing::instrument(name = "auth.request_email_change", skip_all)]
373374 pub async fn request_email_change(
374375 &self,
375376 uid: Uuid,
@@ -475,6 +476,7 @@
475476 })
476477 }
477478
479 #[tracing::instrument(name = "auth.confirm_email_change", skip_all)]
478480 pub async fn confirm_email_change(
479481 &self,
480482 uid: Uuid,
Modified lib/auth/src/services/login.rs lib/auth/src/services/login.rs +2 −0 View lib/auth/src/services/login.rs
@@ -72,6 +72,7 @@
7272 result
7373 }
7474
75 #[tracing::instrument(name = "auth.login", skip_all)]
7576 async fn login_inner(
7677 &self,
7778 session: &Session,
@@ -156,6 +157,7 @@
156157 result
157158 }
158159
160 #[tracing::instrument(name = "auth.login_2fa", skip_all)]
159161 async fn login_2fa_inner(
160162 &self,
161163 session: &Session,
Modified lib/auth/src/services/password.rs lib/auth/src/services/password.rs +2 −0 View lib/auth/src/services/password.rs
@@ -46,6 +46,7 @@
4646}
4747
4848impl AuthService {
49 #[tracing::instrument(name = "auth.forgot_password", skip_all)]
4950 pub async fn forgot_password(
5051 &self,
5152 session: &Session,
@@ -115,6 +116,7 @@
115116 })
116117 }
117118
119 #[tracing::instrument(name = "auth.reset_password", skip_all)]
118120 pub async fn reset_password(&self, cmd: ResetPasswordCmd) -> Result<(), AuthError> {
119121 let config = &self.config().auth;
120122 validate_password(&cmd.new_password, &config.password_policy)?;
Modified lib/auth/src/services/register.rs lib/auth/src/services/register.rs +1 −0 View lib/auth/src/services/register.rs
@@ -36,6 +36,7 @@
3636 /// ccept_language is the raw request header; the recipient has no
3737 /// account preference yet (the row is created here), so the mail follows
3838 /// the browser and only falls back to [email].default_locale.
39 #[tracing::instrument(name = "auth.register", skip_all)]
3940 pub async fn register(
4041 &self,
4142 session: &Session,
Modified lib/auth/src/worker.rs lib/auth/src/worker.rs +1 −0 View lib/auth/src/worker.rs
@@ -17,6 +17,7 @@
1717const CHECK_INTERVAL_SECS: u64 = 3600;
1818
1919impl AuthService {
20 #[tracing::instrument(name = "auth.execute_due_deletions", skip_all)]
2021 pub async fn execute_due_deletions(&self) -> Result<u64, crate::errors::AuthError> {
2122 let db = self.db();
2223 let now = OffsetDateTime::now_utc();
Modified lib/chat/src/services/messages.rs lib/chat/src/services/messages.rs +1 −0 View lib/chat/src/services/messages.rs
@@ -369,6 +369,7 @@
369369 Ok(())
370370 }
371371
372 #[tracing::instrument(name = "chat.send_message", skip_all)]
372373 pub async fn send_message(
373374 &self,
374375 caller: Uuid,
Modified lib/chat/src/services/outbound.rs lib/chat/src/services/outbound.rs +1 −0 View lib/chat/src/services/outbound.rs
@@ -398,6 +398,7 @@
398398 Ok(())
399399 }
400400
401 #[tracing::instrument(name = "chat.deliver_webhooks", skip_all)]
401402 pub async fn deliver_pending_webhook_events(&self) -> Result<u64, ChatError> {
402403 let now = OffsetDateTime::now_utc();
403404
Modified lib/chat/src/services/reminders.rs lib/chat/src/services/reminders.rs +1 −0 View lib/chat/src/services/reminders.rs
@@ -178,6 +178,7 @@
178178 Ok(())
179179 }
180180
181 #[tracing::instrument(name = "chat.deliver_reminders", skip_all)]
181182 pub async fn deliver_due_reminders(&self) -> Result<u64, ChatError> {
182183 let now = OffsetDateTime::now_utc();
183184
Modified lib/ci/src/actions_events.rs lib/ci/src/actions_events.rs +2 −0 View lib/ci/src/actions_events.rs
@@ -223,6 +223,7 @@
223223 Ok(())
224224 }
225225
226 #[tracing::instrument(name = "ci.discover_schedules", skip_all)]
226227 pub async fn discover_actions_schedules(&self) -> CiResult<()> {
227228 let repos = models::repo::repos::Entity::find()
228229 .all(self.db_read())
@@ -243,6 +244,7 @@
243244 Ok(())
244245 }
245246
247 #[tracing::instrument(name = "ci.run_schedules", skip_all)]
246248 pub async fn run_due_actions_schedules(&self) -> CiResult<u64> {
247249 let now = OffsetDateTime::now_utc();
248250 let due = actions_schedule::Entity::find()
Modified lib/ci/src/outbound.rs lib/ci/src/outbound.rs +1 −0 View lib/ci/src/outbound.rs
@@ -58,6 +58,7 @@
5858}
5959
6060impl CiService {
61 #[tracing::instrument(name = "ci.deliver_webhooks", skip_all)]
6162 pub async fn deliver_pending_repo_webhooks(&self) -> CiResult<u64> {
6263 let now = OffsetDateTime::now_utc();
6364 let stuck = now - time::Duration::minutes(CLAIM_STUCK_MINUTES);
Modified lib/ci/src/runners.rs lib/ci/src/runners.rs +1 −0 View lib/ci/src/runners.rs
@@ -285,6 +285,7 @@
285285 }
286286
287287 /// Disables runners that stopped heartbeating and revokes their credentials.
288 #[tracing::instrument(name = "ci.reap_runners", skip_all)]
288289 pub async fn reap_stale_runners(&self) -> CiResult<u64> {
289290 let now = OffsetDateTime::now_utc();
290291 let stale_secs = self.config().ci.runner_stale_secs.max(1) as i64;
Modified lib/ci/src/scheduler.rs lib/ci/src/scheduler.rs +5 −0 View lib/ci/src/scheduler.rs
@@ -43,6 +43,7 @@
4343}
4444
4545impl CiService {
46 #[tracing::instrument(name = "ci.advance_jobs", skip_all)]
4647 pub async fn advance_jobs(&self) -> CiResult<u64> {
4748 let runs = workflow_run::Entity::find()
4849 .filter(
@@ -146,6 +147,7 @@
146147 Ok(())
147148 }
148149
150 #[tracing::instrument(name = "ci.enforce_concurrency", skip_all)]
149151 pub async fn enforce_concurrency(&self) -> CiResult<u64> {
150152 let actions_changed = self.enforce_actions_concurrency().await?;
151153 let groups: Vec<GroupRow> = GroupRow::find_by_statement(Statement::from_string(
@@ -490,6 +492,7 @@
490492 Ok(())
491493 }
492494
495 #[tracing::instrument(name = "ci.expire_leases", skip_all)]
493496 pub async fn expire_leases(&self) -> CiResult<u64> {
494497 let now = OffsetDateTime::now_utc();
495498 let max_attempts = self.config().ci.max_attempts;
@@ -576,6 +579,7 @@
576579 Ok(affected)
577580 }
578581
582 #[tracing::instrument(name = "ci.apply_cancellations", skip_all)]
579583 pub async fn apply_cancellations(&self) -> CiResult<u64> {
580584 let now = OffsetDateTime::now_utc();
581585 let grace = self.config().ci.cancel_grace_secs as i64;
@@ -651,6 +655,7 @@
651655 Ok(affected)
652656 }
653657
658 #[tracing::instrument(name = "ci.finalize_runs", skip_all)]
654659 pub async fn finalize_runs(&self) -> CiResult<u64> {
655660 let runs = workflow_run::Entity::find()
656661 .filter(
Modified lib/ci/src/storage.rs lib/ci/src/storage.rs +1 −0 View lib/ci/src/storage.rs
@@ -174,6 +174,7 @@
174174 Ok(out)
175175 }
176176
177 #[tracing::instrument(name = "ci.prune", skip_all)]
177178 pub async fn prune_expired(&self) -> CiResult<u64> {
178179 use models::ci::ci_log_chunk;
179180 use models::ci::workflow_artifact as artifact_entity;
Modified lib/git/src/smart/dispatch.rs lib/git/src/smart/dispatch.rs +2 −0 View lib/git/src/smart/dispatch.rs
@@ -19,6 +19,7 @@
1919
2020const MAX_RPC_BODY: usize = 512 * 1024 * 1024;
2121
22#[tracing::instrument(name = "git.info_refs", skip_all, fields(space, repo))]
2223pub async fn info_refs(
2324 service: &SmartService,
2425 space: &str,
@@ -60,6 +61,7 @@
6061}
6162
6263#[allow(clippy::too_many_arguments)]
64#[tracing::instrument(name = "git.rpc", skip_all, fields(space, repo, op = ?git_service))]
6365pub async fn rpc(
6466 service: &SmartService,
6567 space: &str,
Modified lib/git/src/ssh/handler/channel.rs lib/git/src/ssh/handler/channel.rs +6 −0 View lib/git/src/ssh/handler/channel.rs
@@ -418,6 +418,7 @@
418418
419419/// Drive one duplex git process: pump `rx` into stdin, forward stdout to the
420420/// SSH channel, and collect stderr for diagnostics.
421#[tracing::instrument(name = "git.ssh", skip_all, fields(service = op.service_arg()))]
421422async fn streaming_git(
422423 op: &crate::ssh::handler::git_op::GitOperation,
423424 handle: &russh::server::Handle,
@@ -546,6 +547,11 @@
546547 }
547548}
548549
550#[tracing::instrument(
551 name = "git.ssh",
552 skip_all,
553 fields(service = op.map(|o| o.service_arg()).unwrap_or("none"))
554)]
549555async fn run_git(
550556 op: Option<&crate::ssh::handler::git_op::GitOperation>,
551557 input: &[u8],
Modified lib/import/src/worker.rs lib/import/src/worker.rs +1 −0 View lib/import/src/worker.rs
@@ -181,6 +181,7 @@
181181 })
182182 }
183183
184 #[tracing::instrument(name = "import.process", skip_all)]
184185 async fn process(&self, row: job::Model) {
185186 let heartbeat = self.spawn_heartbeat(row.id);
186187 let outcome = self.run_job(&row).await;
Modified lib/pulls/src/services/merge.rs lib/pulls/src/services/merge.rs +1 −0 View lib/pulls/src/services/merge.rs
@@ -40,6 +40,7 @@
4040impl PullService {
4141 /// `handle` carries the resolved repository, pull row, caller and admin bit
4242 /// so the signature does not repeat four positionally-similar arguments.
43 #[tracing::instrument(name = "pulls.merge", skip_all)]
4344 pub async fn merge_pull(
4445 &self,
4546 space_name: String,
Modified lib/search/src/worker.rs lib/search/src/worker.rs +1 −0 View lib/search/src/worker.rs
@@ -129,6 +129,7 @@
129129 Ok(())
130130 }
131131
132 #[tracing::instrument(name = "search.run_once", skip_all)]
132133 pub async fn run_once(&self) -> Result<bool, SearchError> {
133134 if !self.service.enabled() {
134135 return Ok(false);