fix(build): stop ignoring cmd/cyrene sources
The bare 'cyrene' .gitignore pattern matched the cmd/cyrene directory, so trace_adapter.go was never committed and a fresh clone failed to build (undefined: traceAdapter). Scope the pattern to the root binary and add the missing file.
This commit is contained in:
1 parent
cc040b861d
commit
f44bf26050
2 files changed
+52
-1
No files matched your search
+1
-1
@@ -16,7 +16,7 @@ models.json
|
|||||||
*.dylib
|
*.dylib
|
||||||
backend/cmd/*/main
|
backend/cmd/*/main
|
||||||
backend/cmd/*/cyrene
|
backend/cmd/*/cyrene
|
||||||
cyrene
|
/backend/cyrene
|
||||||
|
|
||||||
# Go
|
# Go
|
||||||
backend/vendor/
|
backend/vendor/
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
tracepkg "git.yeij.top/AskaEth/Cyrene_v2/services/ai-core/trace"
|
||||||
|
)
|
||||||
|
|
||||||
|
// traceAdapter adapts trace.Logger to api.TraceLogger.
|
||||||
|
type traceAdapter struct{ *tracepkg.Logger }
|
||||||
|
|
||||||
|
func (a *traceAdapter) Recent(n int) []map[string]any {
|
||||||
|
traces := a.Logger.Recent(n)
|
||||||
|
result := make([]map[string]any, len(traces))
|
||||||
|
for i, t := range traces {
|
||||||
|
spans := make([]map[string]any, len(t.Spans))
|
||||||
|
for j, s := range t.Spans {
|
||||||
|
children := make([]map[string]any, len(s.Children))
|
||||||
|
for k, c := range s.Children {
|
||||||
|
children[k] = spanToMap(c)
|
||||||
|
}
|
||||||
|
spans[j] = spanToMap(s)
|
||||||
|
if len(children) > 0 { spans[j]["children"] = children }
|
||||||
|
}
|
||||||
|
result[i] = map[string]any{
|
||||||
|
"id": t.ID,
|
||||||
|
"user_msg": t.UserMsg,
|
||||||
|
"start_time": t.StartTime.Format(time.RFC3339Nano),
|
||||||
|
"end_time": nil,
|
||||||
|
"status": t.Status,
|
||||||
|
"error": t.Error,
|
||||||
|
"spans": spans,
|
||||||
|
}
|
||||||
|
if !t.EndTime.IsZero() {
|
||||||
|
result[i]["end_time"] = t.EndTime.Format(time.RFC3339Nano)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *traceAdapter) Clear() { a.Logger.Clear() }
|
||||||
|
|
||||||
|
func spanToMap(s tracepkg.Span) map[string]any {
|
||||||
|
m := map[string]any{
|
||||||
|
"name": s.Name, "label": s.Label,
|
||||||
|
"start_ms": s.StartMs, "duration_ms": s.Duration,
|
||||||
|
"status": s.Status, "detail": s.Detail,
|
||||||
|
}
|
||||||
|
if s.Data != nil { m["data"] = s.Data }
|
||||||
|
return m
|
||||||
|
}
|
||||||
Reference in new issue
Block a user