Documentation
¶
Index ¶
- func DefaultActionNameExtractor(r *http.Request) string
- func LegacyActionNameExtractor(r *http.Request) string
- func Log(c HasContext, severity LogLevel, format string, args ...interface{})
- func LogDebug(c HasContext, format string, args ...interface{})
- func LogError(c HasContext, format string, args ...interface{})
- func LogFatal(c HasContext, format string, args ...interface{})
- func LogInfo(c HasContext, format string, args ...interface{})
- func LogWarn(c HasContext, format string, args ...interface{})
- func NewMiddleware(handler http.Handler) http.Handler
- func SetLogjamHeaders(hasContext HasContext, outgoing *http.Request)
- func SetupAgent(options *AgentOptions)
- func ShutdownAgent()
- type ActionNameExtractor
- type AgentOptions
- type HasContext
- type LogLevel
- type Logger
- type Request
- func (r *Request) AddCount(key string, value int64)
- func (r *Request) AddDuration(key string, value time.Duration)
- func (r *Request) AugmentRequest(incoming *http.Request) *http.Request
- func (r *Request) Count(key string)
- func (r *Request) Finish(metrics httpsnoop.Metrics)
- func (r *Request) GetField(key string) interface{}
- func (r *Request) MeasureDuration(key string, f func())
- func (r *Request) NewContext(c context.Context) context.Context
- func (r *Request) SetField(key string, value interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultActionNameExtractor ¶
DefaultActionNameExtractor replaces slashes with "::" and camel cases the individual path segments.
func LegacyActionNameExtractor ¶
LegacyActionNameExtractor is an extractor used in older versions of this package. Use it if you want to keep old action names in Logjam.
func Log ¶
func Log(c HasContext, severity LogLevel, format string, args ...interface{})
Log takes a context to be able to collect all logs within the same request. If you're using gin-gonic, please pass the (*gin.Context).Request.Context() Maximum line length is 2048 characters.
func LogDebug ¶
func LogDebug(c HasContext, format string, args ...interface{})
LogDebug calls Log with DEBUG severity.
func LogError ¶
func LogError(c HasContext, format string, args ...interface{})
LogError calls Log with ERROR severity.
func LogFatal ¶
func LogFatal(c HasContext, format string, args ...interface{})
LogFatal calls Log with FATAL severity.
func LogInfo ¶
func LogInfo(c HasContext, format string, args ...interface{})
LogInfo calls Log with INFO severity.
func LogWarn ¶
func LogWarn(c HasContext, format string, args ...interface{})
LogWarn calls Log with WARN severity.
func NewMiddleware ¶
NewMiddleware can be used to wrap any standard http.Handler.
func SetLogjamHeaders ¶
func SetLogjamHeaders(hasContext HasContext, outgoing *http.Request)
SetLogjamHeaders makes sure all X-Logjam-* Headers are copied into the outgoing request. Call this before you call other APIs.
func SetupAgent ¶
func SetupAgent(options *AgentOptions)
SetupAgent configures application name, environment name and ZeroMQ socket options.
Types ¶
type ActionNameExtractor ¶
ActionNameExtractor takes a HTTP request and returns a logjam conformant action name.
type AgentOptions ¶
type AgentOptions struct {
AppName string // Name of your application
EnvName string // What environment you're running in (production, preview, ...)
Endpoints string // Comma separated list of ZeroMQ connections specs, defaults to localhost
Port int // ZeroMQ default port for ceonnection specs
Linger int // ZeroMQ socket option of the same name
Sndhwm int // ZeroMQ socket option of the same name
Rcvhwm int // ZeroMQ socket option of the same name
Sndtimeo int // ZeroMQ socket option of the same name
Rcvtimeo int // ZeroMQ socket option of the same name
Logger Logger // TODO: why is this an option?
ActionNameExtractor ActionNameExtractor // Function to transform path segments to logjam action names.
}
AgentOptions such as appliction name, environment and ZeroMQ oscket options.
type HasContext ¶
HasContext is any object that reponds to the Context method.
type Logger ¶
type Logger interface {
Println(v ...interface{})
Printf(fmt string, v ...interface{})
}
Logger must provide some methods to let Logjam output its logs.
type Request ¶
type Request struct {
Action string // The action name for this request.
// contains filtered or unexported fields
}
Request encapsulates information about the current logjam request.
func GetRequest ¶
GetRequest retrieves a logjam request from a Context. Returns nil of no request is stored in the context.
func NewRequest ¶
NewRequest creates a new logjam request for a given action name.
func (*Request) AddDuration ¶
AddDuration increases increments a timer metric associated with this request.
func (*Request) AugmentRequest ¶
AugmentRequest extends a given http request with a logjam request stored in its context.
func (*Request) MeasureDuration ¶
MeasureDuration is a helper function that records the duration of execution of the passed function in cases where it is cumbersome to just use AddDuration instead.
func (*Request) NewContext ¶
NewContext creates a new context with the request added.