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

Garbage characters when using tracing #72

Closed
mamcx opened this issue Sep 29, 2023 · 4 comments
Closed

Garbage characters when using tracing #72

mamcx opened this issue Sep 29, 2023 · 4 comments

Comments

@mamcx
Copy link

mamcx commented Sep 29, 2023

The tracy client show garbage characters in the output.

When I instrument code like

    #[tracing::instrument(skip(self, tx))]
    pub fn iter<'a>(&'a self, tx: &'a MutTxId, table_id: u32) -> Result<Iter<'a>, DBError> {

the table_id: u32 parameter is joined as zone:

iter{�[3mtable_id�[0m�[2m=�[0m1}

I expect it to be

iter (table_id:1)

or similar.

@Ralith
Copy link
Contributor

Ralith commented Sep 29, 2023

Those look like ANSI escape codes. Perhaps something's trying to pretty-print that information for display in a terminal?

@mamcx
Copy link
Author

mamcx commented Sep 29, 2023

Yes, they are. But how disable them for tracy?

We have the config here.

But we don't want to disable it globally:

    let fmt_layer = tracing_subscriber::fmt::Layer::default()
        .with_writer(write_to)
        .event_format(format)
        .with_ansi(false); <-- Need only for tracy

    let env_filter_layer = parse_from_file(&conf_file);

    let tracy_layer = if std::env::var("SPACETIMEDB_TRACY").is_ok() {
        Some(tracing_tracy::TracyLayer::new())
    } else {
        None
    };

    let subscriber = tracing_subscriber::Registry::default()
        .with(fmt_layer)
        .with(tracy_layer)
        .with(flame_layer);

@mamcx
Copy link
Author

mamcx commented Sep 29, 2023

Oh, just reordering the layers works:

    let subscriber = tracing_subscriber::Registry::default()
        .with(tracy_layer)
        .with(fmt_layer)
        .with(flame_layer);

@mamcx mamcx closed this as completed Sep 29, 2023
@nagisa
Copy link
Owner

nagisa commented Sep 29, 2023

Does it truly? I would expect that doing so should change the output of the stdout logs? The truly correct thing to do would be to provide a different type (even if just a newtype) for formatter. That way tracing-tracy will not attempt to re-use a formatted event/span representation from the other layer(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants