Documentation ¶
Overview ¶
Package oplog implements standard (but extensible) logging for operations (events with status, start/end times). Useful for operational queries and dashboarding with CloudWatch Insights/Metrics. Using standard attributes describing operations and their status allows easy creation of Cloudwatch alarms for discrete system operations. The 3 level (namespace, component, operation) hierarchy enables grouping when graphing/querying. For example, if the hierarchy has top level namespace of "logprocessor" then you can see all errors where namespace="logprocessor" in single graph/query. Similarly you can compute latency and other performance related metrics in aggregate over different _standard_ dimensions.
Example usage:
manager := oplog.NewManager("panther", "logprocessor") // record every S3 object read operation := manager.Start("readlogfile") defer func() { operation.Stop() operation.Log(err, zap.String("bucket", bucket), zap.String("object", object)) }() ... code to read log from S3
Index ¶
- Constants
- type Manager
- type Operation
- func (o *Operation) Log(err error, fields ...zap.Field)
- func (o *Operation) LogError(err error, fields ...zap.Field)
- func (o *Operation) LogSuccess(fields ...zap.Field)
- func (o *Operation) LogWarn(err error, fields ...zap.Field)
- func (o *Operation) Stop() *Operation
- func (o *Operation) WithMemStats() *Operation
- func (o *Operation) WithMemUsed(availableMemMB int) *Operation
Constants ¶
const ( Success = "success" Failure = "failure" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
func NewManager ¶
type Operation ¶
type Operation struct { Manager *Manager Name string Dimensions []zap.Field StartTime time.Time EndTime time.Time StartMemStats *runtime.MemStats // can be nil! EndMemStats *runtime.MemStats // can be nil! AvailableMemMB int // if not zero, the available memory, use to calc percentage }