feat(main): wire embedded Perses + VM toggle
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/claude-agent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
|||||||
|
|
||||||
"github.com/fujin/anthropic-proxy/internal/auth"
|
"github.com/fujin/anthropic-proxy/internal/auth"
|
||||||
"github.com/fujin/anthropic-proxy/internal/config"
|
"github.com/fujin/anthropic-proxy/internal/config"
|
||||||
|
"github.com/fujin/anthropic-proxy/internal/embedded"
|
||||||
"github.com/fujin/anthropic-proxy/internal/logging"
|
"github.com/fujin/anthropic-proxy/internal/logging"
|
||||||
"github.com/fujin/anthropic-proxy/internal/proxy"
|
"github.com/fujin/anthropic-proxy/internal/proxy"
|
||||||
"github.com/fujin/anthropic-proxy/internal/ratelimit"
|
"github.com/fujin/anthropic-proxy/internal/ratelimit"
|
||||||
@@ -36,7 +37,7 @@ func run() error {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Initialize telemetry (metrics always active; OTLP export when endpoint set)
|
// Initialize telemetry (metrics always active; OTLP export when endpoint set)
|
||||||
telemetryShutdown, logBridge, err := telemetry.Setup(context.Background(), cfg.Telemetry, tracker)
|
telemetryShutdown, logBridge, metricsHandler, err := telemetry.Setup(context.Background(), cfg.Telemetry, tracker)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("telemetry setup: %w", err)
|
return fmt.Errorf("telemetry setup: %w", err)
|
||||||
}
|
}
|
||||||
@@ -115,8 +116,27 @@ func run() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Start embedded observability stack (VM + Perses) if enabled
|
||||||
|
var vm *embedded.VM
|
||||||
|
var perses *embedded.Perses
|
||||||
|
if cfg.Telemetry.Embedded.Enabled {
|
||||||
|
vm = embedded.NewVM(cfg.Telemetry.Embedded, cfg.Port)
|
||||||
|
if err := vm.Start(); err != nil {
|
||||||
|
log.Error().Err(err).Msg("failed to start victoria-metrics")
|
||||||
|
} else {
|
||||||
|
defer vm.Stop()
|
||||||
|
}
|
||||||
|
|
||||||
|
perses = embedded.NewPerses(cfg.Telemetry.Embedded, cfg.Port)
|
||||||
|
if err := perses.Start(); err != nil {
|
||||||
|
log.Error().Err(err).Msg("failed to start perses")
|
||||||
|
} else {
|
||||||
|
defer perses.Stop()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
log.Info().Int("port", cfg.Port).Msg("starting server")
|
log.Info().Int("port", cfg.Port).Msg("starting server")
|
||||||
srv := server.New(cfg, pool, profile, tracker)
|
srv := server.New(cfg, pool, profile, tracker, metricsHandler)
|
||||||
|
|
||||||
quit := make(chan os.Signal, 1)
|
quit := make(chan os.Signal, 1)
|
||||||
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
|
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
|
||||||
|
|||||||
Reference in New Issue
Block a user