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
Distributed tracing and other context in logging #1281
Comments
@mickeyreiss Thanks a lot for the feedback/idea. I don't think it's something I've seen asked before or that we've considered. We'll have a look into potential improvements and circle back! |
This is something we'd be very interested in too. We do provide our own We deal with a large number of Stripe accounts for different tenants (a mix of Stripe Connect and stand-alone accounts). While the Stripe log message do contain a Stripe I can think of a couple of possible approaches. Allow a call specific logger to be provided via params := &stripe.PaymentIntentParams{}
params.Context = ctx
params.Logger = logger
params.SetStripeAccount(acct)
pi, err := api.PaymentIntents.Get(piID, params) Add a ContextLeveledLogger interface type ContextLeveledLoggerInterface interface {
// Debugf logs a debug message using Printf conventions.
Debugf(ctx context.Context, format string, v ...interface{})
// etc Our implementation of this interface could then extract a tenant and request identifier from the context -- or more likely an entire logger. Thanks for considering these options. |
The current logging interface does not seem to allow callers to inject structured fields, such as trace ids, into the log lines. While custom loggers are acceptable, only global instances are acceptable, and the logging interface only passes Stripe's log messages as arguments.
In my setup, I use
context.Context
to pass request ids into my logger, which in turn includes these request ids in the structured log lines that are written to stderr. Systems like OpenCensus/OpenTelemetry/OpenTracing also use context to pass correlation tokens through.It would be nice if the Stripe SDK had support for this, so that I could more easily correlate Stripe's logging with incoming requests. While it is possible to do this to a certain extent by overriding the
http.Transaport
, I'd like to take full advantage of the diagnostic logging that is already built into this library.I am curious if this has already been thought through, or if others have solutions. If not, it would be great to add support for this into the logging interfaces.
The current API, for reference:
stripe-go/stripe.go
Lines 181 to 195 in ebbff36
stripe-go/log.go
Lines 124 to 142 in ebbff36
The text was updated successfully, but these errors were encountered: