before refactor
This commit is contained in:
+34
-25
@@ -179,37 +179,46 @@ func main() {
|
||||
}
|
||||
}()
|
||||
|
||||
// OTLP HTTP endpoints
|
||||
http.HandleFunc("/v1/traces", handleTraces(coll))
|
||||
http.HandleFunc("/v1/metrics", handleMetrics(coll))
|
||||
http.HandleFunc("/v1/logs", handleLogs(coll))
|
||||
// OTLP HTTP mux (standard OTel port 4318)
|
||||
otelMux := http.NewServeMux()
|
||||
otelMux.HandleFunc("/v1/traces", handleTraces(coll))
|
||||
otelMux.HandleFunc("/v1/metrics", handleMetrics(coll))
|
||||
otelMux.HandleFunc("/v1/logs", handleLogs(coll))
|
||||
|
||||
// History API endpoints
|
||||
http.HandleFunc("/api/history", handleHistory(coll))
|
||||
http.HandleFunc("/api/history/traces", handleHistoryByType(coll, "traces"))
|
||||
http.HandleFunc("/api/history/metrics", handleHistoryByType(coll, "metrics"))
|
||||
http.HandleFunc("/api/history/logs", handleHistoryByType(coll, "logs"))
|
||||
http.HandleFunc("/api/history/search", handleSearch(coll))
|
||||
http.HandleFunc("/api/history/wait", handleWait(coll))
|
||||
// UI and API mux (port 8080)
|
||||
uiMux := http.NewServeMux()
|
||||
// Also register OTLP endpoints on 8080 for backwards compatibility
|
||||
uiMux.HandleFunc("/v1/traces", handleTraces(coll))
|
||||
uiMux.HandleFunc("/v1/metrics", handleMetrics(coll))
|
||||
uiMux.HandleFunc("/v1/logs", handleLogs(coll))
|
||||
|
||||
// WebSocket server for visualization
|
||||
http.HandleFunc("/ws", wsServer.HandleConnections)
|
||||
uiMux.HandleFunc("/api/history", handleHistory(coll))
|
||||
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
|
||||
http.Handle("/", spaHandler(http.Dir("./dist")))
|
||||
|
||||
log.Printf("Starting HTTP server on port 8080")
|
||||
log.Printf("OTLP HTTP endpoints:")
|
||||
log.Printf(" Traces: http://localhost:8080/v1/traces")
|
||||
log.Printf("Starting HTTP server on port 8080 (UI/API)")
|
||||
log.Printf("OTLP HTTP endpoints (also on port 8080):")
|
||||
log.Printf(" Traces: http://localhost:8080/v1/traces")
|
||||
log.Printf(" Metrics: http://localhost:8080/v1/metrics")
|
||||
log.Printf(" Logs: http://localhost:8080/v1/logs")
|
||||
log.Printf("OTLP gRPC endpoints:")
|
||||
log.Printf(" Traces: localhost:4317")
|
||||
log.Printf(" Metrics: localhost:4317")
|
||||
log.Printf(" Logs: localhost:4317")
|
||||
log.Printf(" Logs: http://localhost:8080/v1/logs")
|
||||
log.Printf("OTLP gRPC endpoint:")
|
||||
log.Printf(" Traces/Metrics/Logs: localhost:4317")
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user