tracequery

package
v0.1.83 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 24 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTraceNotFound = errors.New("trace not found")

Functions

func Handler added in v0.1.83

func Handler(service Service, source string) http.Handler

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.

Types

type AttributeCount

type AttributeCount struct {
	Value string `json:"value"`
	Count int    `json:"count"`
}

AttributeCount is how many traces' root spans carry key=value.

type Detail

type Detail struct {
	Summary        Summary  `json:"summary"`
	Spans          []Span   `json:"spans"`
	MissingParents []string `json:"missingParents"`
}

func Trace

func Trace(spans []Span, id string) (Detail, error)

type DocumentFormat

type DocumentFormat string

func (DocumentFormat) JSONSchema

func (DocumentFormat) JSONSchema() map[string]any

type Mode

type Mode string

Mode includes or excludes a filter value.

const (
	Include Mode = "include"
	Exclude Mode = "exclude"
)

type Modes

type Modes map[string]Mode

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

func (Modes) JSONSchema() map[string]any

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 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"`
}

func ParseRequest added in v0.1.83

func ParseRequest(values url.Values) (Request, error)

ParseRequest reads a Request from query parameters named by its JSON fields, each given once: integers as numbers and Modes as a JSON object.

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"`
}
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.
	Read func(context.Context, Request, []string) ([]Span, error)
}

Service searches the spans of an OpenSearch or opentelemetry connection, or those Read returns.

func (Service) ReadSpans

func (s Service) ReadSpans(ctx context.Context, r Request, ids []string) ([]Span, error)

ReadSpans reads the spans selected by a host without assembling a search.

func (Service) Search

func (s Service) Search(ctx context.Context, r Request) (SearchResult, error)

func (Service) Sources

func (s Service) Sources() ([]Source, error)

func (Service) Trace

func (s Service) Trace(ctx context.Context, r Request, id string) (Detail, error)

type Source

type Source struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Type string `json:"type"`
}

type Span

type Span = span.Span

func FromRow

func FromRow(row query.Row) (Span, error)

FromRow projects a provider row through the shared canonical span boundary.

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"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL