visibility

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2019 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const MetricsNamespaceName = "Metrics"
View Source
const OperationNameKey = "Operation"
View Source
const ZapLoggerEchoContextKey = "ZapLogger"

Variables

View Source
var NullSink = &nullSink{}

Functions

func CL

func CL(ctx context.Context) *zap.Logger

func CLS

func CLS(ctx context.Context) *zap.SugaredLogger

func ExtractSegmentMetrics

func ExtractSegmentMetrics(segment *xray.Segment) []cloudwatch.MetricDatum

func GetZapLoggerFromEchoLogger

func GetZapLoggerFromEchoLogger(logger echo.Logger) *zap.Logger

func ImbueContext

func ImbueContext(ctx context.Context, logger *zap.Logger) context.Context

func IsAmznTraceId

func IsAmznTraceId(id string) bool

Check if ID is in X-Ray format that looks like: 1-5759e988-bd862e3fe1be46a994272793;parent_id=...

func OapiRequestValidatorWithMetrics

func OapiRequestValidatorWithMetrics(swagger *openapi3.Swagger,
	apiPath string, validator AuthValidatorFunc, sink MetricsSink) echo.MiddlewareFunc

Create middleware to validate requests against OAPI3 specification. Additionally this middleware initialized the metric context for the request with appropriate metrics and submits this segment at the end of the request.

Each request gets annotated with the following metrics: Success: 0 or 1 (count). 0 if the request errors out or panics. Fault: 0 or 1 (count). 1 if the request panics. Time: request duration (time)

func RunInstrumented

func RunInstrumented(ctx context.Context, name string, sink MetricsSink,
	logger *zap.Logger, fn func(context.Context) error) error

RunInstrumented() traces the provided synchronous function by beginning and closing a new subsegment around its execution. If the parent segment doesn't exist yet then a new top-level segment is created

func SetOperationNameForMetrics

func SetOperationNameForMetrics(segment *xray.Segment, opName string)

func TracingAndLoggingMiddlewareHook

func TracingAndLoggingMiddlewareHook(opts TracingAndMetricsOptions) echo.MiddlewareFunc

Insert middleware responsible for logging, metrics and tracing

func XrayLogAdapter

func XrayLogAdapter(logger *zap.Logger, minLevel xraylog.LogLevel) xraylog.Logger

Types

type AuthValidatorFunc

type AuthValidatorFunc func(e echo.Context, input *openapi3filter.AuthenticationInput) error

type DefaultMetricsSink

type DefaultMetricsSink struct {
	AwsConfig aws.Config
	AppName   string
	Suffix    string
	// contains filtered or unexported fields
}

func NewMetricsSink

func NewMetricsSink(awsConfig aws.Config, appName string, suffix string) *DefaultMetricsSink

func (*DefaultMetricsSink) SendMetrics

func (m *DefaultMetricsSink) SendMetrics(ctx context.Context) error

func (*DefaultMetricsSink) SubmitSegmentMetrics

func (m *DefaultMetricsSink) SubmitSegmentMetrics(seg *xray.Segment)

type MetricEntry

type MetricEntry struct {
	Val       float64
	Unit      cloudwatch.StandardUnit
	Timestamp time.Time
}

type MetricsContext

type MetricsContext struct {
	// contains filtered or unexported fields
}

func GetMetricContext

func GetMetricContext(segment *xray.Segment) *MetricsContext

func (*MetricsContext) AddCount

func (m *MetricsContext) AddCount(name string, val float64)

func (*MetricsContext) AddDuration

func (m *MetricsContext) AddDuration(name string, duration time.Duration)

func (*MetricsContext) AddMetric

func (m *MetricsContext) AddMetric(name string, val float64, unit cloudwatch.StandardUnit)

func (*MetricsContext) Benchmark

func (m *MetricsContext) Benchmark(name string) *TimeMeasurement

func (*MetricsContext) GetMetric added in v1.2.0

func (m *MetricsContext) GetMetric(name string) (val float64, unit cloudwatch.StandardUnit)

func (*MetricsContext) GetMetricVal added in v1.3.2

func (m *MetricsContext) GetMetricVal(name string) float64

func (*MetricsContext) Reset added in v1.2.0

func (m *MetricsContext) Reset()

Remove all metrics for the context, useful for tests

func (*MetricsContext) SetCount

func (m *MetricsContext) SetCount(name string, val float64)

func (*MetricsContext) SetDuration

func (m *MetricsContext) SetDuration(name string, duration time.Duration)

func (*MetricsContext) SetMetric

func (m *MetricsContext) SetMetric(name string, val float64, unit cloudwatch.StandardUnit)

type MetricsSink

type MetricsSink interface {
	SubmitSegmentMetrics(seg *xray.Segment)
}

type ProcessContext

type ProcessContext struct {
	Parent *ProcessRegistry
	Name   string
	Done   chan struct{}
}

func (*ProcessContext) Run

func (pc *ProcessContext) Run(proc func(ctx context.Context) error)

func (*ProcessContext) RunPeriodicProcess

func (pc *ProcessContext) RunPeriodicProcess(period time.Duration,
	proc func(ctx context.Context) error)

func (*ProcessContext) Wait

func (pc *ProcessContext) Wait()

type ProcessRegistry

type ProcessRegistry struct {
	// contains filtered or unexported fields
}

func NewProcessRegistry

func NewProcessRegistry(xraySuffix string, logger *zap.Logger,
	metrics MetricsSink) *ProcessRegistry

func (*ProcessRegistry) Close

func (p *ProcessRegistry) Close()

func (*ProcessRegistry) CreateProcessContext

func (p *ProcessRegistry) CreateProcessContext(name string) ProcessContext

func (*ProcessRegistry) GetWaitChannel

func (p *ProcessRegistry) GetWaitChannel(processName string) <-chan struct{}

func (*ProcessRegistry) HasProcess

func (p *ProcessRegistry) HasProcess(name string) bool

func (*ProcessRegistry) LogRunning

func (p *ProcessRegistry) LogRunning() string

type TimeMeasurement

type TimeMeasurement struct {
	// contains filtered or unexported fields
}

func (*TimeMeasurement) Done

func (t *TimeMeasurement) Done()

type TracingAndMetricsOptions

type TracingAndMetricsOptions struct {
	DebugMode  bool
	XrayName   string
	EnableXray bool

	HostNameOverride string

	Logger       *zap.Logger
	XRayLogLevel xraylog.LogLevel
}

func (*TracingAndMetricsOptions) Validate

func (t *TracingAndMetricsOptions) Validate()

type XrayStackTrace

type XrayStackTrace struct {
	// contains filtered or unexported fields
}

func NewXrayStackTrace

func NewXrayStackTrace(skipFrames int, msg interface{}) *XrayStackTrace

func (*XrayStackTrace) Error

func (s *XrayStackTrace) Error() string

func (*XrayStackTrace) Field

func (s *XrayStackTrace) Field() zap.Field

func (*XrayStackTrace) JSONStack

func (s *XrayStackTrace) JSONStack() interface{}

func (*XrayStackTrace) StackTrace

func (s *XrayStackTrace) StackTrace() []uintptr

type ZapLoggerWrapper

type ZapLoggerWrapper struct {
	// contains filtered or unexported fields
}

func NewLoggerWrapper

func NewLoggerWrapper(zLogger *zap.Logger) *ZapLoggerWrapper

Create a new wrapper for an Echo logger, imbued with a contextualized Zap logger

func (*ZapLoggerWrapper) Debug

func (l *ZapLoggerWrapper) Debug(i ...interface{})

func (*ZapLoggerWrapper) Debugf

func (l *ZapLoggerWrapper) Debugf(format string, args ...interface{})

func (*ZapLoggerWrapper) Debugj

func (l *ZapLoggerWrapper) Debugj(j log.JSON)

func (*ZapLoggerWrapper) Error

func (l *ZapLoggerWrapper) Error(i ...interface{})

func (*ZapLoggerWrapper) Errorf

func (l *ZapLoggerWrapper) Errorf(format string, args ...interface{})

func (*ZapLoggerWrapper) Errorj

func (l *ZapLoggerWrapper) Errorj(j log.JSON)

func (*ZapLoggerWrapper) Fatal

func (l *ZapLoggerWrapper) Fatal(i ...interface{})

func (*ZapLoggerWrapper) Fatalf

func (l *ZapLoggerWrapper) Fatalf(format string, args ...interface{})

func (*ZapLoggerWrapper) Fatalj

func (l *ZapLoggerWrapper) Fatalj(j log.JSON)

func (*ZapLoggerWrapper) Info

func (l *ZapLoggerWrapper) Info(i ...interface{})

func (*ZapLoggerWrapper) Infof

func (l *ZapLoggerWrapper) Infof(format string, args ...interface{})

func (*ZapLoggerWrapper) Infoj

func (l *ZapLoggerWrapper) Infoj(j log.JSON)

func (*ZapLoggerWrapper) Level

func (l *ZapLoggerWrapper) Level() log.Lvl

func (*ZapLoggerWrapper) Output

func (l *ZapLoggerWrapper) Output() io.Writer

func (*ZapLoggerWrapper) Panic

func (l *ZapLoggerWrapper) Panic(i ...interface{})

func (*ZapLoggerWrapper) Panicf

func (l *ZapLoggerWrapper) Panicf(format string, args ...interface{})

func (*ZapLoggerWrapper) Panicj

func (l *ZapLoggerWrapper) Panicj(j log.JSON)

func (*ZapLoggerWrapper) Prefix

func (l *ZapLoggerWrapper) Prefix() string

func (*ZapLoggerWrapper) Print

func (l *ZapLoggerWrapper) Print(i ...interface{})

func (*ZapLoggerWrapper) Printf

func (l *ZapLoggerWrapper) Printf(format string, args ...interface{})

func (*ZapLoggerWrapper) Printj

func (l *ZapLoggerWrapper) Printj(j log.JSON)

func (*ZapLoggerWrapper) SetHeader

func (l *ZapLoggerWrapper) SetHeader(h string)

func (*ZapLoggerWrapper) SetLevel

func (l *ZapLoggerWrapper) SetLevel(lvl log.Lvl)

func (ZapLoggerWrapper) SetOutput

func (l ZapLoggerWrapper) SetOutput(w io.Writer)

func (*ZapLoggerWrapper) SetPrefix

func (l *ZapLoggerWrapper) SetPrefix(s string)

func (*ZapLoggerWrapper) Warn

func (l *ZapLoggerWrapper) Warn(i ...interface{})

func (*ZapLoggerWrapper) Warnf

func (l *ZapLoggerWrapper) Warnf(format string, args ...interface{})

func (*ZapLoggerWrapper) Warnj

func (l *ZapLoggerWrapper) Warnj(j log.JSON)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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