processor

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasicSpanName

func BasicSpanName(receiver, function string) string

BasicSpanName is common notation of <class>.<method> or <pkg>.<func>

func IsBuildExclude added in v1.2.0

func IsBuildExclude(s string) bool

func IsBuildIgnore added in v1.2.0

func IsBuildIgnore(s string) bool

func IsGoBuildExclude added in v1.2.0

func IsGoBuildExclude(s string) bool

func IsGoBuildIgnore added in v1.2.0

func IsGoBuildIgnore(s string) bool

Types

type Command

type Command struct {
	// contains filtered or unexported fields
}

Command to change behavior of Processor or Instrumentor

func CommandsFromFile

func CommandsFromFile(file ast.File) ([]Command, error)

CommandsFromFile that has been parsed by `go/parse` with comments

func ParseCommand

func ParseCommand(s string) (Command, error)

ParseCommand from string representation

type FunctionSelector added in v1.1.0

type FunctionSelector interface {
	AcceptFunction(functionName string) bool
}

FunctionSelector tells if function has to be instrumented.

type GoBuildDirective added in v1.2.0

type GoBuildDirective uint

GoBuildDirective is standard Go compiler directive.

const (
	UnknownDirective GoBuildDirective = iota
	GoBuildIgnore
	GoBuildExclude
	BuildIgnore
	BuildExclude
)

func GoBuildDirectivesFromFile added in v1.2.0

func GoBuildDirectivesFromFile(file ast.File) (directives []GoBuildDirective)

func ParseGoBuildDirective added in v1.2.0

func ParseGoBuildDirective(s string) GoBuildDirective

func (GoBuildDirective) SkipFile added in v1.2.0

func (v GoBuildDirective) SkipFile() bool

type Instrumenter

type Instrumenter interface {
	Imports() []*types.Package
	PrefixStatements(spanName string, hasError bool) []ast.Stmt
}

Instrumenter supplies ast of Go code that will be inserted and required dependencies.

type MapFunctionSelector added in v1.1.0

type MapFunctionSelector struct {
	AcceptFunctions map[string]bool
	Default         bool
}

MapFunctionSelector makes decision basedd on map value or else default.

func NewMapFunctionSelectorFromCommands added in v1.1.0

func NewMapFunctionSelectorFromCommands(defaultSelect bool, commands []Command) MapFunctionSelector

NewMapFunctionSelectorFromCommands performs join of function names stored in maps of commands.

func (MapFunctionSelector) AcceptFunction added in v1.1.0

func (s MapFunctionSelector) AcceptFunction(functionName string) bool

type Processor

type Processor struct {
	Instrumenter     Instrumenter
	FunctionSelector FunctionSelector
	SpanName         func(receiver, function string) string
	ContextName      string
	ContextPackage   string
	ContextType      string
	ErrorName        string
	ErrorType        string
}

Processor traverses AST, collects details on functions and methods, and invokes Instrumenter

func (*Processor) Process

func (p *Processor) Process(fset *token.FileSet, file *ast.File) error

Jump to

Keyboard shortcuts

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