metrics

package
v1.0.63 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2021 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// MetricsRecorder is used by the GetRecorder function to determine which recorder
	// to return. This allows an application to set a default recorder and simply call
	// GetRecorder.
	// Enum:
	//    noop
	//    newrelic
	MetricsRecorder = "noop"
)

Functions

This section is empty.

Types

type NewRelic

type NewRelic struct {
	Transaction *newrelic.Transaction
	DBName      string
	Collection  string
	Operation   string
}

NewRelic implements the transaction.metrics interface. Populate DBName, Table, Operation before calling DatabaseSegment.

func (*NewRelic) DatabaseSegment

func (nr *NewRelic) DatabaseSegment(product, query string, args ...interface{}) func()

DatabaseSegment records a database segment that occured during the given transaction.

func (*NewRelic) Segment

func (nr *NewRelic) Segment(name string) func()

Segment records a segment that occured during the given transaction.

func (*NewRelic) SetDBMeta

func (nr *NewRelic) SetDBMeta(db, collection, operation string)

SetDBMeta assigns the Database meta data for the next DatabaseSegment call. Call before calling DatabaseSegment.

type NoOp

type NoOp struct{}

NoOp satisfies the Recorder interface, but does nothing.

func (*NoOp) DatabaseSegment

func (n *NoOp) DatabaseSegment(string, string, ...interface{}) func()

DatabaseSegment records a database segment that occured during the given transaction.

func (*NoOp) Segment

func (n *NoOp) Segment(string) func()

Segment records a segment that occured during the given transaction.

func (*NoOp) SetDBMeta

func (n *NoOp) SetDBMeta(string, string, string)

SetDBMeta no-ops.

type Recorder

type Recorder interface {
	// SetDBMeta assigns the Database meta data for the next DatabaseSegment call. Call before calling DatabaseSegment.
	SetDBMeta(string, string, string)

	// DatabaseSegment records a database segment that occured during the given transaction.
	DatabaseSegment(string, string, ...interface{}) func()

	// Segment records a segment that occured during the given transaction.
	Segment(string) func()
}

Recorder is an interface for recording metrics about the application.

func GetRecorder

func GetRecorder(ctx context.Context) Recorder

GetRecorder returns an appropriate recorder based on the value of MetricsRecorder. Populate MetricsRecorder during setup in main to change which recorder is returned.

func NewRelicFromContext

func NewRelicFromContext(ctx context.Context) Recorder

NewRelicFromContext creates a new NewRelic recorder from the given context, or a NoOp recorder if there is no NewRelic transaction in the context.

Jump to

Keyboard shortcuts

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