Add telemetry
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user