oplog

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2020 License: AGPL-3.0, Apache-2.0 Imports: 2 Imported by: 0

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

View Source
const (
	Success = "success"
	Failure = "failure"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	Namespace string
	Component string
}

func NewManager

func NewManager(namespace, component string) *Manager

func (*Manager) Start

func (m *Manager) Start(operation string, dimensions ...zap.Field) *Operation

type Operation

type Operation struct {
	Manager    *Manager
	Name       string
	Dimensions []zap.Field
	StartTime  time.Time
	EndTime    time.Time
}

func (*Operation) Log

func (o *Operation) Log(err error, fields ...zap.Field)

wrapper handling err

func (*Operation) LogError

func (o *Operation) LogError(err error, fields ...zap.Field)

implies status=Fail

func (*Operation) LogSuccess

func (o *Operation) LogSuccess(fields ...zap.Field)

func (*Operation) LogWarn

func (o *Operation) LogWarn(err error, fields ...zap.Field)

implies status=Fail

func (*Operation) Stop

func (o *Operation) Stop()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL