Advanced Configuration
While the Quick Start guide uses the simple autoinit approach, you can also manually initialize Outrig with custom configuration options for more control over its behavior. This is useful for suppressing output in production, changing the monitor port location, disabling specific SDK features, or conditionally initializing Outrig only in development environments.
Manual Initialization
Instead of using the autoinit import, you can manually configure and initialize Outrig:
import "github.com/outrigdev/outrig" func main() { cfg := outrig.DefaultConfig() outrig.Init("your-app-name", cfg) // rest of your code }
Warning
When using manual initialization, be sure to remove any existing autoinit import (import _ "github.com/outrigdev/outrig/autoinit"
) from your code. If both are present, the autoinit (default) settings will be applied since the first initialization wins, making your manual configuration ineffective.
Configuration Options
The Config
struct provides several options to customize Outrig's behavior. For the complete API reference, see the Go documentation.
Basic Configuration
type Config struct { // If true, suppresses init, connect, and disconnect messages Quiet bool // DomainSocketPath is the path to the Unix domain socket. If "" => use default. // If "-" => disable domain socket. DomainSocketPath string // 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 // 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 // ModuleName is the name of the Go module. If not specified, it will be // determined from the go.mod file. ModuleName string // If true, try to synchronously connect to the server on Init ConnectOnInit bool // Development mode flag Dev bool // Collector configurations LogProcessorConfig LogProcessorConfig WatchConfig WatchConfig GoRoutineConfig GoRoutineConfig RuntimeStatsConfig RuntimeStatsConfig }
Tip
Always use DefaultConfig()
as your starting point to ensure all fields are properly initialized with sensible defaults.
Tip
Set Quiet = true
to suppress Outrig's initialization messages when stdout is important, such as in MCP servers or CLI tools that output structured data.
Log Processor Configuration
Control how Outrig captures and processes logs from your application:
type LogProcessorConfig struct { // Enabled indicates whether the log processor is enabled Enabled bool // WrapStdout captures stdout output WrapStdout bool // WrapStderr captures stderr output WrapStderr bool // 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 // AdditionalArgs are additional arguments to pass to the outrig command // These are inserted before the "capturelogs" argument AdditionalArgs []string }
Watch Configuration
Configure the variable watching functionality:
type WatchConfig struct { // Enabled indicates whether the watch collector is enabled Enabled bool }
GoRoutine Configuration
Control goroutine monitoring:
type GoRoutineConfig struct { // Enabled indicates whether the goroutine collector is enabled Enabled bool }
Runtime Stats Configuration
Configure runtime statistics collection:
type RuntimeStatsConfig struct { // Enabled indicates whether the runtime stats collector is enabled Enabled bool }
Example Configurations
Development Mode Only
Only initialize Outrig when your own application is running in development mode:
func main() { // Only enable Outrig when YOUR application is in development mode // change this condition to match how you determine development mode if os.Getenv("ENV") == "development" { cfg := outrig.DefaultConfig() cfg.ConnectOnInit = true cfg.Quiet = false outrig.Init("my-app", cfg) } // your application code }
Remote Connection
Connect to Outrig running on a remote machine:
func main() { cfg := outrig.DefaultConfig() cfg.TcpAddr = "192.168.1.100:5005" // Remote Outrig server cfg.DomainSocketPath = "-" // Disable local socket outrig.Init("my-app", cfg) // your application code }
Environment Variables
Outrig supports several environment variables that can override configuration settings (this can be useful in production or containerized environments):
OUTRIG_DISABLED
Completely disables Outrig initialization when set to any non-empty value (can be useful in environments where you want to disable monitoring without changing code).
export OUTRIG_DISABLED="1"
OUTRIG_DOMAINSOCKET
Sets an override domain socket path. Use -
to disable domain socket connections.
export OUTRIG_DOMAINSOCKET="/custom/path/outrig.sock" # or disable domain socket export OUTRIG_DOMAINSOCKET="-"
OUTRIG_TCPADDR
Sets an override TCP address for connecting to the Outrig server. Use -
to disable TCP connections.
export OUTRIG_TCPADDR="192.168.1.100:5005" # or disable TCP export OUTRIG_TCPADDR="-"
OUTRIG_DISABLEDOCKERPROBE
Disables the automatic probe for host.docker.internal:5005
when running in Docker environments. See Using Docker for more details.
export OUTRIG_DISABLEDOCKERPROBE="1"
Tip
Environment variables take precedence over configuration settings, making them useful for deployment-specific overrides without code changes.