Documentation
¶
Index ¶
- func ApplyMemoryLimit() (int64, string)
- type App
- type AuthConfig
- type BroadcastAppConfig
- type BroadcastConfig
- type Config
- type DatabaseConfig
- type ExplainConfig
- type MCPConfig
- type MetricsConfig
- type MockConditionDef
- type MockDef
- type MockOpenAPIDef
- type ModulesConfig
- type ProjectDef
- type RetentionConfig
- type SMTPRelayConfig
- type SentryConfig
- type ServerConfig
- type StorageConfig
- type TCPConfig
- type TCPServerConfig
- type UIConfig
- type UpdateCheckConfig
- type UpdateConfig
- type WebhookDef
- type XdebugConfig
- type XdebugTraceConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyMemoryLimit ¶
ApplyMemoryLimit sets the Go runtime's soft memory limit, so the garbage collector works harder before a container's limit kills the process (GitHub #331). GOMEMLIMIT, when set, wins: the runtime has applied it already. Otherwise memLimitShare of the cgroup limit is used. It returns the limit in bytes (0 = none) and where it came from.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App orchestrates all servers and modules.
type AuthConfig ¶
type AuthConfig struct {
Enabled bool `yaml:"enabled"` // Enable authentication (default: false).
Provider string `yaml:"provider"` // Provider type: "auth0", "google", "github", "keycloak", "gitlab", "oidc" (default: "oidc").
ProviderURL string `yaml:"provider_url"` // OIDC issuer URL (e.g., https://xxx.us.auth0.com). Used for OIDC discovery.
ClientID string `yaml:"client_id"` // OAuth2 client ID.
ClientSecret string `yaml:"client_secret"` // OAuth2 client secret.
CallbackURL string `yaml:"callback_url"` // OAuth2 callback URL (e.g., http://localhost:8000/auth/sso/callback).
Scopes string `yaml:"scopes"` // Comma-separated scopes (default: "openid,email,profile"; github: "read:user,user:email").
JWTSecret string `yaml:"jwt_secret"` // Secret for signing internal JWT tokens. Required when auth is enabled.
// AllowedEmails and AllowedDomains limit who may sign in (verified email
// required). Both empty = everyone the provider lets in.
AllowedEmails []string `yaml:"allowed_emails"` // e.g. ["me@gmail.com"]; env AUTH_ALLOWED_EMAILS (comma list)
AllowedDomains []string `yaml:"allowed_domains"` // e.g. ["mycompany.com"]; google: Workspace (hd) domain; env AUTH_ALLOWED_DOMAINS
// AdminEmails may read the audit log (GET /api/audit). Empty = every
// signed-in user.
AdminEmails []string `yaml:"admin_emails"` // env AUTH_ADMIN_EMAILS (comma list)
}
AuthConfig controls authentication via OAuth2/OIDC providers.
type BroadcastAppConfig ¶ added in v2.13.0
BroadcastAppConfig is one app's key and secret.
type BroadcastConfig ¶ added in v2.13.0
type BroadcastConfig struct {
Upstream string `yaml:"upstream"` // e.g. http://127.0.0.1:8080 (Reverb); empty = capture only
Apps []BroadcastAppConfig `yaml:"apps"` // secrets to check signatures; none = not checked
}
BroadcastConfig is the module broadcast. Without an upstream events are only captured; with one, the request also goes to the real server.
func (BroadcastConfig) Secrets ¶ added in v2.13.0
func (b BroadcastConfig) Secrets() map[string]string
Secrets maps each app key to its secret.
type Config ¶
type Config struct {
Server ServerConfig `yaml:"server"`
Database DatabaseConfig `yaml:"database"`
Storage StorageConfig `yaml:"storage"`
TCP TCPConfig `yaml:"tcp"`
Metrics MetricsConfig `yaml:"metrics"`
MCP MCPConfig `yaml:"mcp"`
Xdebug XdebugConfig `yaml:"xdebug"`
Auth AuthConfig `yaml:"auth"`
UI UIConfig `yaml:"ui"`
Sentry SentryConfig `yaml:"sentry"`
Modules ModulesConfig `yaml:"modules"`
Webhooks []WebhookDef `yaml:"webhooks"`
Projects []ProjectDef `yaml:"projects"`
Mocks []MockDef `yaml:"mocks"`
// MocksOpenAPI are OpenAPI specs turned into read-only mock rules at start.
MocksOpenAPI []MockOpenAPIDef `yaml:"mocks_openapi"`
// UpdateCheck asks GitHub for the latest release so the UI can say a new
// version is out.
UpdateCheck UpdateCheckConfig `yaml:"update_check"`
// Update controls installing a new release from the UI.
Update UpdateConfig `yaml:"update"`
// XdebugTrace bounds uploaded Xdebug function traces (module xdebug-trace).
XdebugTrace XdebugTraceConfig `yaml:"xdebug_trace"`
// Retention deletes old events in the background; unset keeps everything.
Retention RetentionConfig `yaml:"retention"`
// SMTPRelay is the outgoing SMTP server a caught email can be released
// to from the UI; off while host is empty.
SMTPRelay SMTPRelayConfig `yaml:"smtp_relay"`
// Broadcast is the Pusher-compatible events catcher (Laravel Reverb,
// Pusher, soketi): an optional upstream to forward to, app secrets.
Broadcast BroadcastConfig `yaml:"broadcast"`
// Explain sends a Sentry error to a harnsy project's agents over h2a
// and shows their answers; off unless url and token are set.
Explain ExplainConfig `yaml:"explain"`
Version string `yaml:"-"`
// Shortcuts.
HTTPAddr string `yaml:"-"`
DatabaseDSN string `yaml:"-"`
SMTPAddr string `yaml:"-"`
MonologAddr string `yaml:"-"`
VarDumperAddr string `yaml:"-"`
ProxyAddr string `yaml:"-"`
}
Config holds application configuration.
func LoadConfig ¶
func LoadConfig() Config
func (Config) ListenPorts ¶ added in v2.11.0
ListenPorts gives the port of each listener that is on, for /api/settings: the setup help fills real values. A listener that is off, or whose address has no fixed port, is left out; the UI then shows its default.
type DatabaseConfig ¶
type DatabaseConfig struct {
Driver string `yaml:"driver"`
DSN string `yaml:"dsn"`
// MaxOpenConns is the size of the SQLite connection pool (default 4).
//
// With a single connection ingestion and UI queries share one queue: a heavy
// list slows down writes, and writes slow down the list. In WAL mode readers
// disturb neither each other nor the writer, so a pool is safe; the writer is
// still serialized by SQLite itself, and busy_timeout in the DSN makes a
// competing write wait instead of failing.
MaxOpenConns int `yaml:"max_open_conns"`
}
type ExplainConfig ¶ added in v2.15.0
type ExplainConfig struct {
URL string `yaml:"url"` // wss://<harnsy gateway>/h2a/v1
Token string `yaml:"token"` // the pass's token (h2a_…); a secret
To string `yaml:"to"` // address the explanations go to; default: lead
}
ExplainConfig is the h2a connection of «Explain this error» (a concept).
func (ExplainConfig) On ¶ added in v2.15.0
func (c ExplainConfig) On() bool
On reports whether the explain module runs.
type MCPConfig ¶
type MCPConfig struct {
Enabled bool `yaml:"enabled"` // Enable MCP server (default: false).
Transport string `yaml:"transport"` // "socket" (Unix socket, default) or "http" (HTTP SSE for remote access).
SocketPath string `yaml:"socket_path"` // Unix socket path (for transport=socket). Default: /tmp/buggregator-mcp.sock
Addr string `yaml:"addr"` // HTTP listen address (for transport=http). Default: :8001
AuthToken string `yaml:"auth_token"` // Bearer token for HTTP transport auth. Empty = no auth.
// ReadOnly drops every tool that changes data or drives a debug session
// (event_delete, mock writes, xdebug control and eval): for agents that
// should only look (default: false).
ReadOnly bool `yaml:"read_only"`
// MockWrite exposes the MCP tools that create, change and delete mock
// rules (default: true; false leaves the read and preview tools).
MockWrite *bool `yaml:"mock_write"`
}
MCPConfig controls the MCP (Model Context Protocol) server.
func (MCPConfig) MockWriteOn ¶
MockWriteOn reports whether the MCP mock write tools are on (default true).
type MetricsConfig ¶
type MetricsConfig struct {
Enabled bool `yaml:"enabled"`
Addr string `yaml:"addr"` // Separate metrics server address (e.g., ":9090"). Empty = use main HTTP server.
}
MetricsConfig controls Prometheus metrics.
type MockConditionDef ¶ added in v2.16.0
type MockConditionDef struct {
In string `yaml:"in"`
Name string `yaml:"name"`
Op string `yaml:"op"`
Value string `yaml:"value"`
}
MockConditionDef is one condition of a config mock rule: in (header or body), name (header name, or body path a.b, items.0.id, items.*.id), op (equals, not_equals, exists, not_exists; default equals) and value.
type MockDef ¶
type MockDef struct {
Name string `yaml:"name"`
Method string `yaml:"method"` // GET, POST, … or ANY (default)
Path string `yaml:"path"` // /users/me, /users/{id}, /files/*
Status int `yaml:"status"` // default 200
Headers map[string]string `yaml:"headers"`
Body string `yaml:"body"`
Delay string `yaml:"delay"` // e.g. "150ms", at most 30s
Project string `yaml:"project"` // empty = every project
// Template makes body and header values Go templates (request values, fake data).
Template bool `yaml:"template"`
Seed int64 `yaml:"seed"` // not 0: the same fake data on every request
// Conditions on request headers and JSON body fields; all must hold.
Conditions []MockConditionDef `yaml:"conditions"`
}
type MockOpenAPIDef ¶
type MockOpenAPIDef struct {
File string `yaml:"file"` // path to the spec, YAML or JSON
Project string `yaml:"project"` // empty = every project
Group string `yaml:"group"` // default openapi:<info.title>, openapi:<project>:<info.title> with a project
BasePath *string `yaml:"base_path"` // default the path of servers[0].url; "" = none
}
WebhookDef defines a webhook from config. MockDef is a read-only mock rule from the config file (see #332): requests to /mock<path> get this response. MockOpenAPIDef is one OpenAPI spec file of the mocks_openapi section.
type ModulesConfig ¶
type ModulesConfig struct {
Sentry *bool `yaml:"sentry"`
Ray *bool `yaml:"ray"`
VarDump *bool `yaml:"var-dump"`
Inspector *bool `yaml:"inspector"`
Monolog *bool `yaml:"monolog"`
SMTP *bool `yaml:"smtp"`
SMS *bool `yaml:"sms"`
CSP *bool `yaml:"csp"` // browser CSP / Reporting API reports
HTML *bool `yaml:"html"` // events with the sender's own HTML markup
Broadcast *bool `yaml:"broadcast"` // Pusher HTTP API events (Laravel Reverb, Pusher)
HttpDump *bool `yaml:"http-dump"`
Profiler *bool `yaml:"profiler"`
// XdebugTrace is the Xdebug function trace upload (type xdebug-trace).
XdebugTrace *bool `yaml:"xdebug-trace"`
}
ModulesConfig controls which modules are enabled. By default all modules are enabled. Set to false to disable.
func (*ModulesConfig) Disable ¶
func (m *ModulesConfig) Disable(moduleType string)
Disable turns a module off, e.g. when it cannot start, so EnabledTypes (the UI menu) no longer lists it.
func (ModulesConfig) EnabledTypes ¶
func (m ModulesConfig) EnabledTypes() []string
EnabledTypes returns a list of enabled module type strings.
func (ModulesConfig) IsEnabled ¶
func (m ModulesConfig) IsEnabled(moduleType string) bool
IsEnabled returns true if a module is enabled (default: true).
type ProjectDef ¶
ProjectDef defines a project from config.
type RetentionConfig ¶ added in v2.11.0
type RetentionConfig struct {
MaxAge string `yaml:"max_age"` // delete events older than this: "30m", "24h", "7d"; empty or 0 = keep
MaxEvents int `yaml:"max_events"` // keep at most this many events in total, newest first; 0 = no cap
MaxAgeDur time.Duration `yaml:"-"` // parsed MaxAge, 0 = off
}
RetentionConfig is the optional auto-cleanup. Pinned events are never deleted and do not count towards max_events.
type SMTPRelayConfig ¶ added in v2.13.0
type SMTPRelayConfig struct {
Host string `yaml:"host"` // empty = release off
Port int `yaml:"port"` // default 587 (starttls), 465 (tls), 25 (none)
TLS string `yaml:"tls"` // starttls (default), tls or none
Username string `yaml:"username"` // empty = no AUTH
Password string `yaml:"password"` // prefer SMTP_RELAY_PASSWORD or password_file
PasswordFile string `yaml:"password_file"` // file holding the password (a Docker/K8s secret)
From string `yaml:"from"` // MAIL FROM; empty = the message's From
AllowedRecipients []string `yaml:"allowed_recipients"` // patterns like "*@example.com"; empty = any
InsecureSkipVerify bool `yaml:"insecure_skip_verify"` // accept any TLS certificate
}
SMTPRelayConfig is the outgoing SMTP server for releasing a caught email to a real inbox. The password comes from the env or a file, never back out through the API.
type SentryConfig ¶ added in v2.11.0
type SentryConfig struct {
// SourceFetch: where the server may fetch the source of JS stack frames
// (frame filename is a URL): "private" (default) loopback and private
// hosts only, "any" any host, "off" never.
SourceFetch string `yaml:"source_fetch"`
}
SentryConfig controls the Sentry module.
type ServerConfig ¶
type StorageConfig ¶
type TCPConfig ¶
type TCPConfig struct {
SMTP TCPServerConfig `yaml:"smtp"`
Monolog TCPServerConfig `yaml:"monolog"`
VarDumper TCPServerConfig `yaml:"var-dumper"`
Proxy TCPServerConfig `yaml:"proxy"`
}
type TCPServerConfig ¶
type TCPServerConfig struct {
Addr string `yaml:"addr"`
}
type UIConfig ¶
type UIConfig struct {
DefaultLimit *int `yaml:"default_limit"` // events returned without a limit param; unset or 0 = unlimited
MaxLimit *int `yaml:"max_limit"` // ceiling for an explicit limit (default 5000); 0 = no ceiling
DefaultWindow string `yaml:"default_window"` // time window without from/to: "24h", "7d"; empty or "all" = no window
}
UIConfig bounds the event lists served to the UI.
/api/events and /api/events/preview used to return everything stored for a project. By default they still do: the current UI loads the list once and does not page, so a cap would hide older events. default_limit and default_window opt in to smaller responses.
The limits are pointers so an explicit 0 (no limit) differs from "not set".
type UpdateCheckConfig ¶
type UpdateCheckConfig struct {
Enabled *bool `yaml:"enabled"` // default true; false = no network call at all
Interval string `yaml:"interval"` // Go duration between checks, default 12h, at least 1h
IntervalDur time.Duration `yaml:"-"`
}
UpdateCheckConfig controls the new-version check (GitHub releases/latest).
func (UpdateCheckConfig) On ¶
func (c UpdateCheckConfig) On() bool
On reports whether the check runs (default true).
type UpdateConfig ¶ added in v2.11.0
type UpdateConfig struct {
// SelfUpdate: "auto" (default) the UI may update a binary install unless
// the server listens beyond loopback without auth; "on" also then; "off"
// never.
SelfUpdate string `yaml:"self_update"`
// ReleaseURL replaces the GitHub releases/latest API (a mirror); empty =
// GitHub. Downloads are still checked against the built-in release key.
ReleaseURL string `yaml:"release_url"`
}
UpdateConfig controls updating from the UI (binary installs only).
type WebhookDef ¶
type WebhookDef struct {
Event string `yaml:"event"` // Event type to match ("sentry", "ray", "*" for all).
URL string `yaml:"url"` // Target URL.
Headers map[string]string `yaml:"headers"` // Custom HTTP headers.
VerifySSL *bool `yaml:"verify_ssl"` // Verify SSL certificates (default: false).
Retry *bool `yaml:"retry"` // Retry on failure (default: true).
}
type XdebugConfig ¶
type XdebugConfig struct {
Enabled bool `yaml:"enabled"` // Enable the proxy (default: false).
Addr string `yaml:"addr"` // Where Xdebug connects. Default: 127.0.0.1:9003
IDEAddr string `yaml:"ide_addr"` // Where the IDE listens. Default: 127.0.0.1:9004
AllowEval bool `yaml:"allow_eval"` // Expose the xdebug_eval MCP tool (default: false).
AllowControl *bool `yaml:"allow_control"` // Expose the MCP control tools: step, continue, stop, wait (default: true).
Mode string `yaml:"mode"` // proxy, auto or standalone. Default: auto
PauseOnFirstLine bool `yaml:"pause_on_first_line"` // A session driven here stops at the first line (default: false).
IdleTimeout string `yaml:"idle_timeout"` // Release a session paused here after this long without a command. Default: 10m; 0 = never
IdleTimeoutDur time.Duration `yaml:"-"` // parsed IdleTimeout: 0 = default, <0 = never
}
XdebugConfig controls the Xdebug (DBGp) proxy: Xdebug → Buggregator → IDE, or Buggregator drives the session itself when there is no IDE.
func (XdebugConfig) AllowControlOn ¶
func (c XdebugConfig) AllowControlOn() bool
AllowControlOn reports whether the MCP control tools are on (default true).
type XdebugTraceConfig ¶
type XdebugTraceConfig struct {
MaxUpload string `yaml:"max_upload"` // request body, gzip or not. Default: 100MB
MaxSize string `yaml:"max_size"` // uncompressed bytes read; a longer trace is cut. Default: 256MB
Keep int `yaml:"keep"` // traces kept, the oldest go first. Default: 20
MaxUploadBytes int64 `yaml:"-"`
MaxSizeBytes int64 `yaml:"-"`
}
XdebugTraceConfig bounds uploaded Xdebug traces. Sizes take a plain byte count or a KB/MB/GB suffix (1024-based).