mirror of
https://github.com/marcusDenslow/terminalShop.git
synced 2026-10-25 02:52:20 +02:00
feat: add OpenTelemetry tracing
This commit is contained in:
12
api/main.go
12
api/main.go
@@ -15,6 +15,7 @@ import (
|
||||
"terminalShop/pkg/auth"
|
||||
"terminalShop/pkg/config"
|
||||
"terminalShop/pkg/database"
|
||||
"terminalShop/pkg/observability"
|
||||
)
|
||||
|
||||
const version = "v0.1.0"
|
||||
@@ -45,6 +46,17 @@ func main() {
|
||||
log.Fatalf("Failed to seed database: %v", err)
|
||||
}
|
||||
|
||||
otlpEndpoint := os.Getenv("OTLP_ENDPOINT")
|
||||
if otlpEndpoint == "" {
|
||||
otlpEndpoint = "tempo:4318"
|
||||
}
|
||||
shutdown, err := observability.InitTracing(context.Background(), "terminalshop-api", otlpEndpoint)
|
||||
if err != nil {
|
||||
log.Printf("tracing init failed (non-fatal): %v", err)
|
||||
} else {
|
||||
defer shutdown(context.Background())
|
||||
}
|
||||
|
||||
// Init JWT manager (same secret + duration as SSH server)
|
||||
jwtManager := auth.NewJWTManager(cfg.JWTSecret, 30*time.Minute)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user