actix: fix docs, namespace metrics

This commit is contained in:
asonix 2024-01-13 16:37:44 -05:00
parent 8797127077
commit ab6ab53b9a
3 changed files with 11 additions and 9 deletions

View file

@ -23,6 +23,7 @@ tokio = { version = "1", default-features = false, features = [
"macros", "macros",
"rt", "rt",
"sync", "sync",
"time",
"tracing", "tracing",
] } ] }
uuid = { version = "1", features = ["v7", "serde"] } uuid = { version = "1", features = ["v7", "serde"] }

View file

@ -99,11 +99,11 @@
//! // Jobs can optionally override this value //! // Jobs can optionally override this value
//! const BACKOFF: Backoff = Backoff::Exponential(2); //! const BACKOFF: Backoff = Backoff::Exponential(2);
//! //!
//! // When should the job be considered dead //! // This is important for allowing the job server to reap processes that were started but never
//! // completed.
//! // //! //
//! // The timeout defines when a job is allowed to be considered dead, and so can be retried //! // Defaults to 5 seconds
//! // by the job processor. The value is in milliseconds and defaults to 15,000 //! const HEARTBEAT_INTERVAL: u64 = 5_000;
//! const TIMEOUT: i64 = 15_000;
//! //!
//! fn run(self, state: MyState) -> Self::Future { //! fn run(self, state: MyState) -> Self::Future {
//! println!("{}: args, {:?}", state.app_name, self); //! println!("{}: args, {:?}", state.app_name, self);
@ -197,7 +197,7 @@ impl Manager {
notified.await; notified.await;
metrics::counter!("background-jobs.worker-arbiter.restart", "number" => i.to_string()).increment(1); metrics::counter!("background-jobs.actix.worker-arbiter.restart", "number" => i.to_string()).increment(1);
tracing::warn!("Recovering from dead worker arbiter"); tracing::warn!("Recovering from dead worker arbiter");
drop(worker_arbiter); drop(worker_arbiter);

View file

@ -16,7 +16,7 @@ struct LocalWorkerStarter<State: Clone + 'static, Extras: 'static> {
impl<State: Clone + 'static, Extras: 'static> Drop for LocalWorkerStarter<State, Extras> { impl<State: Clone + 'static, Extras: 'static> Drop for LocalWorkerStarter<State, Extras> {
fn drop(&mut self) { fn drop(&mut self) {
metrics::counter!("background-jobs.worker.finished", "queue" => self.queue.clone()) metrics::counter!("background-jobs.actix.worker.finished", "queue" => self.queue.clone())
.increment(1); .increment(1);
let res = std::panic::catch_unwind(|| actix_rt::Arbiter::current().spawn(async move {})); let res = std::panic::catch_unwind(|| actix_rt::Arbiter::current().spawn(async move {}));
@ -141,7 +141,8 @@ pub(crate) async fn local_worker<State, Extras>(
State: Clone + 'static, State: Clone + 'static,
Extras: 'static, Extras: 'static,
{ {
metrics::counter!("background-jobs.worker.started", "queue" => queue.clone()).increment(1); metrics::counter!("background-jobs.actix.worker.started", "queue" => queue.clone())
.increment(1);
let starter = LocalWorkerStarter { let starter = LocalWorkerStarter {
queue: queue.clone(), queue: queue.clone(),
@ -166,7 +167,7 @@ pub(crate) async fn local_worker<State, Extras>(
{ {
Ok(job) => job, Ok(job) => job,
Err(e) => { Err(e) => {
metrics::counter!("background-jobs.worker.failed-request").increment(1); metrics::counter!("background-jobs.actix.worker.failed-request").increment(1);
let display_val = format!("{}", e); let display_val = format!("{}", e);
let debug = format!("{:?}", e); let debug = format!("{:?}", e);
@ -201,7 +202,7 @@ pub(crate) async fn local_worker<State, Extras>(
.instrument(return_span.clone()) .instrument(return_span.clone())
.await .await
{ {
metrics::counter!("background-jobs.worker.failed-return").increment(1); metrics::counter!("background-jobs.actix.worker.failed-return").increment(1);
let display_val = format!("{}", e); let display_val = format!("{}", e);
let debug = format!("{:?}", e); let debug = format!("{:?}", e);