Documentation
¶
Overview ¶
Package client adds some goodies for clients inside opinionated-server servers.
Nothing here should be called until server.Setup() has been run; we depend on the global tracer and global logger which are setup there.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ServerSetup = false LogMetadata = false LogPayloads = false )
Functions ¶
func GRPCInterceptors ¶ added in v0.0.16
func GRPCInterceptors() ([]grpc.UnaryClientInterceptor, []grpc.StreamClientInterceptor)
GRPCInterceptors returns interceptors that you should use when dialing a remote gRPC service, including instrumentation to log each request and propagate tracing information upstream. Only call this after server.Setup() has been run; we rely on the global logger and global tracer setup there.
We give you this list instead of a DialOption (or wrap Dial ourselves) so that you don't lose the ability to add your own interceptors. (grpc.WithChainUnaryInterceptor will let you pass a list of interceptors to Dial.)
func WrapRoundTripper ¶
func WrapRoundTripper(rt http.RoundTripper) http.RoundTripper
WrapRoundTripper returns a wrapped HTTP round tripper with tracing, logging, and prometheus metrics. It exists for backwards compatibility reasons; new code should use WrapRoundTripperWithOptions.
func WrapRoundTripperWithOptions ¶ added in v0.0.22
func WrapRoundTripperWithOptions(rt http.RoundTripper, options ...RoundTripperOption) http.RoundTripper
WrapRoundTripperWithOptions returns a wrapped version of the provided RoundTripper with tracing, logging, and prometheus metrics. The RoundTripper may be nil, in which case an empty http.Transport will be used.
Types ¶
type RoundTripperOption ¶ added in v0.0.22
type RoundTripperOption func(*roundTripperOptions)
RoundTripperOption customizes the behavior of the RoundTripper returned by WrapRoundTripper.
func WithContextLogger ¶ added in v0.0.22
func WithContextLogger() RoundTripperOption
WithContextLogger causes the RoundTripper returned by WrapRoundTripper to log requests to the context logger (ctxzap), instead of the global logger. Note that logs will be suppressed if there is no logger in the context, because ctxzap returns a NoopLogger and we can't inspect that logger and upgrade it to a real logger.
If WithLogger is specified, this option is ignored and a warning is logged when creating the roundtripper.
func WithLogger ¶ added in v0.0.22
func WithLogger(l *zap.Logger) RoundTripperOption
WithLogger causes the RoundTripper returned by WrapRoundTripper to log requests to the provided log, instead of a global logger.