visibility

package
v0.0.0-...-c8e4165 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2021 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2016-2019 Datadog, Inc.

Index

Constants

View Source
const ClientTypeCanary = "canary"
View Source
const ClientTypeNormal = "normal"
View Source
const ClientTypeTag = "client-type"
View Source
const MetricsContextKey = "MetricContext"
View Source
const RequestHeaderKey = 11
View Source
const (
	RequestTimingKey contextKey = 1
)
View Source
const StackTraceKey = "StackTrace"

Variables

View Source
var DefAnalyticsRate = math.NaN()

Functions

func CL

func CL(ctx context.Context, opts ...zap.Option) *zap.Logger

func CLS

func CLS(ctx context.Context, opts ...zap.Option) *zap.SugaredLogger

func ClientTypeFromSpan

func ClientTypeFromSpan(sp tracer.Span) string

func ContextWithClientType

func ContextWithClientType(ctx context.Context, ct string) context.Context

func ContextWithStatsd

func ContextWithStatsd(ctx context.Context, sink statsd.ClientInterface) context.Context

func GetClientTypeFromContext

func GetClientTypeFromContext(ctx context.Context) string

func GetHttpRequestHeader

func GetHttpRequestHeader(ctx context.Context) (http.Header, bool)

func GetStatsdFromContext

func GetStatsdFromContext(ctx context.Context) statsd.ClientInterface

func ImbueContext

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

func InstrumentWithMetrics

func InstrumentWithMetrics(ctx context.Context, fn func(context.Context) error) error

func MakeMetricContext

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

func MakeTraceHooks

func MakeTraceHooks(serviceName string) *twirp.ServerHooks

func NewMultiValueContext

func NewMultiValueContext(parent context.Context, dataList ...interface{}) context.Context

Create a multi-value context and populate it with data, dataList must be a list in "key, value, key, value..." format.

func NewResponseCodeCapturer

func NewResponseCodeCapturer(writer http.ResponseWriter) *responseCapturer

func RunInstrumented

func RunInstrumented(ctx context.Context, name string, 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 SetupTracing

func SetupTracing(ctx context.Context, appName, envName string, logger *zap.Logger) (
	statsd.ClientInterface, error)

func TearDownTracing

func TearDownTracing(ctx context.Context, client statsd.ClientInterface)

func WithStack

func WithStack(err twirp.Error) twirp.Error

Types

type FakeSpan

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

func (*FakeSpan) BaggageItem

func (f *FakeSpan) BaggageItem(key string) string

func (*FakeSpan) Context

func (f *FakeSpan) Context() ddtrace.SpanContext

func (*FakeSpan) Finish

func (f *FakeSpan) Finish(opts ...ddtrace.FinishOption)

func (*FakeSpan) SetBaggageItem

func (f *FakeSpan) SetBaggageItem(key, val string)

func (*FakeSpan) SetOperationName

func (f *FakeSpan) SetOperationName(operationName string)

func (*FakeSpan) SetTag

func (f *FakeSpan) SetTag(key string, value interface{})

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
	// contains filtered or unexported fields
}

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) CopyToSpan

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

func (*MetricsContext) CopyToStatsd

func (m *MetricsContext) CopyToStatsd(client statsd.ClientInterface, clientType string)

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 MultiValueContext

type MultiValueContext struct {
	context.Context
	// contains filtered or unexported fields
}

func (*MultiValueContext) Deadline

func (m *MultiValueContext) Deadline() (deadline time.Time, ok bool)

func (*MultiValueContext) Done

func (m *MultiValueContext) Done() <-chan struct{}

func (*MultiValueContext) Err

func (m *MultiValueContext) Err() error

func (*MultiValueContext) Value

func (m *MultiValueContext) Value(key interface{}) interface{}

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) TryRun

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

func (*ProcessContext) Wait

func (pc *ProcessContext) Wait()

type ProcessRegistry

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

func NewProcessRegistry

func NewProcessRegistry(parentCtx context.Context) *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 RecordingSink

type RecordingSink struct {
	Distributions map[string]float64
	Counts        map[string]int64
	Tags          map[string][]string
}

func NewRecordingSink

func NewRecordingSink() *RecordingSink

func (*RecordingSink) Clear

func (r *RecordingSink) Clear()

func (*RecordingSink) Close

func (r *RecordingSink) Close() error

func (*RecordingSink) Count

func (r *RecordingSink) Count(name string, value int64, tags []string, _ float64) error

func (*RecordingSink) Decr

func (r *RecordingSink) Decr(_ string, _ []string, _ float64) error

func (*RecordingSink) Distribution

func (r *RecordingSink) Distribution(name string, value float64, tags []string, _ float64) error

func (*RecordingSink) Event

func (r *RecordingSink) Event(_ *statsd.Event) error

func (*RecordingSink) Flush

func (r *RecordingSink) Flush() error

func (*RecordingSink) Gauge

func (r *RecordingSink) Gauge(_ string, _ float64, _ []string, _ float64) error

func (*RecordingSink) Histogram

func (r *RecordingSink) Histogram(_ string, _ float64, _ []string, _ float64) error

func (*RecordingSink) Incr

func (r *RecordingSink) Incr(_ string, _ []string, _ float64) error

func (*RecordingSink) ServiceCheck

func (r *RecordingSink) ServiceCheck(_ *statsd.ServiceCheck) error

func (*RecordingSink) Set

func (r *RecordingSink) Set(_ string, _ string, _ []string, _ float64) error

func (*RecordingSink) SetWriteTimeout

func (r *RecordingSink) SetWriteTimeout(_ time.Duration) error

func (*RecordingSink) SimpleEvent

func (r *RecordingSink) SimpleEvent(_, _ string) error

func (*RecordingSink) SimpleServiceCheck

func (r *RecordingSink) SimpleServiceCheck(_ string, _ statsd.ServiceCheckStatus) error

func (*RecordingSink) TimeInMilliseconds

func (r *RecordingSink) TimeInMilliseconds(_ string, _ float64, _ []string, _ float64) error

func (*RecordingSink) Timing

func (r *RecordingSink) Timing(_ string, _ time.Duration, _ []string, _ float64) error

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, sink statsd.ClientInterface,
	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
}

type TwirpHttpClient

type TwirpHttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}

TwirpHttpClient is duplicated from twirp's generated service code. It is declared in this package so that the client can be wrapped to initiate traces.

func WrapTwirpClient

func WrapTwirpClient(c TwirpHttpClient, clientServiceName string,
	analyticsRate float64, clientType string) TwirpHttpClient

WrapTwirpClient wraps an TwirpHttpClient to add distributed tracing to its requests.

func WrapTwirpClientDef

func WrapTwirpClientDef(c TwirpHttpClient, clientServiceName string) TwirpHttpClient

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