Better span naming and logging tweaks

This commit is contained in:
Tony Garnock-Jones 2021-10-08 16:37:17 +02:00
parent 3c42b5eaeb
commit baf98d6c54
7 changed files with 16 additions and 9 deletions

View File

@ -16,10 +16,10 @@ use crate::schemas::internal_services;
use syndicate_macros::during;
pub fn boot(t: &mut Activation, ds: Arc<Cap>) {
t.spawn(syndicate::name!("tracker", module = module_path!()), move |t| {
t.spawn(syndicate::name!("dependencies"), move |t| {
Ok(during!(t, ds, language(), <require-service $spec>, |t: &mut Activation| {
tracing::debug!(?spec, "tracking dependencies");
t.spawn_link(syndicate::name!(parent: None, "tracker", spec = ?spec),
t.spawn_link(syndicate::name!(parent: None, "dependencies", spec = ?spec),
enclose!((ds) |t| run(t, ds, spec)));
Ok(())
}))

View File

@ -32,7 +32,7 @@ use crate::script;
use syndicate_macros::during;
pub fn on_demand(t: &mut Activation, config_ds: Arc<Cap>) {
t.spawn(syndicate::name!("on_demand", module = module_path!()), move |t| {
t.spawn(syndicate::name!("config_watcher"), move |t| {
Ok(during!(t, config_ds, language(), <run-service $spec: internal_services::ConfigWatcher>, |t| {
Supervisor::start(
t,

View File

@ -21,7 +21,7 @@ use crate::schemas::external_services::*;
use syndicate_macros::during;
pub fn on_demand(t: &mut Activation, config_ds: Arc<Cap>, root_ds: Arc<Cap>) {
t.spawn(syndicate::name!("on_demand", module = module_path!()), move |t| {
t.spawn(syndicate::name!("daemon"), move |t| {
Ok(during!(t, config_ds, language(), <run-service $spec: DaemonService>, |t| {
Supervisor::start(
t,

View File

@ -10,7 +10,7 @@ use crate::schemas::internal_services::DebtReporter;
use syndicate_macros::during;
pub fn on_demand(t: &mut Activation, ds: Arc<Cap>) {
t.spawn(syndicate::name!("on_demand", module = module_path!()), move |t| {
t.spawn(syndicate::name!("debt_reporter"), move |t| {
Ok(during!(t, ds, language(), <run-service $_spec: DebtReporter>, |t: &mut Activation| {
t.spawn_link(tracing::Span::current(), enclose!((ds) |t| run(t, ds)));
Ok(())

View File

@ -15,7 +15,7 @@ use crate::schemas::internal_services::TcpRelayListener;
use syndicate_macros::during;
pub fn on_demand(t: &mut Activation, ds: Arc<Cap>) {
t.spawn(syndicate::name!("on_demand", module = module_path!()), move |t| {
t.spawn(syndicate::name!("tcp_relay_listener"), move |t| {
Ok(during!(t, ds, language(), <run-service $spec: TcpRelayListener>, |t| {
Supervisor::start(
t,

View File

@ -19,7 +19,7 @@ use crate::schemas::internal_services::UnixRelayListener;
use syndicate_macros::during;
pub fn on_demand(t: &mut Activation, ds: Arc<Cap>) {
t.spawn(syndicate::name!("on_demand", module = module_path!()), move |t| {
t.spawn(syndicate::name!("unix_relay_listener"), move |t| {
Ok(during!(t, ds, language(), <run-service $spec: UnixRelayListener>, |t| {
Supervisor::start(
t,

View File

@ -1018,7 +1018,7 @@ impl<'activation> Activation<'activation> {
let f = Facet::new(Some(self.facet.facet_id));
let facet_id = f.facet_id;
self.state.facet_nodes.insert(facet_id, f);
tracing::debug!(parent_id = ?self.facet.facet_id,
tracing::trace!(parent_id = ?self.facet.facet_id,
?facet_id,
actor_facet_count = ?self.state.facet_nodes.len());
self.state.facet_children.entry(self.facet.facet_id).or_default().insert(facet_id);
@ -1110,7 +1110,7 @@ impl<'activation> Activation<'activation> {
fn _terminate_facet(&mut self, facet_id: FacetId, alive: bool) -> ActorResult {
if let Some(mut f) = self.state.facet_nodes.remove(&facet_id) {
tracing::debug!(actor_facet_count = ?self.state.facet_nodes.len(),
tracing::trace!(actor_facet_count = ?self.state.facet_nodes.len(),
"{} termination of {:?}",
if alive { "living" } else { "post-exit" },
facet_id);
@ -1455,6 +1455,7 @@ impl PartialOrd for Mailbox {
impl Drop for Mailbox {
fn drop(&mut self) {
tracing::debug!("Last reference to mailbox of actor id {:?} was dropped", self.actor_id);
let _ = self.tx.send(SystemMessage::Release);
()
}
@ -1649,6 +1650,12 @@ impl ActorRef {
}
}
impl std::fmt::Debug for ActorRef {
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
write!(f, "#<ActorRef {}>", self.actor_id)
}
}
impl RunningActor {
/// Requests a shutdown of the actor. The shutdown request is
/// handled by the actor's main loop, causing it to terminate with