before refactor

This commit is contained in:
2026-04-03 18:12:40 +02:00
parent 26265e776c
commit 0fd17e4944
3 changed files with 40 additions and 25 deletions
+32 -23
View File
@@ -179,37 +179,46 @@ func main() {
} }
}() }()
// OTLP HTTP endpoints // OTLP HTTP mux (standard OTel port 4318)
http.HandleFunc("/v1/traces", handleTraces(coll)) otelMux := http.NewServeMux()
http.HandleFunc("/v1/metrics", handleMetrics(coll)) otelMux.HandleFunc("/v1/traces", handleTraces(coll))
http.HandleFunc("/v1/logs", handleLogs(coll)) otelMux.HandleFunc("/v1/metrics", handleMetrics(coll))
otelMux.HandleFunc("/v1/logs", handleLogs(coll))
// History API endpoints // UI and API mux (port 8080)
http.HandleFunc("/api/history", handleHistory(coll)) uiMux := http.NewServeMux()
http.HandleFunc("/api/history/traces", handleHistoryByType(coll, "traces")) // Also register OTLP endpoints on 8080 for backwards compatibility
http.HandleFunc("/api/history/metrics", handleHistoryByType(coll, "metrics")) uiMux.HandleFunc("/v1/traces", handleTraces(coll))
http.HandleFunc("/api/history/logs", handleHistoryByType(coll, "logs")) uiMux.HandleFunc("/v1/metrics", handleMetrics(coll))
http.HandleFunc("/api/history/search", handleSearch(coll)) uiMux.HandleFunc("/v1/logs", handleLogs(coll))
http.HandleFunc("/api/history/wait", handleWait(coll))
// WebSocket server for visualization uiMux.HandleFunc("/api/history", handleHistory(coll))
http.HandleFunc("/ws", wsServer.HandleConnections) uiMux.HandleFunc("/api/history/traces", handleHistoryByType(coll, "traces"))
uiMux.HandleFunc("/api/history/metrics", handleHistoryByType(coll, "metrics"))
uiMux.HandleFunc("/api/history/logs", handleHistoryByType(coll, "logs"))
uiMux.HandleFunc("/api/history/search", handleSearch(coll))
uiMux.HandleFunc("/api/history/wait", handleWait(coll))
uiMux.HandleFunc("/ws", wsServer.HandleConnections)
uiMux.Handle("/", spaHandler(http.Dir("./dist")))
// Serve static files with SPA fallback log.Printf("Starting HTTP server on port 8080 (UI/API)")
http.Handle("/", spaHandler(http.Dir("./dist"))) log.Printf("OTLP HTTP endpoints (also on port 8080):")
log.Printf("Starting HTTP server on port 8080")
log.Printf("OTLP HTTP endpoints:")
log.Printf(" Traces: http://localhost:8080/v1/traces") log.Printf(" Traces: http://localhost:8080/v1/traces")
log.Printf(" Metrics: http://localhost:8080/v1/metrics") log.Printf(" Metrics: http://localhost:8080/v1/metrics")
log.Printf(" Logs: http://localhost:8080/v1/logs") log.Printf(" Logs: http://localhost:8080/v1/logs")
log.Printf("OTLP gRPC endpoints:") log.Printf("OTLP gRPC endpoint:")
log.Printf(" Traces: localhost:4317") log.Printf(" Traces/Metrics/Logs: localhost:4317")
log.Printf(" Metrics: localhost:4317")
log.Printf(" Logs: localhost:4317")
log.Printf("WebSocket: ws://localhost:8080/ws") log.Printf("WebSocket: ws://localhost:8080/ws")
if err := http.ListenAndServe(":8080", nil); err != nil { // Start OTLP HTTP server on port 4318
go func() {
log.Printf("Starting OTLP HTTP server on port 4318")
if err := http.ListenAndServe(":4318", otelMux); err != nil {
log.Printf("failed to start OTLP HTTP server: %v", err)
}
}()
if err := http.ListenAndServe(":8080", uiMux); err != nil {
log.Fatalf("failed to start HTTP server: %v", err) log.Fatalf("failed to start HTTP server: %v", err)
} }
} }
+2
View File
@@ -20,6 +20,8 @@ spec:
name: http name: http
- containerPort: 4317 - containerPort: 4317
name: grpc name: grpc
- containerPort: 4318
name: otlp-http
env: env:
- name: GRPC_GO_LOG_SEVERITY_LEVEL - name: GRPC_GO_LOG_SEVERITY_LEVEL
value: "info" value: "info"
+4
View File
@@ -14,4 +14,8 @@ spec:
port: 4317 port: 4317
targetPort: 4317 targetPort: 4317
protocol: TCP protocol: TCP
- name: otlp-http
port: 4318
targetPort: 4318
protocol: TCP
type: ClusterIP type: ClusterIP