Improve agent-facing history endpoints (Phase 1)
- Fix /api/history/{type} to search the full persistent store instead of
only the bounded in-memory ring buffer, so filtered history isn't
silently truncated.
- Add structured type/since/until filters to /api/history/search and
/api/history/wait, alongside the existing free-text query.
- Add GET /api/traces/{traceId} to fetch all entries for a trace in one
call instead of relying on substring search.
- Rate-limit /api/history/wait per client IP.
- Add docs/PLAN.md tracking the phased improvement plan; update README
and agents_example.md for the new/changed endpoints.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0ed1cb4355
commit
f77b89a779
13 files changed
+473
-88
No files matched your search
@@ -5,9 +5,24 @@ import (
|
||||
"git.tornberg.me/go-otel/internal/websocket"
|
||||
)
|
||||
|
||||
// SearchOptions narrows a Search call beyond the free-text query.
|
||||
type SearchOptions struct {
|
||||
// Query is a case-insensitive substring match against the raw entry JSON.
|
||||
Query string
|
||||
// Type restricts results to a single telemetry type (traces, metrics, logs).
|
||||
// Empty matches any type.
|
||||
Type string
|
||||
// Since restricts results to entries with Timestamp >= Since (unix nanoseconds).
|
||||
// Zero means no lower bound.
|
||||
Since int64
|
||||
// Until restricts results to entries with Timestamp <= Until (unix nanoseconds).
|
||||
// Zero means no upper bound.
|
||||
Until int64
|
||||
}
|
||||
|
||||
// Store interface for telemetry history persistence.
|
||||
type Store interface {
|
||||
Append(ctx context.Context, entry websocket.HistoryEntry) error
|
||||
GetHistory(ctx context.Context, limit int) ([]websocket.HistoryEntry, error)
|
||||
Search(ctx context.Context, query string, limit int) ([]websocket.HistoryEntry, error)
|
||||
Search(ctx context.Context, opts SearchOptions, limit int) ([]websocket.HistoryEntry, error)
|
||||
}
|
||||
Reference in new issue
Block a user