Documentation ¶
Index ¶
- Constants
- func CL(ctx context.Context) *zap.Logger
- func CLS(ctx context.Context) *zap.SugaredLogger
- func ImbueContext(ctx context.Context, logger *zap.Logger) context.Context
- func MakeMetricContext(ctx context.Context, opName string) context.Context
- func MakeTraceHooks(serviceName string, sink *MetricsSink) *twirp.ServerHooks
- func NewResponseCodeCapturer(writer http.ResponseWriter) *responseCapturer
- func RunInstrumented(ctx context.Context, name string, sink *MetricsSink, logger *zap.Logger, ...) error
- func WithStack(err twirp.Error) twirp.Error
- type GenericTwirpServer
- type MetricEntry
- type MetricsContext
- func (m *MetricsContext) AddCount(name string, val float64)
- func (m *MetricsContext) AddDuration(name string, duration time.Duration)
- func (m *MetricsContext) AddMetric(name string, val float64, unit cloudwatch.StandardUnit)
- func (m *MetricsContext) Benchmark(name string) *TimeMeasurement
- func (m *MetricsContext) CopyToHarvester(sink *MetricsSink)
- func (m *MetricsContext) CopyToSpan(span tracer.Span)
- func (m *MetricsContext) GetMetric(name string) (val float64, unit cloudwatch.StandardUnit)
- func (m *MetricsContext) GetMetricVal(name string) float64
- func (m *MetricsContext) Reset()
- func (m *MetricsContext) SetCount(name string, val float64)
- func (m *MetricsContext) SetDuration(name string, duration time.Duration)
- func (m *MetricsContext) SetMetric(name string, val float64, unit cloudwatch.StandardUnit)
- type MetricsSink
- type NopLogger
- type ProcessContext
- type ProcessRegistry
- type ShortenedStackTrace
- type StackElement
- type TimeMeasurement
- type TracedGorilla
- type TracedTwirp
Constants ¶
View Source
const MetricsContextKey = "MetricContext"
View Source
const (
RequestTimingKey contextKey = 1
)
View Source
const StackTraceKey = "StackTrace"
Variables ¶
This section is empty.
Functions ¶
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
Types ¶
type GenericTwirpServer ¶
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 ProcessContext ¶
type ProcessContext struct { Parent *ProcessRegistry Name string Done chan struct{} }
func (*ProcessContext) RunPeriodicProcess ¶
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 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
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.