Documentation

Index

Constants

View Source
const MaxBodyThreshold = 2048
View Source
const MetricsContextKey = "MetricContext"
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 GetZapLoggerFromEchoLogger

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

func ImbueContext

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

func MakeMetricContext

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

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, app newrelic.Application,
    	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 TracingAndLoggingMiddlewareHook

      func TracingAndLoggingMiddlewareHook(opts TracingAndMetricsOptions) echo.MiddlewareFunc

        Insert middleware responsible for logging, metrics and tracing

        Types

        type AuthValidatorFunc

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

        type DefaultMetricsSink

        type DefaultMetricsSink struct {
        	Harvester *telemetry.Harvester
        }

        func NewMetricsSink

        func NewMetricsSink(nrLicenseKey, appName string, suffix string,
        	client *http.Client) *DefaultMetricsSink

        func (*DefaultMetricsSink) SendMetrics

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

        func (*DefaultMetricsSink) SubmitSegmentMetrics

        func (m *DefaultMetricsSink) SubmitSegmentMetrics(met *MetricsContext)

        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 (*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(h *telemetry.Harvester)

          func (*MetricsContext) CopyToTransaction

          func (m *MetricsContext) CopyToTransaction(trans newrelic.Transaction)

          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 interface {
            	SubmitSegmentMetrics(met *MetricsContext)
            }

            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, app newrelic.Application,
            	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 ShortenedStackTrace

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

            func NewShortenedStackTrace

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

            func (*ShortenedStackTrace) Error

            func (s *ShortenedStackTrace) Error() string

            func (*ShortenedStackTrace) Field

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

            func (*ShortenedStackTrace) JSONStack

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

            func (*ShortenedStackTrace) StackTrace

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

            type TimeMeasurement

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

            func (*TimeMeasurement) Done

            func (t *TimeMeasurement) Done()

            type TracingAndMetricsOptions

            type TracingAndMetricsOptions struct {
            	DebugMode bool
            	NrApp     newrelic.Application
            
            	HostNameOverride string
            
            	Logger *zap.Logger
            }

            func (*TracingAndMetricsOptions) Validate

            func (t *TracingAndMetricsOptions) Validate()

            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