parser

package
v0.0.0-...-6217d46 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
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

func FindGrpcServerObject(pkg *decorator.Package, node dst.Node) (facts.Entry, bool)

FindGrpcServerObject scans for a call to Register***Server in the package It uses this call to identify the gRPC server Implementation object

func FindGrpcServerStreamInterface

func FindGrpcServerStreamInterface(pkg *decorator.Package, node dst.Node) (facts.Entry, bool)

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

type DependencyScan func(pkg *decorator.Package, node dst.Node) (facts.Entry, bool)

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL