Skip to content

Where is structured logging appropriate (with tracing) #509

@DanGould

Description

@DanGould

re:

I noticed that we initialize a tracing subscriber in a every test but don't really seem to be using tracing much, instead using log::debug in most places. Is there a reason to keep using tracing in tests or should we just remove that dependency too and use log instead?

@spacebear21

We can easily convert log::x to tracing::x to take advantage of tracing's additional context. There's also the tracing-log crate to have dependency log::x handled as tracing::x calls.

I feel like tracing calls would be especially useful for payment processors depending on payjoin, like bria, since they depend heavily on structured logging, but I have to admit I'm green to the ins-and-outs of a well maintained system of structured logging.

I thought we should take advantage of tracing's structured logs in payjoin-directory, ohttp-relay, and payjoin-cli to provide structured logging for downstream users. It gives way more context across closure boundaries and with async, and the logs can be filtered dynamically. I figured this would be good for debugging and uptime monitoring in particular, but I do wonder if it's at odds with our goals for privacy. We're certainly not taking advantage of it yet. tracing lets us provide the kind of polish I'd like our actual kit to have post-1.0. If we figure out how to do that I reckon it makes sense to do in tests too.

Is it overly complex in tests? We're definitely not using it to leverage what we print in CI vs local. hard to say. @0xBEEFCAF3 @nothingmuch any comment on where we should be using structured logs

Originally posted by @DanGould in #507 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions