Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log format is changed. #297

Closed
FancyQian opened this issue Dec 6, 2024 · 6 comments · Fixed by #299
Closed

Log format is changed. #297

FancyQian opened this issue Dec 6, 2024 · 6 comments · Fixed by #299
Labels
bug Something isn't working

Comments

@FancyQian
Copy link

Describe the bug
I upgraded from "0.10.2" to "0.13.3" and I found that the prefix of the log is not the name of a single atcor, but also includes the chain of supervisors. Although this is good to tracing, a very simple log will become very long. Which code is related to this modification? Or how to configure it to shorten it to a concise log?

2024-12-06T09:50:56.369278Z  INFO Actor{id="0.7" name="ConnectionService"}:Actor{id="0.17" name="192.168.1.18:33456"}:Actor{id="0.19" name="192.168.1.18:33456-reader"}: Onboarding: ....

To Reproduce
Supervisors actor, tracing log, log init code

          let dir = tracing_subscriber::filter::Directive::from(LevelFilter::from(log_level));
      
          let filter = vec![dir]
              .into_iter()
              .fold(EnvFilter::from_default_env(), |filter, directive| {
                  filter.add_directive(directive)
              });

            use tracing_glog::Glog;
            use tracing_glog::GlogFields;

            let fmt = tracing_subscriber::fmt::Layer::default()
                .with_ansi(stderr().is_terminal())
                .with_writer(std::io::stderr)
                .event_format(Glog::default().with_timer(tracing_glog::LocalTime::default()))
                .fmt_fields(GlogFields::default().compact());

            let subscriber = Registry::default().with(filter).with(fmt);
            tracing::subscriber::set_global_default(subscriber)
                .expect("to set GLOG global subscriber");

Expected behavior
The log can be shorten or flexible customization

@FancyQian FancyQian added the bug Something isn't working label Dec 6, 2024
@FancyQian FancyQian changed the title Log formart is changed. Log format is changed. Dec 6, 2024
@slawlor
Copy link
Owner

slawlor commented Dec 6, 2024

This was changed in #266

You can probably customize your tracing subscriber to exclude/truncate it, but at the moment tracing propagation is automatically added for you. We did look at making it optional, however the ergonomics were deemed too clunky and we decided better to opt-in universally.

However for the supervisor->child logging, it should only double-print the actor id during pre_start() messages, since that executes on the supervisor's blocking spawn or spawn_linked. Once the child is started and running, future messages will only show the child id.

@FancyQian
Copy link
Author

@slawlor thanks, the ture thing is the supervisor->child logging is not only "double-print the actor id during pre_start()" messages in my project, let me deep into that..

@FancyQian
Copy link
Author

Looks like each actor handler has span message as well, it may too noise..

        // The current [tracing::Span] is retrieved, boxed, and included in every
        // `BoxedMessage` during the conversion of this `TActor::Msg`. It is used
        // to automatically continue tracing span nesting when sending messages to Actors.
        let current_span_when_message_was_sent = msg.span.take();

        // An error here will bubble up to terminate the actor
        let typed_msg = TActor::Msg::from_boxed(msg)?;

        if let Some(span) = current_span_when_message_was_sent {
            handler
                .handle(myself, typed_msg, state)

@slawlor
Copy link
Owner

slawlor commented Dec 11, 2024

I'm adding an opt-out feature for this. it'll be enabled by default, but can selectively be turned off

@texascloud
Copy link
Contributor

Does an opt-out fix the problem of the spans looking goofy?

@FancyQian
Copy link
Author

FancyQian commented Dec 13, 2024

@texascloud yes, the #299 is working as expected

ractor = { version = "0.13.5", default-features = false, features = ["tokio_runtime", "async-trait"] }

thank you @slawlor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants