Documentation ¶
Index ¶
- Constants
- func CannotInstrumentHttpMethod(manager *InstrumentationManager, c *dstutil.Cursor)
- func ExternalHttpCall(manager *InstrumentationManager, stmt dst.Stmt, c *dstutil.Cursor, ...) bool
- func FindGrpcServerObject(pkg *decorator.Package, node dst.Node) (facts.Entry, bool)
- func FindGrpcServerStreamInterface(pkg *decorator.Package, node dst.Node) (facts.Entry, bool)
- func InstrumentGinFunction(manager *InstrumentationManager, c *dstutil.Cursor)
- func InstrumentGinMiddleware(manager *InstrumentationManager, stmt dst.Stmt, c *dstutil.Cursor, ...) bool
- func InstrumentGrpcDial(manager *InstrumentationManager, c *dstutil.Cursor)
- func InstrumentGrpcServer(manager *InstrumentationManager, stmt dst.Stmt, c *dstutil.Cursor, ...) bool
- func InstrumentGrpcServerMethod(manager *InstrumentationManager, c *dstutil.Cursor)
- func InstrumentHandleFunction(manager *InstrumentationManager, c *dstutil.Cursor)
- func InstrumentHttpClient(manager *InstrumentationManager, c *dstutil.Cursor)
- func InstrumentMain(manager *InstrumentationManager, c *dstutil.Cursor)
- func NoticeError(manager *InstrumentationManager, stmt dst.Stmt, c *dstutil.Cursor, ...) bool
- func TraceFunction(manager *InstrumentationManager, node dst.Node, tracing *tracestate.State) (dst.Node, bool)
- func WrapNestedHandleFunction(manager *InstrumentationManager, stmt dst.Stmt, c *dstutil.Cursor, ...) bool
- type DependencyScan
- type InstrumentationManager
- func (m *InstrumentationManager) AddRequiredModules() error
- func (m *InstrumentationManager) CreateDiffFile() error
- func (m *InstrumentationManager) DetectDependencyIntegrations() error
- func (m *InstrumentationManager) InstrumentApplication(instrumentationFunctions ...StatelessTracingFunction) error
- func (m *InstrumentationManager) WriteDiff() error
- type PackageState
- type StatefulTracingFunction
- type StatelessTracingFunction
Constants ¶
const (
UntypedNil = "untyped nil"
)
Variables ¶
This section is empty.
Functions ¶
func CannotInstrumentHttpMethod ¶
func CannotInstrumentHttpMethod(manager *InstrumentationManager, c *dstutil.Cursor)
CannotInstrumentHttpMethod is a function that discovers methods of net/http. If that function can not be penetrated by instrumentation, it leaves a comment header warning the customer. This function needs no tracing context to work.
func ExternalHttpCall ¶
func ExternalHttpCall(manager *InstrumentationManager, stmt dst.Stmt, c *dstutil.Cursor, tracing *tracestate.State) bool
ExternalHttpCall finds and instruments external net/http calls to the method http.Do. It returns true if a modification was made
func FindGrpcServerObject ¶
FindGrpcServerObject scans for a call to Register***Server in the package It uses this call to identify the gRPC server Implementation object
func FindGrpcServerStreamInterface ¶
FindGrpcServerStreamInterface scans for an interface that embeds the grpc.ServerStream object We know this is a carrier of contexts injected with New Relic Transactions
func InstrumentGinFunction ¶
func InstrumentGinFunction(manager *InstrumentationManager, c *dstutil.Cursor)
InstrumentGinFunction verifies gin function calls and initiates tracing. If tracing was added, then defineTxnFromGinCtx is called to inject the transaction into the function body via the gin context
func InstrumentGinMiddleware ¶
func InstrumentGinMiddleware(manager *InstrumentationManager, stmt dst.Stmt, c *dstutil.Cursor, tracing *tracestate.State) bool
WrapHandleFunction is a function that wraps net/http.HandeFunc() declarations inside of functions that are being traced by a transaction.
func InstrumentGrpcDial ¶
func InstrumentGrpcDial(manager *InstrumentationManager, c *dstutil.Cursor)
InstrumentGrpcDial adds the New Relic gRPC client interceptor to the grpc.Dial client call This function does not need any tracing context to work, nor will it produce any tracing context
func InstrumentGrpcServer ¶
func InstrumentGrpcServer(manager *InstrumentationManager, stmt dst.Stmt, c *dstutil.Cursor, tracing *tracestate.State) bool
InstrumentGrpcServer adds the New Relic gRPC server interceptors to the grpc.NewServer call
func InstrumentGrpcServerMethod ¶
func InstrumentGrpcServerMethod(manager *InstrumentationManager, c *dstutil.Cursor)
InstrumentGrpcServerMethod finds methods of a declared gRPC server and pulls tracing through it
func InstrumentHandleFunction ¶
func InstrumentHandleFunction(manager *InstrumentationManager, c *dstutil.Cursor)
Recognize if a function is a handler func based on its contents, and inject instrumentation. This function discovers entrypoints to tracing for a given transaction and should trace all the way down the call chain of the function it is invoked on.
func InstrumentHttpClient ¶
func InstrumentHttpClient(manager *InstrumentationManager, c *dstutil.Cursor)
InstrumentHttpClient automatically injects a newrelic roundtripper into any newly created http client looks for the following pattern: client := &http.Client{}
func InstrumentMain ¶
func InstrumentMain(manager *InstrumentationManager, c *dstutil.Cursor)
InstrumentMain looks for the main method of a program, and uses this as an instrumentation initialization and injection point TODO: Can this be refactored to be part of the Trace Function algorithm?
func NoticeError ¶
func NoticeError(manager *InstrumentationManager, stmt dst.Stmt, c *dstutil.Cursor, tracing *tracestate.State, functionCallWasTraced bool) bool
NoticeError will check for the presence of an error.Error variable in the body at the index in bodyIndex. If it finds that an error is returned, it will add a line after the assignment statement to capture an error with a newrelic transaction. All transactions are assumed to be named "txn"
func TraceFunction ¶
func TraceFunction(manager *InstrumentationManager, node dst.Node, tracing *tracestate.State) (dst.Node, bool)
TraceFunction adds tracing to a function. This includes error capture, and passing agent metadata to relevant functions and services. Traces all called functions inside the current package as well. This function returns a FuncDecl object pointer that contains the potentially modified version of the FuncDecl object, fn, passed. If the bool field is true, then the function was modified, and requires a transaction most likely.
This function can accept a FuncDecl or FuncLit object for the node only.
func WrapNestedHandleFunction ¶
func WrapNestedHandleFunction(manager *InstrumentationManager, stmt dst.Stmt, c *dstutil.Cursor, tracing *tracestate.State) bool
WrapHandleFunction is a function that wraps net/http.HandeFunc() declarations inside of functions that are being traced by a transaction.
Types ¶
type DependencyScan ¶
DependencyScan is a function that scans a function declaration for dependencies that need to be recognized before tracing occurs. Functions that implement this should be designed to detect a specific thing during a walk of the full AST tree of an application.
type InstrumentationManager ¶
type InstrumentationManager struct {
// contains filtered or unexported fields
}
InstrumentationManager maintains state relevant to tracing across all files, packages and functions.
func NewInstrumentationManager ¶
func NewInstrumentationManager(pkgs []*decorator.Package, appName, agentVariableName, diffFile, userAppPath string) *InstrumentationManager
NewInstrumentationManager initializes an InstrumentationManager cache for a given package.
func (*InstrumentationManager) AddRequiredModules ¶
func (m *InstrumentationManager) AddRequiredModules() error
func (*InstrumentationManager) CreateDiffFile ¶
func (m *InstrumentationManager) CreateDiffFile() error
func (*InstrumentationManager) DetectDependencyIntegrations ¶
func (m *InstrumentationManager) DetectDependencyIntegrations() error
DetectDependencyIntegrations
func (*InstrumentationManager) InstrumentApplication ¶
func (m *InstrumentationManager) InstrumentApplication(instrumentationFunctions ...StatelessTracingFunction) error
InstrumentApplication applies instrumentation in place to the dst files stored in the InstrumentationManager. This will not generate any changes to the actual source code, just the abstract syntax tree generated from it. Note: only pass tracing functions to this method for testing, or if you sincerely know what you are doing.
func (*InstrumentationManager) WriteDiff ¶
func (m *InstrumentationManager) WriteDiff() error
WriteDiff writes out the changes made to a file to the diff file for this package.
type PackageState ¶
type PackageState struct {
// contains filtered or unexported fields
}
PackageManager contains state relevant to tracing within a single package.
type StatefulTracingFunction ¶
type StatefulTracingFunction func(manager *InstrumentationManager, stmt dst.Stmt, c *dstutil.Cursor, tracing *tracestate.State) bool
StatefulTracingFunctions are functions that require knowledge of the current tracing state of the package to apply instrumentation. These functions are passed the current tracing state of the package, and return a boolean indicating whether the function was modified. If the function was modified, it is likely that a transaction is required. The tracingName parameter is used to identify the object containing a New Relic Transaction. These functions are invoked on every statement in the body of a function that is being traced by the TraceFunction function.
type StatelessTracingFunction ¶
type StatelessTracingFunction func(manager *InstrumentationManager, c *dstutil.Cursor)
StatelessTracingFunction is a function that does not need to be aware of the current tracing state of the package to apply instrumentation. These functions are passed the current node, the InstrumentationManager, and a cursor to the current node. These functions are invoked on every node in the DST tree no matter what.