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 <clio-agent@sisyphuslabs.ai>
This commit is contained in:
+37
-11
@@ -11,12 +11,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Port int `yaml:"port"`
|
Port int `yaml:"port"`
|
||||||
APIKeys []string `yaml:"api_keys"`
|
APIKeys []string `yaml:"api_keys"`
|
||||||
ClaudeBinary string `yaml:"claude_binary"`
|
ClaudeBinary string `yaml:"claude_binary"`
|
||||||
Sanitize SanitizeConfig `yaml:"sanitize"`
|
Sanitize SanitizeConfig `yaml:"sanitize"`
|
||||||
Logging LoggingConfig `yaml:"logging"`
|
Logging LoggingConfig `yaml:"logging"`
|
||||||
Telemetry TelemetryConfig `yaml:"telemetry"`
|
Telemetry TelemetryConfig `yaml:"telemetry"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SanitizeConfig struct {
|
type SanitizeConfig struct {
|
||||||
@@ -36,13 +36,27 @@ type ReplaceRule struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type TelemetryConfig struct {
|
type TelemetryConfig struct {
|
||||||
Endpoint string `yaml:"endpoint"`
|
Export ExportConfig `yaml:"export"`
|
||||||
Insecure bool `yaml:"insecure"`
|
Embedded EmbeddedConfig `yaml:"embedded"`
|
||||||
ServiceName string `yaml:"service_name"`
|
ServiceName string `yaml:"service_name"`
|
||||||
Headers map[string]string `yaml:"headers"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
type LoggingConfig struct {
|
||||||
Level string `yaml:"level"`
|
Level string `yaml:"level"`
|
||||||
@@ -89,6 +103,18 @@ func Load(path string) (*Config, error) {
|
|||||||
if cfg.Telemetry.ServiceName == "" {
|
if cfg.Telemetry.ServiceName == "" {
|
||||||
cfg.Telemetry.ServiceName = "anthropic-proxy"
|
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
|
// Check for deprecated claude_credentials field
|
||||||
var rawCfg map[string]interface{}
|
var rawCfg map[string]interface{}
|
||||||
|
|||||||
Reference in New Issue
Block a user