instrument

package
v0.41.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DynamicTracerImport string

DynamicTracerImport holds the dynamic tracer import string set by SetDynamicTracerImport. It is used to dynamically specify the tracer package import.

Functions

func BuildInstrumentedBinary

func BuildInstrumentedBinary(workspace string) (string, error)

BuildInstrumentedBinary runs the necessary Go commands ("go mod tidy", "go get", and "go build") in the workspace directory to build the instrumented binary. It preserves environment variables. It returns the path to the built binary and an error if any command fails.

Parameters:

  • workspace (string): the path to the workspace directory.

Returns:

  • string: the path to the built instrumented binary.
  • error: an error object if any step in the build process fails.

func InstrumentWorkspace

func InstrumentWorkspace(workspace string, cfg config.Config) error

InstrumentWorkspace traverses all files within the workspace directory and instruments each Go source file according to the provided configuration. Files matching any exclude patterns from cfg.Instrumentation.Exclude or located within the "tracer" directory are skipped.

Parameters:

  • workspace (string): the path to the workspace directory.
  • cfg (config.Config): the configuration settings used for instrumentation.

Returns:

  • error: an error object if any file fails to be instrumented.

func PrepareWorkspace

func PrepareWorkspace(projectDir string) (string, error)

PrepareWorkspace copies the target Go project from projectDir into a new temporary workspace. It returns the absolute path to the workspace and an error if the operation fails.

Parameters:

  • projectDir (string): the path to the target Go project directory.

Returns:

  • string: the path to the temporary workspace directory.
  • error: an error object if any error occurs during workspace preparation.

func RunInstrumentedBinary

func RunInstrumentedBinary(binaryPath string, args []string) error

RunInstrumentedBinary executes the built binary located at binaryPath with any additional command-line arguments. It sets the standard output and error to the current process's output streams and preserves environment variables.

Parameters:

  • binaryPath (string): the path to the instrumented binary.
  • args ([]string): a slice of strings representing additional arguments to pass to the binary.

Returns:

  • error: an error object if the binary execution fails.

func SetDynamicTracerImport

func SetDynamicTracerImport(workspace string) error

SetDynamicTracerImport sets the DynamicTracerImport variable to the tracer package import path. The workspace parameter is accepted for interface consistency though it is not used in this implementation.

Parameters:

  • workspace (string): the path to the workspace directory.

Returns:

  • error: an error object if setting the tracer import fails (currently always nil).

Types

This section is empty.

Jump to

Keyboard shortcuts

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