package binarylog
Import Path
google.golang.org/grpc/internal/binarylog (on go.dev)
Dependency Relation
imports 20 packages, and imported by one package
Involved Source Files
Package binarylog implementation binary logging as defined in
https://github.com/grpc/proposal/blob/master/A16-binary-logging.md.
binarylog_testutil.go
env_config.go
method_logger.go
sink.go
Package-Level Type Names (total 19, in which 14 are exported)
Cancel configs the binary log entry to be a Cancel entry.
OnClientSide bool
(*Cancel) toProto() *binlogpb.GrpcLogEntry
*Cancel : LogEntryConfig
ClientHalfClose configs the binary log entry to be a ClientHalfClose entry.
OnClientSide bool
(*ClientHalfClose) toProto() *binlogpb.GrpcLogEntry
*ClientHalfClose : LogEntryConfig
ClientHeader configs the binary log entry to be a ClientHeader entry.
Authority string
Header metadata.MD
MethodName string
OnClientSide bool
PeerAddr is required only when it's on server side.
Timeout time.Duration
(*ClientHeader) toProto() *binlogpb.GrpcLogEntry
*ClientHeader : LogEntryConfig
ClientMessage configs the binary log entry to be a ClientMessage entry.
Message can be a proto.Message or []byte. Other messages formats are not
supported.
OnClientSide bool
(*ClientMessage) toProto() *binlogpb.GrpcLogEntry
*ClientMessage : LogEntryConfig
LogEntryConfig represents the configuration for binary log entry.
( LogEntryConfig) toProto() *binlogpb.GrpcLogEntry
*Cancel
*ClientHalfClose
*ClientHeader
*ClientMessage
*ServerHeader
*ServerMessage
*ServerTrailer
func MethodLogger.Log(LogEntryConfig)
func (*TruncatingMethodLogger).Build(c LogEntryConfig) *binlogpb.GrpcLogEntry
func (*TruncatingMethodLogger).Log(c LogEntryConfig)
Logger is the global binary logger. It can be used to get binary logger for
each method.
( Logger) GetMethodLogger(methodName string) MethodLogger
*logger
func GetLogger() Logger
func NewLoggerFromConfig(config LoggerConfig) Logger
func NewLoggerFromConfigString(s string) Logger
func SetLogger(l Logger)
func google.golang.org/grpc.binaryLogger(bl Logger) grpc.ServerOption
func google.golang.org/grpc.withBinaryLogger(bl Logger) grpc.DialOption
var AllLogger
var binLogger
LoggerConfig contains the config for loggers to create method loggers.
All *MethodLoggerConfig
Blacklist map[string]struct{}
Methods map[string]*MethodLoggerConfig
Services map[string]*MethodLoggerConfig
func NewLoggerFromConfig(config LoggerConfig) Logger
MethodLogger is the sub-logger for each method.
( MethodLogger) Log(LogEntryConfig)
*TruncatingMethodLogger
func GetMethodLogger(methodName string) MethodLogger
func Logger.GetMethodLogger(methodName string) MethodLogger
MethodLoggerConfig contains the setting for logging behavior of a method
logger. Currently, it contains the max length of header and message.
Max length of header and message.
Max length of header and message.
ServerHeader configs the binary log entry to be a ServerHeader entry.
Header metadata.MD
OnClientSide bool
PeerAddr is required only when it's on client side.
(*ServerHeader) toProto() *binlogpb.GrpcLogEntry
*ServerHeader : LogEntryConfig
ServerMessage configs the binary log entry to be a ServerMessage entry.
Message can be a proto.Message or []byte. Other messages formats are not
supported.
OnClientSide bool
(*ServerMessage) toProto() *binlogpb.GrpcLogEntry
*ServerMessage : LogEntryConfig
ServerTrailer configs the binary log entry to be a ServerTrailer entry.
Err is the status error.
OnClientSide bool
PeerAddr is required only when it's on client side and the RPC is trailer
only.
Trailer metadata.MD
(*ServerTrailer) toProto() *binlogpb.GrpcLogEntry
*ServerTrailer : LogEntryConfig
Sink writes log entry into the binary log sink.
sink is a copy of the exported binarylog.Sink, to avoid circular dependency.
Close will be called when the Sink is replaced by a new Sink.
Write will be called to write the log entry into the sink.
It should be thread-safe so it can be called in parallel.
*bufferedSink
*noopSink
*writerSink
Sink : io.Closer
func NewBufferedSink(o io.WriteCloser) Sink
func newWriterSink(w io.Writer) Sink
var DefaultSink
TruncatingMethodLogger is a method logger that truncates headers and messages
based on configured fields.
callID uint64
headerMaxLen uint64
idWithinCallGen *callIDGenerator
messageMaxLen uint64
// TODO(blog): make this plugable.
Build is an internal only method for building the proto message out of the
input event. It's made public to enable other library to reuse as much logic
in TruncatingMethodLogger as possible.
Log creates a proto binary log entry, and logs it to the sink.
(*TruncatingMethodLogger) truncateMessage(msgPb *binlogpb.Message) (truncated bool)
(*TruncatingMethodLogger) truncateMetadata(mdPb *binlogpb.Metadata) (truncated bool)
*TruncatingMethodLogger : MethodLogger
func NewTruncatingMethodLogger(h, m uint64) *TruncatingMethodLogger
Package-Level Functions (total 15, in which 7 are exported)
GetLogger gets the binary logger.
Only call this at init time.
GetMethodLogger returns the MethodLogger for the given methodName.
methodName should be in the format of "/service/method".
Each MethodLogger returned by this method is a new instance. This is to
generate sequence id within the call.
NewBufferedSink creates a binary log sink with the given WriteCloser.
Write() marshals the proto message and writes it to the given writer. Each
message is prefixed with a 4 byte big endian unsigned integer as the length.
Content is kept in a buffer, and is flushed every 60 seconds.
Close closes the WriteCloser.
NewLoggerFromConfig builds a logger with the given LoggerConfig.
NewLoggerFromConfigString reads the string and build a logger. It can be used
to build a new logger and assign it to binarylog.Logger.
Example filter config strings:
- "" Nothing will be logged
- "*" All headers and messages will be fully logged.
- "*{h}" Only headers will be logged.
- "*{m:256}" Only the first 256 bytes of each message will be logged.
- "Foo/*" Logs every method in service Foo
- "Foo/*,-Foo/Bar" Logs every method in service Foo except method /Foo/Bar
- "Foo/*,Foo/Bar{m:256}" Logs the first 256 bytes of each message in method
/Foo/Bar, logs all headers and messages in every other method in service
Foo.
If two configs exist for one certain method or service, the one specified
later overrides the previous config.
NewTruncatingMethodLogger returns a new truncating method logger.
SetLogger sets the binary logger.
Only call this at init time.
Package-Level Variables (total 11, in which 4 are exported)
AddrToProto converts an address to a binary logging proto message. It's
for testing only.
AllLogger is a logger that logs all headers/messages for all RPCs. It's
for testing only.
DefaultSink is the sink where the logs will be written to. It's exported
for the binarylog package to update.
MdToMetadataProto converts metadata to a binary logging proto message.
It's for testing only.
Package-Level Constants (total 7, none are exported)
The pages are generated with Golds v0.4.9. (GOOS=linux GOARCH=amd64)