fixes
This commit is contained in:
1 parent
c8cc0fb28a
commit
e790c02d59
16 files changed
+659
-15
No files matched your search
+36
-5
@@ -8,6 +8,7 @@ import (
|
||||
"net/http"
|
||||
"net/http/pprof"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"git.tornberg.me/go-otel/internal/abuseipdb"
|
||||
@@ -18,6 +19,7 @@ import (
|
||||
"git.tornberg.me/go-otel/internal/geoip"
|
||||
"git.tornberg.me/go-otel/internal/honeypot"
|
||||
"git.tornberg.me/go-otel/internal/investigation"
|
||||
"git.tornberg.me/go-otel/internal/issues"
|
||||
kube "git.tornberg.me/go-otel/internal/kubernetes"
|
||||
"git.tornberg.me/go-otel/internal/prometheus"
|
||||
"git.tornberg.me/go-otel/internal/sourcemaps"
|
||||
@@ -185,6 +187,18 @@ func withCORS(next http.HandlerFunc) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// dataPath resolves a small state file: the env override, else next to the
|
||||
// telemetry log (a mounted volume in the cluster), else the working directory.
|
||||
func dataPath(env, name string) string {
|
||||
if p := os.Getenv(env); p != "" {
|
||||
return p
|
||||
}
|
||||
if lp := os.Getenv("OTELLOG_PATH"); lp != "" {
|
||||
return filepath.Join(filepath.Dir(lp), name)
|
||||
}
|
||||
return name
|
||||
}
|
||||
|
||||
// setupStore returns the telemetry store: ClickHouse when OTEL_CLICKHOUSE_ADDR
|
||||
// is set (host:port, native protocol), otherwise the JSONL file store.
|
||||
func setupStore(ctx context.Context) storage.Store {
|
||||
@@ -295,11 +309,7 @@ func main() {
|
||||
}
|
||||
}
|
||||
if todoStore == nil {
|
||||
path := os.Getenv("OTEL_TODOS_PATH")
|
||||
if path == "" {
|
||||
path = "otel-todos.jsonl"
|
||||
}
|
||||
if st, err := todos.NewFileStore(path); err != nil {
|
||||
if st, err := todos.NewFileStore(dataPath("OTEL_TODOS_PATH", "otel-todos.jsonl")); err != nil {
|
||||
log.Printf("todos disabled: %v", err)
|
||||
} else {
|
||||
todoStore = st
|
||||
@@ -308,6 +318,26 @@ func main() {
|
||||
if todoStore != nil {
|
||||
coll.SetTodoStore(todoStore)
|
||||
}
|
||||
var statusStore issues.StatusStore
|
||||
if chStore, ok := store.(*storage.ClickHouseStore); ok {
|
||||
if st, err := issues.NewClickHouseStatusStore(context.Background(), chStore.Conn(), chStore.Database()); err != nil {
|
||||
log.Printf("issue status: clickhouse unavailable, using file store: %v", err)
|
||||
} else {
|
||||
statusStore = st
|
||||
}
|
||||
}
|
||||
if statusStore == nil {
|
||||
if st, err := issues.NewFileStatusStore(dataPath("OTEL_ISSUE_STATUS_PATH", "otel-issue-status.json")); err != nil {
|
||||
log.Printf("issue status will not be persisted: %v", err)
|
||||
} else {
|
||||
statusStore = st
|
||||
}
|
||||
}
|
||||
if statusStore != nil {
|
||||
if err := coll.SetIssueStatusStore(context.Background(), statusStore); err != nil {
|
||||
log.Printf("failed to load issue status: %v", err)
|
||||
}
|
||||
}
|
||||
investigator := investigation.NewHandler(investigation.ConfigFromEnv(), investigationStore)
|
||||
abuse := abuseipdb.NewHandler(abuseipdb.ConfigFromEnv())
|
||||
|
||||
@@ -409,6 +439,7 @@ func main() {
|
||||
uiMux.Handle("GET /api/issues/{id}/similar", oidcAuth.RequireAuth(http.HandlerFunc(coll.HandleIssueSimilar)))
|
||||
uiMux.Handle("POST /api/issues/{id}/similar", oidcAuth.RequireAuth(http.HandlerFunc(coll.HandleSimilarityFeedback)))
|
||||
uiMux.Handle("GET /api/todos", oidcAuth.RequireAuth(http.HandlerFunc(coll.HandleTodoList)))
|
||||
uiMux.Handle("PATCH /api/todos/{id}", oidcAuth.RequireAuth(http.HandlerFunc(coll.HandleTodoUpdate)))
|
||||
uiMux.Handle("GET /api/patterns", oidcAuth.RequireAuth(http.HandlerFunc(coll.HandlePatterns)))
|
||||
uiMux.Handle("GET /api/topology", oidcAuth.RequireAuth(http.HandlerFunc(topo.HandleTopology)))
|
||||
uiMux.Handle("GET /api/rollouts", oidcAuth.RequireAuth(http.HandlerFunc(coll.HandleRollouts)))
|
||||
|
||||
Reference in new issue
Block a user