materialized view and a bit better ui
This commit is contained in:
1 parent
26b677154b
commit
49f9bb3458
30 files changed
+2184
-106
No files matched your search
@@ -2,6 +2,7 @@ package storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"git.tornberg.me/go-otel/internal/websocket"
|
||||
)
|
||||
|
||||
@@ -38,3 +39,73 @@ type StatsQuerier interface {
|
||||
// Services lists distinct services seen in the rollup.
|
||||
Services(ctx context.Context) ([]string, error)
|
||||
}
|
||||
|
||||
// TraceSummary is the per-trace rollup shown in overview tables: everything
|
||||
// needed to render a row without reading any span payloads. Times are unix
|
||||
// nanoseconds, matching the rest of the API.
|
||||
type TraceSummary struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
StartTime int64 `json:"startTime"`
|
||||
EndTime int64 `json:"endTime"`
|
||||
Duration int64 `json:"duration"`
|
||||
SpanCount int `json:"spanCount"`
|
||||
ErrorCount int `json:"errorCount"`
|
||||
Services []string `json:"services"`
|
||||
}
|
||||
|
||||
// TraceQuerier is implemented by stores that can look a trace up by id
|
||||
// without scanning payloads, and can summarise many traces cheaply
|
||||
// (ClickHouseStore).
|
||||
type TraceQuerier interface {
|
||||
// TraceEntries returns every stored entry that contains the trace, with
|
||||
// each payload trimmed to that trace's spans/log records. Newest first.
|
||||
TraceEntries(ctx context.Context, traceID string, limit int) ([]websocket.HistoryEntry, error)
|
||||
// TraceSummaries returns summaries keyed by trace id; unknown ids are absent.
|
||||
TraceSummaries(ctx context.Context, ids []string) (map[string]TraceSummary, error)
|
||||
}
|
||||
|
||||
// Occurrence is one persisted occurrence of an issue. Sample is the issue
|
||||
// sample as JSON, so its shape can evolve without a schema change.
|
||||
type Occurrence struct {
|
||||
IssueID string
|
||||
Kind string
|
||||
Service string
|
||||
Timestamp int64
|
||||
TraceID string
|
||||
SpanID string
|
||||
Sample json.RawMessage
|
||||
}
|
||||
|
||||
// IssueTrace is one trace an issue occurred in.
|
||||
type IssueTrace struct {
|
||||
TraceID string `json:"traceId"`
|
||||
Hits int `json:"hits"`
|
||||
FirstSeen int64 `json:"firstSeen"`
|
||||
LastSeen int64 `json:"lastSeen"`
|
||||
Summary *TraceSummary `json:"summary,omitempty"`
|
||||
Samples []json.RawMessage `json:"-"`
|
||||
}
|
||||
|
||||
// IssueTracesOptions pages through an issue's traces, most recently hit first.
|
||||
// Before is a LastSeen boundary (exclusive); zero starts from the newest.
|
||||
type IssueTracesOptions struct {
|
||||
Limit int
|
||||
Before int64
|
||||
}
|
||||
|
||||
// IssueTracesPage is one page of an issue's traces plus totals. Untraced holds
|
||||
// occurrences that carried no trace id (only on the first page).
|
||||
type IssueTracesPage struct {
|
||||
Traces []IssueTrace
|
||||
Untraced []json.RawMessage
|
||||
TotalOccurrences int
|
||||
HasMore bool
|
||||
}
|
||||
|
||||
// OccurrenceStore persists every issue occurrence and answers "which traces
|
||||
// did this issue happen in" in one query (ClickHouseStore).
|
||||
type OccurrenceStore interface {
|
||||
AppendOccurrence(ctx context.Context, occ Occurrence) error
|
||||
IssueTraces(ctx context.Context, issueID string, opts IssueTracesOptions) (IssueTracesPage, error)
|
||||
}
|
||||
Reference in new issue
Block a user