nrmock

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package nrmock contains mock implementations of newrelic.Application and newrelic.Transaction

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application struct {
	AllTransactions   []*Transaction
	LatestTransaction *Transaction

	CustomEvents  map[string][]map[string]interface{}
	CustomMetrics map[string][]float64
}

Application is a mock implementation of newrelic.Application

func NewApplication

func NewApplication(options ...func(*Application)) *Application

NewApplication creates a new *Application

func (*Application) RecordCustomEvent

func (a *Application) RecordCustomEvent(eventType string, params map[string]interface{}) error

RecordCustomEvent stores the provided eventType and params for later inspection

func (*Application) RecordCustomMetric added in v0.2.0

func (a *Application) RecordCustomMetric(name string, value float64) error

RecordCustomMetric records a custom metric.

func (*Application) Shutdown

func (a *Application) Shutdown(timeout time.Duration)

Shutdown does nothing

func (*Application) StartTransaction

func (a *Application) StartTransaction(name string, w http.ResponseWriter, r *http.Request) newrelic.Transaction

StartTransaction creates a mocked transaction, stores it for later inspection, and returns it

func (*Application) WaitForConnection

func (a *Application) WaitForConnection(timeout time.Duration) error

WaitForConnection does nothing

type Transaction

type Transaction struct {
	Name       string
	Ended      bool
	Ignored    bool
	Errors     int
	Code       int
	Attributes map[string]interface{}
}

Transaction is a mock implementation of newrelic.Transaction

func NewTransaction

func NewTransaction(name string, options ...func(*Transaction)) *Transaction

NewTransaction creates a new *Transaction

func (*Transaction) AddAttribute

func (t *Transaction) AddAttribute(key string, value interface{}) error

AddAttribute adds the provided key and value to the transaction attributes for later inspection

func (*Transaction) End

func (t *Transaction) End() error

End marks the transaction as ended

func (*Transaction) Header

func (t *Transaction) Header() http.Header

Header returns and empty header map

func (*Transaction) Ignore

func (t *Transaction) Ignore() error

Ignore marks the transaction as ignored

func (*Transaction) NoticeError

func (t *Transaction) NoticeError(err error) error

NoticeError increments the errors counter

func (*Transaction) SetName

func (t *Transaction) SetName(name string) error

SetName sets the transaction name

func (*Transaction) StartSegmentNow

func (t *Transaction) StartSegmentNow() newrelic.SegmentStartTime

StartSegmentNow returns a blank newrelic.SegmentStartTime

func (*Transaction) Write

func (t *Transaction) Write(b []byte) (int, error)

Write writes nothing

func (*Transaction) WriteHeader

func (t *Transaction) WriteHeader(code int)

WriteHeader stores the provided status code for later inspection

Jump to

Keyboard shortcuts

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