Documentation
¶
Index ¶
- Variables
- func BuildInstrumentedBinary(workspace string) (string, error)
- func InstrumentWorkspace(workspace string, cfg config.Config) error
- func PrepareWorkspace(projectDir string) (string, error)
- func RunInstrumentedBinary(binaryPath string, args []string) error
- func SetDynamicTracerImport(workspace string) error
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.