Documentation ¶
Overview ¶
Contains different helpers to make life easier with NewRelic and Context
Index ¶
- func ContextWithTxn(c context.Context, txn newrelic.Transaction) context.Context
- func GetTnxFromContext(c context.Context) newrelic.Transaction
- func SetTxnToGorm(ctx context.Context, db *gorm.DB) *gorm.DB
- func WrapHTTPClient(ctx context.Context, c *http.Client)
- func WrapRedisClient(ctx context.Context, c *redis.Client) *redis.Client
- type NewRelicMiddleware
- type TxnNameFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithTxn ¶
Set NewRelic transaction to context
func GetTnxFromContext ¶
Get NewRelic transaction from context anywhere
func SetTxnToGorm ¶
Sets transaction from Context to gorm settings, returns cloned DB
func WrapHTTPClient ¶
Gets NewRelic transaction from context and wraps client transport with newrelic RoundTripper
Types ¶
type NewRelicMiddleware ¶
type NewRelicMiddleware struct {
// contains filtered or unexported fields
}
func NewMiddleware ¶
func NewMiddleware(appname string, license string) (*NewRelicMiddleware, error)
Creates new middleware that will report time in NewRelic and set transaction in context
func NewMiddlewareWithApp ¶
func NewMiddlewareWithApp(app newrelic.Application) *NewRelicMiddleware
Same as NewMiddleware but accepts newrelic.Application
func NewMiddlewareWithConfig ¶
func NewMiddlewareWithConfig(c newrelic.Config) (*NewRelicMiddleware, error)
Same as NewMiddleware but accepts newrelic.Config
func (*NewRelicMiddleware) Handler ¶
func (nr *NewRelicMiddleware) Handler(h http.Handler) http.Handler
Creates wrapper for your handler
func (*NewRelicMiddleware) SetTxnNameFunc ¶
func (nr *NewRelicMiddleware) SetTxnNameFunc(fn TxnNameFunc)
Allows to change transaction name. By default `fmt.Sprintf("%s %s", r.Method, r.URL.Path)`
type TxnNameFunc ¶
Click to show internal directories.
Click to hide internal directories.