github.com/lulzWill/go-agent@v2.1.2+incompatible/transaction.go (about) 1 package newrelic 2 3 import "net/http" 4 5 // Transaction represents a request or a background task. 6 // Each Transaction should only be used in a single goroutine. 7 type Transaction interface { 8 // If StartTransaction is called with a non-nil http.ResponseWriter then 9 // the Transaction may be used in its place. This allows 10 // instrumentation of the response code and response headers. 11 http.ResponseWriter 12 13 // End finishes the current transaction, stopping all further 14 // instrumentation. Subsequent calls to End will have no effect. 15 End() error 16 17 // Ignore ensures that this transaction's data will not be recorded. 18 Ignore() error 19 20 // SetName names the transaction. Transactions will not be grouped 21 // usefully if too many unique names are used. 22 SetName(name string) error 23 24 // NoticeError records an error. The first five errors per transaction 25 // are recorded (this behavior is subject to potential change in the 26 // future). 27 NoticeError(err error) error 28 29 // AddAttribute adds a key value pair to the current transaction. This 30 // information is attached to errors, transaction events, and error 31 // events. The key must contain fewer than than 255 bytes. The value 32 // must be a number, string, or boolean. Attribute configuration is 33 // applied (see config.go). 34 // 35 // For more information, see: 36 // https://docs.newrelic.com/docs/agents/manage-apm-agents/agent-metrics/collect-custom-attributes 37 AddAttribute(key string, value interface{}) error 38 39 // StartSegmentNow allows the timing of functions, external calls, and 40 // datastore calls. The segments of each transaction MUST be used in a 41 // single goroutine. Consumers are encouraged to use the 42 // `StartSegmentNow` functions which checks if the Transaction is nil. 43 // See segments.go 44 StartSegmentNow() SegmentStartTime 45 }