You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
@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 LeveledLogger which integrates the Stripe logging into our log stream, but we are unable to surface our tenant or request identifiers without access to the context.Context of the call.
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 request_id it can be time consuming to reverse this back to a particular Stripe Account or tenant on our side.
I can think of a couple of possible approaches.
Allow a call specific logger to be provided via stripe.Params
We provide a context.Context for each call anyhow (which does give us http span monitoring). It would be easy for us to provide a call specific LeveledLogger also.
Add a ContextLeveledLogger interface
And prefer to use this if it is provided when the SDK is instantiated. You would need to pass the context from the call stripe.Params to it.
typeContextLeveledLoggerInterfaceinterface {
// Debugf logs a debug message using Printf conventions. Debugf(ctx context.Context, formatstring, 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.
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: