Documentation
¶
Overview ¶
traceobject defines an interface for objects that can contain a New Relic transaction, and how to interact with them.
Index ¶
- type AddToCallReturn
- type Context
- func (ctx *Context) AddToCall(pkg *decorator.Package, call *dst.CallExpr, transactionVariableName string, ...) AddToCallReturn
- func (ctx *Context) AddToFuncDecl(pkg *decorator.Package, decl *dst.FuncDecl) (TraceObject, string)
- func (ctx *Context) AddToFuncLit(pkg *decorator.Package, lit *dst.FuncLit) (TraceObject, string)
- func (ctx *Context) AssignTransactionVariable(variableName string) (dst.Stmt, string)
- type TraceObject
- type Transaction
- func (txn *Transaction) AddToCall(pkg *decorator.Package, call *dst.CallExpr, transactionVariable string, ...) AddToCallReturn
- func (txn *Transaction) AddToFuncDecl(pkg *decorator.Package, decl *dst.FuncDecl) (TraceObject, string)
- func (txn *Transaction) AddToFuncLit(pkg *decorator.Package, lit *dst.FuncLit) (TraceObject, string)
- func (txn *Transaction) AssignTransactionVariable(variableName string) (dst.Stmt, string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddToCallReturn ¶
type AddToCallReturn struct {
TraceObject TraceObject // the trace object that was passed to the call
Import string // the import that needs to be added to the package with `go get“
NeedsTx bool // whether a transaction needs to be in scope for the call
}
AddToCallReturn is the return type for the AddToCall method on TraceObjects.
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context is a trace object that contains a context.Context object. Note: this will not work for structured objects that contain a context.Context object.
func NewContext ¶
func (*Context) AddToFuncDecl ¶
func (*Context) AddToFuncLit ¶
type TraceObject ¶
type TraceObject interface {
// AddToCall adds a trace object to a call expression, passing it as an argument
// to the function being invoked in the call.
//
// If an import needs to be added to support the changes made, it will be returned as a string in the second return.
// The third return value indicates whether a transaction needs to be in scope for the call.
AddToCall(pkg *decorator.Package, call *dst.CallExpr, transactionVariableName string, async bool) AddToCallReturn
// AddToFuncDecl adds a trace object to a function declaration as a parameter, so that
// trace objects can be passed in calls to this function.
//
// Make sure that the package passed is from the same package that the function is defined in.
//
// If an import needs to be added to support the changes made, it will be returned as a string.
AddToFuncDecl(pkg *decorator.Package, decl *dst.FuncDecl) (TraceObject, string)
// AddToFuncLit adds a trace object to a function literal definition as a parameter, so that
// trace objects can be passed in calls to this function literal.
//
// Make sure that the package passed is from the same package that the function literal is defined in.
//
// If an import needs to be added to support the changes made, it will be returned as a string.
AddToFuncLit(pkg *decorator.Package, lit *dst.FuncLit) (TraceObject, string)
// AssignTransactionVariable fetches the transaction from the trace object and assigns it to a variable
//
// If an import needs to be added to support the changes made, it will be returned as a string.
//
// If an import needs to be added to support the changes made, it will be returned as a string.
AssignTransactionVariable(variableName string) (dst.Stmt, string)
}
TraceObject is an object that contains New Relic tracing in the form of a transaction. Transactions can be injected into various object types that may require different methods of retrieval.
This interface defines a standard set of behaviors that all objects containing a transaction must implement for the underlying transaction to be usable for tracing.
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
func NewTransaction ¶
func NewTransaction() *Transaction
func (*Transaction) AddToCall ¶
func (txn *Transaction) AddToCall(pkg *decorator.Package, call *dst.CallExpr, transactionVariable string, async bool) AddToCallReturn
AddToCall adds the transaction as an argument to the function call. If async is true, the transaction will cloned by calling NewGoroutine().
func (*Transaction) AddToFuncDecl ¶
func (txn *Transaction) AddToFuncDecl(pkg *decorator.Package, decl *dst.FuncDecl) (TraceObject, string)
AddToFuncDecl adds the transaction as a parameter to the function declaration
func (*Transaction) AddToFuncLit ¶
func (txn *Transaction) AddToFuncLit(pkg *decorator.Package, lit *dst.FuncLit) (TraceObject, string)
AddToFuncLit adds the transaction as a parameter to the function literal
func (*Transaction) AssignTransactionVariable ¶
func (txn *Transaction) AssignTransactionVariable(variableName string) (dst.Stmt, string)
This is already a transaction no-op