Documentation ¶
Overview ¶
Package newrelicutil provides a set of helpers for working with objects of New Relic Go Agent.
Index ¶
- func DatastoreSegment(ctx context.Context) *newrelic.DatastoreSegment
- func ExternalSegment(ctx context.Context) *newrelic.ExternalSegment
- func Segment(ctx context.Context) *newrelic.Segment
- func Transaction(ctx context.Context) *newrelic.Transaction
- func WithDatastoreSegment(ctx context.Context, sgm *newrelic.DatastoreSegment) context.Context
- func WithExternalSegment(ctx context.Context, sgm *newrelic.ExternalSegment) context.Context
- func WithSegment(ctx context.Context, sgm *newrelic.Segment) context.Context
- func WithTransaction(ctx context.Context, txn *newrelic.Transaction) context.Context
- func WrapHandler(app *newrelic.Application, name string, handler http.Handler) http.Handler
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DatastoreSegment ¶
func DatastoreSegment(ctx context.Context) *newrelic.DatastoreSegment
DatastoreSegment returns the New Relic DatastoreSegment object from context.
func ExternalSegment ¶
func ExternalSegment(ctx context.Context) *newrelic.ExternalSegment
ExternalSegment returns the New Relic ExternalSegment object from context.
func Transaction ¶
func Transaction(ctx context.Context) *newrelic.Transaction
Transaction returns the New Relic Transaction object from context. Returns nil if the context does not contain an object.
func WithDatastoreSegment ¶
WithDatastoreSegment puts the New Relic ExternalSegment object to the given context and returns the new context.
func WithExternalSegment ¶
WithExternalSegment puts the New Relic ExternalSegment object to the given context and returns the new context.
func WithSegment ¶
WithSegment puts the New Relic Segment object to the given context and returns the new context.
func WithTransaction ¶
WithTransaction puts the New Relic Transaction object to the given context and returns the new context.
func WrapHandler ¶
WrapHandler returns the given http handler that is wrapped to New Relic Transaction. Current New Relic Transaction is placed in the context.
Example ¶
nrapp, _ := newrelic.NewApplication( newrelic.ConfigAppName("app_test"), newrelic.ConfigEnabled(false), newrelic.ConfigInfoLogger(os.Stdout), ) handler := http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {}) wrappedHandler := newrelicutil.WrapHandler(nrapp, "HandlerName", handler) mux := http.NewServeMux() mux.Handle("/some/path", wrappedHandler)
Output:
Types ¶
This section is empty.