visibility

package
v0.0.0-...-5f47e43 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2020 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const MetricsContextKey = "MetricContext"
View Source
const (
	RequestTimingKey contextKey = 1
)
View Source
const StackTraceKey = "StackTrace"

Variables

This section is empty.

Functions

func CL

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

func CLS

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

func ImbueContext

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

func MakeMetricContext

func MakeMetricContext(ctx context.Context, opName string) context.Context

func MakeTraceHooks

func MakeTraceHooks(serviceName string, sink *MetricsSink) *twirp.ServerHooks

func NewResponseCodeCapturer

func NewResponseCodeCapturer(writer http.ResponseWriter) *responseCapturer

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 WithStack

func WithStack(err twirp.Error) twirp.Error

Types

type GenericTwirpServer

type GenericTwirpServer interface {
	http.Handler
	ServiceDescriptor() ([]byte, int)
	ProtocGenTwirpVersion() string
	PathPrefix() string
}

type MetricEntry

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

func (MetricEntry) Normalize

func (e MetricEntry) Normalize() (float64, cloudwatch.StandardUnit)

Normalize unit to use the smallest possible unit: microsecond, bit, byte

type MetricsContext

type MetricsContext struct {
	Lock    sync.Mutex
	OpName  string
	Metrics map[string]*MetricEntry
}

func GetMetricsFromContext

func GetMetricsFromContext(ctx context.Context) *MetricsContext

func TryGetMetricsFromContext

func TryGetMetricsFromContext(ctx context.Context) *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) CopyToHarvester

func (m *MetricsContext) CopyToHarvester(sink *MetricsSink)

func (*MetricsContext) CopyToSpan

func (m *MetricsContext) CopyToSpan(span tracer.Span)

func (*MetricsContext) GetMetric

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

func (*MetricsContext) GetMetricVal

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

func (*MetricsContext) Reset

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 struct {
	StatsClient statsd.ClientInterface
}

type NopLogger

type NopLogger struct {
}

func (NopLogger) Log

func (n NopLogger) Log(msg string)

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(sink *MetricsSink, logger *zap.Logger) *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 ShortenedStackTrace

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

func NewShortenedStackTrace

func NewShortenedStackTrace(skipFrames int, skipToFirstPanic bool,
	msg interface{}) *ShortenedStackTrace

Create a new shortened stack trace, that can optionally skip all the frames after the first panic() call (typically deferred error handlers).

func (*ShortenedStackTrace) Error

func (s *ShortenedStackTrace) Error() string

func (*ShortenedStackTrace) Field

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

func (*ShortenedStackTrace) JSONStack

func (s *ShortenedStackTrace) JSONStack() []StackElement

Create a nice stack trace, skipping all the deferred frames after the first panic() call.

func (*ShortenedStackTrace) StackTrace

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

func (*ShortenedStackTrace) StringStack

func (s *ShortenedStackTrace) StringStack() string

Create a nice stack trace, skipping all the deferred frames after the first panic() call.

type StackElement

type StackElement struct {
	Fl string
	Fn string
}

type TimeMeasurement

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

func (*TimeMeasurement) Done

func (t *TimeMeasurement) Done()

type TracedGorilla

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

func NewTracedGorilla

func NewTracedGorilla(twirpServer GenericTwirpServer, logger *zap.Logger,
	sampleRate *float64, errorSampleRate *float64) *TracedGorilla

func (*TracedGorilla) AttachGorillaToMuxer

func (t *TracedGorilla) AttachGorillaToMuxer(router *mux.Router)

type TracedTwirp

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

Directories

Path Synopsis
Licensed under Apache License Version 2.0.
Licensed under Apache License Version 2.0.

Jump to

Keyboard shortcuts

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