Documentation
¶
Index ¶
- Variables
- func Handler(service Service, source string) http.Handler
- func InWindow(span Span, r Request) bool
- func SummarizeSpans(spans []Span) (map[string]TraceSummary, error)
- type AttributeCount
- type Detail
- type DocumentFormat
- type Mode
- type Modes
- type OperationStats
- type ReadOptions
- type Request
- type RootState
- type SearchResult
- type Service
- type SessionClaim
- type Source
- type Span
- type Summary
- type TraceSummary
- type Truncation
Constants ¶
This section is empty.
Variables ¶
var ErrTraceNotFound = errors.New("trace not found")
Functions ¶
func Handler ¶ added in v0.1.83
Handler serves service's traces of source relative to where it is mounted (behind http.StripPrefix): GET / searches with the query parameters ParseRequest reads, and GET /{traceId} opens one trace. An Accept of application/schema+json returns the Request schema instead.
func InWindow ¶ added in v0.1.101
InWindow reports whether span starts in the request's window and trace.
func SummarizeSpans ¶ added in v0.1.101
func SummarizeSpans(spans []Span) (map[string]TraceSummary, error)
SummarizeSpans is the summary of each trace spans hold, as Search builds it: an identical duplicate span counts once and a conflicting one is an error.
Types ¶
type AttributeCount ¶
AttributeCount is how many traces' root spans carry key=value.
type Detail ¶
type DocumentFormat ¶
type DocumentFormat string
func (DocumentFormat) JSONSchema ¶
func (DocumentFormat) JSONSchema() map[string]any
type Modes ¶
Modes are a filter's values, each included or excluded: a trace passes when it has one of the included values (or none is included) and none of the excluded ones.
func (Modes) JSONSchema ¶
type OperationStats ¶
type OperationStats struct {
Operation string `json:"operation"`
Count int `json:"count"`
// SingleSpan is set when every one of them is a single span.
SingleSpan bool `json:"singleSpan,omitempty"`
P50Ms float64 `json:"p50Ms"`
P95Ms float64 `json:"p95Ms"`
}
OperationStats are the traces of one root operation.
type ReadOptions ¶ added in v0.1.101
ReadOptions selects the spans a host's Read returns.
type Request ¶
type Request struct {
Source string `json:"source" clicky:"title=Source,required"`
Run string `json:"run,omitempty" clicky:"title=Run,desc=Optional recorded run ID"`
Index string `json:"index,omitempty" clicky:"title=Index,desc=OpenSearch index pattern (default otel-traces-*)"`
Format DocumentFormat `json:"format,omitempty" clicky:"title=Document format"`
Services Modes `json:"services,omitempty" clicky:"title=Services,desc=Services a trace's spans run in: each included or excluded"`
Operations Modes `json:"operations,omitempty" clicky:"title=Root operations,desc=A trace's root operation: each included or excluded"`
Statuses Modes `json:"statuses,omitempty" clicky:"title=Statuses,desc=error (a span failed) or ok: each included or excluded"`
Attributes Modes `` /* 156-byte string literal not displayed */
MinSpans int `json:"minSpans,omitempty" clicky:"title=Minimum spans,desc=Traces of at least this many spans"`
TraceID string `json:"traceId,omitempty" clicky:"title=Trace ID"`
Lookback string `json:"lookback,omitempty" clicky:"title=Lookback,desc=Duration such as 15m or 24h; used when From is empty"`
From string `json:"from,omitempty" clicky:"title=From,desc=Inclusive RFC3339 timestamp"`
Until string `json:"until,omitempty" clicky:"title=Until,desc=Exclusive RFC3339 timestamp"`
MinDuration string `json:"minDuration,omitempty" clicky:"title=Minimum trace duration,desc=Duration such as 100ms or 2s"`
MaxDuration string `json:"maxDuration,omitempty" clicky:"title=Maximum trace duration,desc=Duration such as 100ms or 2s"`
Limit int `json:"limit,omitempty" clicky:"title=Trace limit,desc=Maximum traces (1 to 1000); spans of a trace stay together"`
Offset int `json:"offset,omitempty" clicky:"title=Trace offset,desc=Matching traces to skip, newest first, before the limit applies"`
}
type RootState ¶ added in v0.1.101
type RootState struct {
SpanID string `json:"spanId"`
Parentless bool `json:"parentless"`
StartedAt time.Time `json:"startedAt"`
// Session is the root's own gen_ai.conversation.id.
Session string `json:"session,omitempty"`
}
RootState is what choosing a trace's root incrementally needs: the root is the parentless span, else the earliest, and the lowest span ID breaks a tie.
type SearchResult ¶
type SearchResult struct {
Traces []Summary `json:"traces"`
Total int `json:"total"`
// Services are those of every trace in the window.
Services []string `json:"services"`
// RootOperations count the traces in the window that pass every filter
// but the operation and span-count ones, by root operation.
RootOperations []OperationStats `json:"rootOperations"`
// Attributes suggest values of those traces' root spans, most frequent first.
Attributes []AttributeCount `json:"attributes"`
// Truncated is set when the attribute filter stopped at its span limit, so
// older candidate traces were never checked and the result may miss them.
Truncated *Truncation `json:"truncated,omitempty"`
}
func Search ¶
func Search(spans []Span, r Request) (SearchResult, error)
Search filters whole traces with a span in the window: by their duration, services, status, any span's attributes, root operation and span count.
func SearchOpenSearch ¶ added in v0.1.83
func SearchOpenSearch(queryContext dbcontext.Context, r Request, c *models.Connection) (SearchResult, error)
SearchOpenSearch searches the traces with a span in r's window. Every span the window holds settles which traces those are; the filters the span layout matches exactly then narrow them across whole traces, so a filter met outside the window still counts, and only the traces that may pass are read in full. The services facet still covers every trace in the window.
type Service ¶
type Service struct {
Connections *store.Store
// Resolve is the connection a source names and the context it is read in,
// for a host whose connections Connections does not hold.
Resolve func(context.Context, string) (dbcontext.Context, *models.Connection, error)
// Read replaces the connection read with a host's own spans, which a search
// then filters in memory. Exactly one of o.Traces or o.IDs is set per call.
// With o.Traces it returns every span of every trace that has a span
// starting in r's window, across all of the host's stores; completeness
// across stores is the host's job. With o.IDs it returns exactly those
// traces' spans and ignores the window. o.OTLP asks for each span's native
// OTLP request, which only trace detail uses.
Read func(ctx context.Context, r Request, o ReadOptions) ([]Span, error)
// Summaries, when set, makes a search run over one summary per trace instead
// of reading every span: it returns the summary of every trace, whole across
// all of the host's stores, with a span starting in r's window (InWindow's
// meaning, not start/end overlap). Read is then called only with o.IDs, to
// check the any-span attribute filter against the traces that pass the rest.
Summaries func(ctx context.Context, r Request) ([]TraceSummary, error)
}
Service searches the spans of an OpenSearch or opentelemetry connection, or those Read returns.
func (Service) ReadSpans ¶
ReadSpans reads the spans o selects, without assembling a search. Without a host Read, only o.IDs reads are supported.
type SessionClaim ¶ added in v0.1.101
type SessionClaim struct {
ID string `json:"id,omitempty"`
SpanID string `json:"spanId,omitempty"`
StartedAt time.Time `json:"startedAt,omitempty"`
}
SessionClaim is the earliest span naming an AI conversation, which names the trace's session when its root does not.
type Span ¶
func ReadOpenSearch ¶
func ReadOpenSearch(queryContext dbcontext.Context, r Request, c *models.Connection, ids []string) ([]Span, error)
ReadOpenSearch reads the spans of the traces ids, or of r.TraceID, or else every span in r's window.
type Summary ¶
type Summary struct {
TraceID string `json:"traceId"`
Operation string `json:"operation"`
Service string `json:"service"`
StartedAt time.Time `json:"startedAt"`
DurationMs float64 `json:"durationMs"`
SpanCount int `json:"spanCount"`
Errors int `json:"errors"`
Services []string `json:"services"`
// Session is the AI conversation the trace belongs to (gen_ai.conversation.id), so one
// session's agent runs can be grouped; empty for traces outside one.
Session string `json:"session,omitempty"`
// Scope is the root span's instrumentation scope; Tags are its scalar span
// attributes and ProcessTags its scalar resource attributes, as text.
Scope string `json:"scope,omitempty"`
Tags map[string]string `json:"tags,omitempty"`
ProcessTags map[string]string `json:"processTags,omitempty"`
}
type TraceSummary ¶ added in v0.1.101
type TraceSummary struct {
TraceID string `json:"traceId" filter:"exact"`
Operation string `json:"operation"`
Service string `json:"service"`
StartedAt time.Time `json:"startedAt"`
EndedAt time.Time `json:"endedAt"`
SpanCount int `json:"spanCount"`
Errors int `json:"errors"`
Services []string `json:"services"`
Session string `json:"session,omitempty"`
// RootAttributes are the root span's scalar span and resource attributes as text, which the facets count.
RootAttributes map[string]string `json:"rootAttributes,omitempty"`
// RootScope, RootTags and RootProcessTags are the root span's
// instrumentation scope, scalar span attributes and scalar resource
// attributes, as text, which a search lists.
RootScope string `json:"rootScope,omitempty"`
RootTags map[string]string `json:"rootTags,omitempty"`
RootProcessTags map[string]string `json:"rootProcessTags,omitempty"`
Root RootState `json:"root"`
FirstSession SessionClaim `json:"firstSession"`
// contains filtered or unexported fields
}
TraceSummary is everything a search and its facets need from one trace. Merging spans or other summaries of the trace yields the same summary in any order, which lets a store keep it up to date as spans arrive and a host merge the partial summaries of several stores.
func MergeSummaries ¶ added in v0.1.101
func MergeSummaries(a, b TraceSummary) TraceSummary
MergeSummaries combines two summaries of disjoint spans of one trace.
func MergeSummary ¶ added in v0.1.101
func MergeSummary(existing TraceSummary, spans ...Span) TraceSummary
MergeSummary folds spans of one trace into existing. Merging a span twice counts it twice: callers merge each span once, as Search does by grouping deduplicated spans and a writer does by merging only the spans it stores.
func (TraceSummary) Summary ¶ added in v0.1.101
func (t TraceSummary) Summary() Summary
Summary is the summary a search lists.
type Truncation ¶ added in v0.1.101
type Truncation struct {
// SpanLimit is the most spans the filter loads for one search.
SpanLimit int `json:"spanLimit"`
// CheckedTraces of CandidateTraces, newest first, had their spans checked.
CheckedTraces int `json:"checkedTraces"`
CandidateTraces int `json:"candidateTraces"`
}
Truncation is how far the any-span attribute filter got before its span limit.