From 1bc704a7b231aa7e30abc2dd7d250c29333f393e Mon Sep 17 00:00:00 2001 From: Alexander Date: Tue, 14 Apr 2026 21:56:32 +0200 Subject: [PATCH] refactor(config): restructure telemetry config with export and embedded sub-configs Ultraworked with [Sisyphus](https://github.com/code-yeongyu/claude-agent) Co-authored-by: Sisyphus --- internal/config/config.go | 48 ++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index 718908d..97f9753 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -11,12 +11,12 @@ import ( ) type Config struct { - Port int `yaml:"port"` - APIKeys []string `yaml:"api_keys"` - ClaudeBinary string `yaml:"claude_binary"` - Sanitize SanitizeConfig `yaml:"sanitize"` - Logging LoggingConfig `yaml:"logging"` - Telemetry TelemetryConfig `yaml:"telemetry"` + Port int `yaml:"port"` + APIKeys []string `yaml:"api_keys"` + ClaudeBinary string `yaml:"claude_binary"` + Sanitize SanitizeConfig `yaml:"sanitize"` + Logging LoggingConfig `yaml:"logging"` + Telemetry TelemetryConfig `yaml:"telemetry"` } type SanitizeConfig struct { @@ -36,13 +36,27 @@ type ReplaceRule struct { } type TelemetryConfig struct { - Endpoint string `yaml:"endpoint"` - Insecure bool `yaml:"insecure"` - ServiceName string `yaml:"service_name"` - Headers map[string]string `yaml:"headers"` + Export ExportConfig `yaml:"export"` + Embedded EmbeddedConfig `yaml:"embedded"` + ServiceName string `yaml:"service_name"` } -func (t TelemetryConfig) ExportEnabled() bool { return t.Endpoint != "" } +type ExportConfig struct { + Endpoint string `yaml:"endpoint"` + Insecure bool `yaml:"insecure"` + Headers map[string]string `yaml:"headers"` +} + +func (e ExportConfig) Enabled() bool { return e.Endpoint != "" } + +type EmbeddedConfig struct { + Enabled bool `yaml:"enabled"` + Port int `yaml:"port"` + PersesBinary string `yaml:"perses_binary"` + VMBinary string `yaml:"vm_binary"` + VMPort int `yaml:"vm_port"` + BinDir string `yaml:"bin_dir"` +} type LoggingConfig struct { Level string `yaml:"level"` @@ -89,6 +103,18 @@ func Load(path string) (*Config, error) { if cfg.Telemetry.ServiceName == "" { cfg.Telemetry.ServiceName = "anthropic-proxy" } + if cfg.Telemetry.Embedded.Port == 0 { + cfg.Telemetry.Embedded.Port = 8080 + } + if cfg.Telemetry.Embedded.PersesBinary == "" { + cfg.Telemetry.Embedded.PersesBinary = "perses" + } + if cfg.Telemetry.Embedded.VMBinary == "" { + cfg.Telemetry.Embedded.VMBinary = "victoria-metrics" + } + if cfg.Telemetry.Embedded.VMPort == 0 { + cfg.Telemetry.Embedded.VMPort = 8428 + } // Check for deprecated claude_credentials field var rawCfg map[string]interface{}