chore: add more tracing messages
Some checks failed
Test / build (map[name:stable]) (push) Successful in 6m42s
Test / build (map[name:nightly]) (push) Successful in 7m50s
Release Please / Release-plz (push) Failing after 48s

This commit is contained in:
Paul Campbell 2024-12-23 09:44:02 +00:00
parent d96dee302d
commit d65dbd18ee
8 changed files with 50 additions and 11 deletions

View file

@ -69,6 +69,7 @@ impl Actor for ImportAttachmentActor {
.with_context(|| f!("saving attachment {}", file_path.display()))?; // FIXME: (#6) handle error .with_context(|| f!("saving attachment {}", file_path.display()))?; // FIXME: (#6) handle error
let attachment_file = this.ctx.temp_fs.file(&attachment_path); let attachment_file = this.ctx.temp_fs.file(&attachment_path);
// - - - upload the attachment to nextcloud card // - - - upload the attachment to nextcloud card
tracing::info!("Nextcloud: upload attachment");
let attachment = this let attachment = this
.ctx .ctx
.deck_client() .deck_client()
@ -103,6 +104,7 @@ impl Actor for ImportAttachmentActor {
dir.remove() dir.remove()
.with_context(|| f!("deleting temp dir {dir}"))?; // FIXME: (#6) handle error .with_context(|| f!("deleting temp dir {dir}"))?; // FIXME: (#6) handle error
tracing::info!("ImportAttachmentActor finished");
Ok(actor_ref.stop_gracefully().await?) Ok(actor_ref.stop_gracefully().await?)
}); });
} }

View file

@ -67,13 +67,17 @@ impl Actor for ImportCardActor {
let deck_client: DeckClient = this.ctx.deck_client(); let deck_client: DeckClient = this.ctx.deck_client();
p!(this.ctx.prt, "> Importing card: {}", this.trello_card.name); p!(this.ctx.prt, "> Importing card: {}", this.trello_card.name);
tracing::info!(name = %this.trello_card.name, "importing card");
// - - create a nextcloud card // - - create a nextcloud card
let title = NextcloudCardTitle::from(&this.trello_card.name); let title = NextcloudCardTitle::from(&this.trello_card.name);
let desc: Option<NextcloudCardDescription> = match this.trello_card.desc.len() { let desc: Option<NextcloudCardDescription> = match this.trello_card.desc.len() {
0 => None, 0 => None,
_ => Some(NextcloudCardDescription::from(&this.trello_card.desc)), _ => Some(NextcloudCardDescription::from(&this.trello_card.desc)),
}; };
let nextcloud_card = deck_client tracing::info!("Nextcloud: Create card");
let nextcloud_card = this
.ctx
.deck_client()
.create_card( .create_card(
this.nextcloud_board_id, this.nextcloud_board_id,
this.nextcloud_stack_id, this.nextcloud_stack_id,
@ -86,6 +90,7 @@ impl Actor for ImportCardActor {
let mut limit = RateLimit::new("labels & attachments", 10, 10.0, this.ctx.now()); let mut limit = RateLimit::new("labels & attachments", 10, 10.0, this.ctx.now());
// - - for each label on the trello card // - - for each label on the trello card
tracing::trace!(labels = ?this.trello_card.labels, "");
let mut labels = vec![]; let mut labels = vec![];
std::mem::swap(&mut this.trello_card.labels, &mut labels); std::mem::swap(&mut this.trello_card.labels, &mut labels);
for trello_label in labels.into_iter() { for trello_label in labels.into_iter() {
@ -107,7 +112,10 @@ impl Actor for ImportCardActor {
} }
ask!(this.rate_limit_actor, RequestToken)?; ask!(this.rate_limit_actor, RequestToken)?;
let attachments = trello_client tracing::info!("Trello: Fetch card for attachments");
let attachments = this
.ctx
.trello_client()
.card(&this.trello_card.id) .card(&this.trello_card.id)
.await .await
.result? .result?
@ -134,6 +142,7 @@ impl Actor for ImportCardActor {
} }
if this.labels_children.is_empty() && this.attachments_children.is_empty() { if this.labels_children.is_empty() && this.attachments_children.is_empty() {
tracing::info!("ImportAttachmentActor finished");
Ok(actor_ref.stop_gracefully().await?) Ok(actor_ref.stop_gracefully().await?)
} else { } else {
Ok(()) Ok(())
@ -152,15 +161,18 @@ impl Actor for ImportCardActor {
match reason { match reason {
ActorStopReason::Normal => {} ActorStopReason::Normal => {}
_ => { _ => {
tracing::warn!(?reason, "card child died");
return Ok(Some(reason)); return Ok(Some(reason));
} }
} }
tracing::debug!(?this.labels_children, ?this.attachments_children, "card children"); tracing::debug!(?this.labels_children, ?this.attachments_children, "card children");
if this.labels_children.is_empty() && this.attachments_children.is_empty() { if this.labels_children.is_empty() && this.attachments_children.is_empty() {
tracing::info!("ImportCardActor finished");
return Ok(Some(ActorStopReason::Normal)); return Ok(Some(ActorStopReason::Normal));
} }
tracing::info!("ImportCardActor not finished");
Ok(None) Ok(None)
}); });
} }

View file

@ -48,7 +48,9 @@ impl Actor for ImportLabelActor {
trello_color: this.trello_label.color.clone() trello_color: this.trello_label.color.clone()
} }
)?; // FIXME: (#6) handle error )?; // FIXME: (#6) handle error
// - - - add the label to the nextcloud card
// - - - add the label to the nextcloud card
tracing::info!("Nextcloud: add label to card");
this.ctx this.ctx
.deck_client() .deck_client()
.add_label_to_card( .add_label_to_card(
@ -60,6 +62,7 @@ impl Actor for ImportLabelActor {
.await .await
.result?; // FIXME: (#6) handle error .result?; // FIXME: (#6) handle error
tracing::info!("ImportLabelActor finished");
Ok(actor_ref.stop_gracefully().await?) Ok(actor_ref.stop_gracefully().await?)
}); });
} }

View file

@ -7,12 +7,13 @@ use kameo::{
message::{Context, Message}, message::{Context, Message},
Actor, Actor,
}; };
use tracing::instrument;
use crate::{ use crate::{
nextcloud::model::{ nextcloud::model::{
NextcloudBoardId, NextcloudLabelColour, NextcloudLabelId, NextcloudLabelTitle, NextcloudBoardId, NextcloudLabelColour, NextcloudLabelId, NextcloudLabelTitle,
}, },
on_actor_start, p, on_actor_start,
trello::model::label::{TrelloLabelColor, TrelloLabelName}, trello::model::label::{TrelloLabelColor, TrelloLabelName},
FullCtx, FullCtx,
}; };
@ -49,12 +50,14 @@ impl Actor for LabelsActor {
}); });
} }
#[derive(Debug)]
pub(crate) struct LookupNextcloudLabelId { pub(crate) struct LookupNextcloudLabelId {
pub(crate) trello_name: TrelloLabelName, pub(crate) trello_name: TrelloLabelName,
pub(crate) trello_color: TrelloLabelColor, pub(crate) trello_color: TrelloLabelColor,
} }
impl Message<LookupNextcloudLabelId> for LabelsActor { impl Message<LookupNextcloudLabelId> for LabelsActor {
type Reply = Result<NextcloudLabelId, kxio::Error>; type Reply = Result<NextcloudLabelId, kxio::Error>;
#[instrument(skip(self, _ctx))]
async fn handle( async fn handle(
&mut self, &mut self,
msg: LookupNextcloudLabelId, msg: LookupNextcloudLabelId,
@ -64,29 +67,31 @@ impl Message<LookupNextcloudLabelId> for LabelsActor {
.lookup .lookup
.get(&NextcloudLabelTitle::new(msg.trello_name.as_ref())) .get(&NextcloudLabelTitle::new(msg.trello_name.as_ref()))
{ {
Some(nextcloud_label_id) => nextcloud_label_id, Some(nextcloud_label_id) => {
tracing::info!(?nextcloud_label_id, "found");
nextcloud_label_id
}
None => { None => {
p!( let color_hex = get_color_hex(msg.trello_color.as_ref());
self.ctx.prt, tracing::info!(color = ?msg.trello_color, ?color_hex, "Label not found in nextcloud board, creating");
">> Label not found in nextcloud board, creating"
);
let label = self let label = self
.ctx .ctx
.deck_client() .deck_client()
.create_label( .create_label(
self.nextcloud_board_id, self.nextcloud_board_id,
&NextcloudLabelTitle::new(msg.trello_name.as_ref()), &NextcloudLabelTitle::new(msg.trello_name.as_ref()),
&NextcloudLabelColour::new(get_color_hex(msg.trello_color.as_ref())), &NextcloudLabelColour::new(color_hex),
) )
.await .await
.result?; .result?;
tracing::info!(?label, "created");
self.lookup.insert(label.title.clone(), label.id); self.lookup.insert(label.title.clone(), label.id);
self.lookup self.lookup
.get(&NextcloudLabelTitle::new(msg.trello_name.as_ref())) .get(&NextcloudLabelTitle::new(msg.trello_name.as_ref()))
.expect("label was just inserted") .expect("label was just inserted")
} }
}; };
tracing::info!(?nextcloud_label_id, "responding");
Ok(*nextcloud_label_id) Ok(*nextcloud_label_id)
} }
} }

View file

@ -104,6 +104,7 @@ impl Actor for ImportStackActor {
match reason { match reason {
ActorStopReason::Normal => {} ActorStopReason::Normal => {}
_ => { _ => {
tracing::warn!(?reason, "stack child died");
return Ok(Some(reason)); return Ok(Some(reason));
} }
} }

View file

@ -169,6 +169,7 @@ impl Actor for ImportStacksActor {
match reason { match reason {
ActorStopReason::Normal => {} ActorStopReason::Normal => {}
_ => { _ => {
tracing::warn!(?reason, "stacks child died");
return Ok(Some(reason)); return Ok(Some(reason));
} }
} }

View file

@ -17,6 +17,7 @@ impl Actor for Supervisor {
reason: ActorStopReason, reason: ActorStopReason,
) -> Result<Option<ActorStopReason>, BoxError> { ) -> Result<Option<ActorStopReason>, BoxError> {
// normally when ImportStacksActor stops it would not cause the supervisor to stop, but we want it to stop. // normally when ImportStacksActor stops it would not cause the supervisor to stop, but we want it to stop.
tracing::warn!(?reason, "supervisor child died");
Ok(Some(reason)) Ok(Some(reason))
} }
} }

View file

@ -6,6 +6,7 @@ use kxio::{
}; };
use reqwest::multipart; use reqwest::multipart;
use serde_json::json; use serde_json::json;
use tracing::instrument;
use crate::nextcloud::model::NextcloudOrder; use crate::nextcloud::model::NextcloudOrder;
use crate::{ use crate::{
@ -46,12 +47,14 @@ impl<'ctx> DeckClient<'ctx> {
) )
} }
#[instrument(skip_all)]
async fn request<T: for<'a> serde::Deserialize<'a>>( async fn request<T: for<'a> serde::Deserialize<'a>>(
&self, &self,
url: impl Into<String>, url: impl Into<String>,
custom: fn(&Net, String) -> ReqBuilder, custom: fn(&Net, String) -> ReqBuilder,
) -> APIResult<T> { ) -> APIResult<T> {
let url = url.into(); let url = url.into();
tracing::trace!(?url);
APIResult::new( APIResult::new(
with_exponential_backoff!( with_exponential_backoff!(
&self.ctx, &self.ctx,
@ -67,6 +70,7 @@ impl<'ctx> DeckClient<'ctx> {
.await .await
} }
#[instrument(skip_all)]
async fn request_with_body<T: for<'a> serde::Deserialize<'a>>( async fn request_with_body<T: for<'a> serde::Deserialize<'a>>(
&self, &self,
url: impl Into<String>, url: impl Into<String>,
@ -91,20 +95,24 @@ impl<'ctx> DeckClient<'ctx> {
.await .await
} }
#[instrument(skip(self))]
pub(crate) async fn get_boards(&self) -> APIResult<Vec<Board>> { pub(crate) async fn get_boards(&self) -> APIResult<Vec<Board>> {
self.request("boards", |net, url| net.get(url)).await self.request("boards", |net, url| net.get(url)).await
} }
#[instrument(skip(self))]
pub(crate) async fn get_board(&self, board_id: NextcloudBoardId) -> APIResult<Board> { pub(crate) async fn get_board(&self, board_id: NextcloudBoardId) -> APIResult<Board> {
self.request(f!("boards/{board_id}"), |net, url| net.get(url)) self.request(f!("boards/{board_id}"), |net, url| net.get(url))
.await .await
} }
#[instrument(skip(self))]
pub(crate) async fn get_stacks(&self, board_id: NextcloudBoardId) -> APIResult<Vec<Stack>> { pub(crate) async fn get_stacks(&self, board_id: NextcloudBoardId) -> APIResult<Vec<Stack>> {
self.request(f!("boards/{board_id}/stacks"), |net, url| net.get(url)) self.request(f!("boards/{board_id}/stacks"), |net, url| net.get(url))
.await .await
} }
#[instrument(skip(self))]
pub(crate) async fn get_stack( pub(crate) async fn get_stack(
&self, &self,
board_id: NextcloudBoardId, board_id: NextcloudBoardId,
@ -116,6 +124,7 @@ impl<'ctx> DeckClient<'ctx> {
.await .await
} }
#[instrument(skip(self))]
pub(crate) async fn create_stack( pub(crate) async fn create_stack(
&self, &self,
board_id: NextcloudBoardId, board_id: NextcloudBoardId,
@ -134,6 +143,7 @@ impl<'ctx> DeckClient<'ctx> {
.await .await
} }
#[instrument(skip(self))]
pub(crate) async fn create_card( pub(crate) async fn create_card(
&self, &self,
board_id: NextcloudBoardId, board_id: NextcloudBoardId,
@ -157,6 +167,7 @@ impl<'ctx> DeckClient<'ctx> {
.await .await
} }
#[instrument(skip(self))]
pub(crate) async fn create_label( pub(crate) async fn create_label(
&self, &self,
board_id: NextcloudBoardId, board_id: NextcloudBoardId,
@ -175,6 +186,7 @@ impl<'ctx> DeckClient<'ctx> {
.await .await
} }
#[instrument(skip(self))]
pub(crate) async fn get_card( pub(crate) async fn get_card(
&self, &self,
board_id: NextcloudBoardId, board_id: NextcloudBoardId,
@ -188,6 +200,7 @@ impl<'ctx> DeckClient<'ctx> {
.await .await
} }
#[instrument(skip(self))]
pub(crate) async fn add_label_to_card( pub(crate) async fn add_label_to_card(
&self, &self,
board_id: NextcloudBoardId, board_id: NextcloudBoardId,
@ -206,6 +219,7 @@ impl<'ctx> DeckClient<'ctx> {
.await .await
} }
#[instrument(skip(self))]
pub(crate) async fn add_attachment_to_card( pub(crate) async fn add_attachment_to_card(
&self, &self,
board_id: NextcloudBoardId, board_id: NextcloudBoardId,