processor

package
v0.0.0-...-98c0e79 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 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

func IsBuildExclude(s string) bool

func IsBuildIgnore

func IsBuildIgnore(s string) bool

func IsGoBuildExclude

func IsGoBuildExclude(s string) bool

func IsGoBuildIgnore

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

type FunctionSelector interface {
	AcceptFunction(functionName string) bool
}

FunctionSelector tells if function has to be instrumented.

type GoBuildDirective

type GoBuildDirective uint

GoBuildDirective is standard Go compiler directive.

const (
	UnknownDirective GoBuildDirective = iota
	GoBuildIgnore
	GoBuildExclude
	BuildIgnore
	BuildExclude
)

func GoBuildDirectivesFromFile

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

func ParseGoBuildDirective

func ParseGoBuildDirective(s string) GoBuildDirective

func (GoBuildDirective) SkipFile

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

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

MapFunctionSelector makes decision basedd on map value or else default.

func NewMapFunctionSelectorFromCommands

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

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

func (MapFunctionSelector) AcceptFunction

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