config

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2025 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DomainSocketEnvName       = "OUTRIG_DOMAINSOCKET"
	TcpAddrEnvName            = "OUTRIG_TCPADDR"
	DisabledEnvName           = "OUTRIG_DISABLED"
	NoTelemetryEnvName        = "OUTRIG_NOTELEMETRY"
	DevConfigEnvName          = "OUTRIG_DEVCONFIG"
	DisableDockerProbeEnvName = "OUTRIG_DISABLEDOCKERPROBE"
	ExternalLogCaptureEnvName = "OUTRIG_EXTERNALLOGCAPTURE"
	AppRunIdEnvName           = "OUTRIG_APPRUNID"
	ConfigFileEnvName         = "OUTRIG_CONFIGFILE"
	ConfigJsonEnvName         = "OUTRIG_CONFIGJSON"
	OutrigPathEnvName         = "OUTRIG_OUTRIGBINPATH"
	AppNameEnvName            = "OUTRIG_APPNAME"
	RunSDKReplacePathEnvName  = "OUTRIG_RUN_SDKREPLACEPATH"
	FromRunModeEnvName        = "OUTRIG_FROMRUNMODE"
)

Environment variables

View Source
const (
	OutrigHome              = "~/.config/outrig"
	DevOutrigHome           = "~/.config/outrig-dev"
	DefaultDomainSocketName = "/outrig.sock"
)

Home directory paths

View Source
const (
	ProdWebServerPort = 5005
	DevWebServerPort  = 6005
)

Default ports for the server (should match serverbase)

View Source
const ConfigFileName = "outrig.json"
View Source
const OutrigSDKVersion = "v0.9.1"

Variables

This section is empty.

Functions

func GetAppRunId added in v0.8.1

func GetAppRunId() string

func GetDomainSocketNameForClient added in v0.8.1

func GetDomainSocketNameForClient() string

GetDomainSocketNameForClient returns the full domain socket path for client

func GetExternalAppRunId added in v0.8.1

func GetExternalAppRunId() string

func GetMonitorPort added in v0.8.1

func GetMonitorPort() int

func GetOutrigHomeForClient added in v0.8.1

func GetOutrigHomeForClient() string

GetOutrigHomeForClient returns the appropriate home directory based on client config

func GetTcpAddrForClient added in v0.8.1

func GetTcpAddrForClient() string

func SetUseDevConfig added in v0.8.1

func SetUseDevConfig(dev bool)

func UseDevConfig added in v0.8.1

func UseDevConfig() bool

Types

type CollectorConfig added in v0.9.0

type CollectorConfig struct {
	Logs         LogProcessorConfig `json:"logs"`
	RuntimeStats RuntimeStatsConfig `json:"runtimestats"`
	Watch        WatchConfig        `json:"watch"`
	Goroutine    GoRoutineConfig    `json:"goroutine"`

	Plugins map[string]any `json:"-"`
}

func (*CollectorConfig) UnmarshalJSON added in v0.9.0

func (c *CollectorConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom unmarshaling for CollectorConfig with defaults

type Config added in v0.5.0

type Config struct {
	Quiet bool `json:"quiet"` // If true, suppresses init, connect, and disconnect messages

	// AppName is the name of the application
	AppName string `json:"appname"`

	// DomainSocketPath is the path to the Unix domain socket. If "" => use default.
	// If "-" => disable domain socket.
	DomainSocketPath string `json:"domainsocketpath"`

	// TcpAddr is the TCP address to connect to the Outrig server.  If "" => use default.
	// If "-" => disable TCP connection. Domain socket will be tried first (except on Windows where domain sockets are not supported).)
	TcpAddr string `json:"tcpaddr"`

	// By default the SDK will probe host.docker.internal:5005 to see if the Outrig monitor is running on the host machine
	// We do an initial DNS lookup at startup and only try this host/port if the DNS lookup succeeds.
	// Setting this to true will disable the initial probe.
	DisableDockerProbe bool `json:"disabledockerprobe"`

	// ModuleName is the name of the Go module. If not specified, it will be determined
	// from the go.mod file.
	ModuleName string `json:"modulename"`

	// If true, try to synchronously connect to the server on Init
	ConnectOnInit bool `json:"connectoninit"`

	// Collector configurations
	Collectors CollectorConfig `json:"collectors"`

	// RunMode configuration
	RunMode RunModeConfig `json:"runmode,omitempty"`

	// Exec options
	Exec ExecConfig `json:"exec,omitempty"`
}

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration for normal usage

func DefaultConfigForOutrigDevelopment

func DefaultConfigForOutrigDevelopment() *Config

DefaultConfigForOutrigDevelopment returns a configuration specifically for Outrig internal development This is only used for internal Outrig development and not intended for general SDK users

func LoadConfig added in v0.9.0

func LoadConfig(overrideFileName string, cwd string) (*Config, string, error)

LoadConfig loads configuration from various sources in priority order. The overrideFileName parameter, if provided, takes highest priority and overrides all other sources. This is typically used when a config file is explicitly specified via CLI arguments. The cwd parameter specifies the working directory to use for config discovery. If empty, uses os.Getwd().

Configuration loading priority (highest to lowest):

  1. overrideFileName parameter (if not empty) - returns error if file doesn't exist
  2. OUTRIG_CONFIGJSON environment variable - JSON string
  3. OUTRIG_CONFIGFILE environment variable - file path
  4. outrig.json files found by walking up directory tree from specified working directory, stopping at project root markers (go.mod, .git) or home directory

Returns nil config (not an error) if no configuration is found through automatic discovery. Returns an error if an explicitly specified config source fails to load or parse.

func (*Config) UnmarshalJSON added in v0.9.0

func (c *Config) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom unmarshaling for Config with defaults

type ExecConfig added in v0.9.1

type ExecConfig struct {
	// Entry specifies the Go package or .go files to run (relative to config file location).
	// Examples: ".", "./cmd/myapp", "main.go", "cmd/myapp/main.go"
	// Must specify either Entry OR RawCmd, not both.
	Entry string `json:"entry,omitempty"`

	// BuildFlags are Go build flags to pass to the go run command.
	// Examples: ["-race", "-tags=debug", "-ldflags=-X main.version=1.0"]
	BuildFlags []string `json:"buildflags,omitempty"`

	// Args are command-line arguments to pass to the Go program after it's built.
	Args []string `json:"args,omitempty"`

	// Env specifies additional environment variables to set when running the program.
	Env map[string]string `json:"env,omitempty"`

	// Cwd specifies the working directory for the program (relative to config file location).
	// If not specified, defaults to the directory containing the config file.
	Cwd string `json:"cwd,omitempty"`

	// RawCmd specifies a raw shell command to execute instead of running Go code.
	// This runs through the shell, so $() and “ expansions will work.
	// Must specify either Entry OR RawCmd, not both.
	RawCmd string `json:"rawcmd,omitempty"`

	// RawCmdShell specifies which shell to use for RawCmd execution.
	// Defaults to $SHELL environment variable.
	RawCmdShell string `json:"rawcmdshell,omitempty"`
}

func (*ExecConfig) UnmarshalJSON added in v0.9.1

func (c *ExecConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom unmarshaling for ExecConfig with defaults

func (*ExecConfig) ValidateExecConfig added in v0.9.1

func (e *ExecConfig) ValidateExecConfig() error

ValidateExecConfig validates the ExecConfig for consistency

type GoRoutineConfig added in v0.5.0

type GoRoutineConfig struct {
	// Enabled indicates whether the goroutine collector is enabled
	Enabled bool `json:"enabled"`
}

func (*GoRoutineConfig) UnmarshalJSON added in v0.9.0

func (c *GoRoutineConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom unmarshaling for GoRoutineConfig with defaults

type LogProcessorConfig added in v0.5.0

type LogProcessorConfig struct {
	// Enabled indicates whether the log processor is enabled
	Enabled    bool `json:"enabled"`
	WrapStdout bool `json:"wrapstdout"`
	WrapStderr bool `json:"wrapstderr"`
	// OutrigPath is the full path to the outrig executable (including the executable name)
	// If empty, the system will look for "outrig" in the PATH
	OutrigPath string `json:"outrigpath"`
	// AdditionalArgs are additional arguments to pass to the outrig command
	// These are inserted before the "capturelogs" argument
	AdditionalArgs []string `json:"additionalargs"`
}

func (*LogProcessorConfig) UnmarshalJSON added in v0.9.0

func (c *LogProcessorConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom unmarshaling for LogProcessorConfig with defaults

type RunModeConfig added in v0.9.0

type RunModeConfig struct {
	// SDKReplacePath specifies an absolute path to replace the outrig SDK import.
	// This must be an absolute path to a local outrig SDK directory.
	SDKReplacePath string `json:"sdkreplacepath,omitempty"`

	// TransformPkgs specifies a list of additional package patterns to transform
	TransformPkgs []string `json:"transformpkgs,omitempty"`
}

func (*RunModeConfig) UnmarshalJSON added in v0.9.0

func (c *RunModeConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom unmarshaling for RunModeConfig with defaults

type RuntimeStatsConfig added in v0.5.0

type RuntimeStatsConfig struct {
	// Enabled indicates whether the runtime stats collector is enabled
	Enabled bool `json:"enabled"`
}

func (*RuntimeStatsConfig) UnmarshalJSON added in v0.9.0

func (c *RuntimeStatsConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom unmarshaling for RuntimeStatsConfig with defaults

type WatchConfig added in v0.5.0

type WatchConfig struct {
	// Enabled indicates whether the watch collector is enabled
	Enabled bool `json:"enabled"`
}

func (*WatchConfig) UnmarshalJSON added in v0.9.0

func (c *WatchConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom unmarshaling for WatchConfig with defaults

Jump to

Keyboard shortcuts

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