Add telemetry

This commit is contained in:
Alexander
2026-04-14 10:31:56 +02:00
parent 20049881ad
commit 9cc052c162
15 changed files with 580 additions and 62 deletions
+15 -1
View File
@@ -3,6 +3,7 @@ package main
import (
"context"
"fmt"
"io"
"net/http"
"os"
"os/signal"
@@ -14,6 +15,7 @@ import (
"github.com/fujin/anthropic-proxy/internal/logging"
"github.com/fujin/anthropic-proxy/internal/proxy"
"github.com/fujin/anthropic-proxy/internal/server"
"github.com/fujin/anthropic-proxy/internal/telemetry"
"github.com/rs/zerolog/log"
)
@@ -23,6 +25,18 @@ func run() error {
return fmt.Errorf("load config: %w", err)
}
// Initialize telemetry (metrics always active; OTLP export when endpoint set)
telemetryShutdown, logBridge, err := telemetry.Setup(context.Background(), cfg.Telemetry)
if err != nil {
return fmt.Errorf("telemetry setup: %w", err)
}
defer telemetryShutdown(context.Background())
var extraWriters []io.Writer
if logBridge != nil {
extraWriters = append(extraWriters, logBridge)
}
logging.Setup(logging.Config{
Level: cfg.Logging.Level,
File: cfg.Logging.File,
@@ -30,7 +44,7 @@ func run() error {
MaxBackups: cfg.Logging.MaxBackups,
MaxAgeDays: cfg.Logging.MaxAgeDays,
Compress: cfg.Logging.Compress,
})
}, extraWriters...)
// Load credentials from ~/.claude/.credentials.json
creds, err := config.LoadDefaultCredentials()