Help us shape the future of Go! Take the 2026 Go Developer Survey

traceserve

package
v0.1.62 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package traceserve serves the API of a trace results store: the traces/<kind> result profiles, the sessions API over its captures (their exports and checkpoints) and the profile OpenAPI document, as one handler a host mounts under a path of its own. It serves no UI: a host renders the store with clicky-ui or @flanksource/commons-db-ui, or composes the query app over the handler itself (www.Handler serves the app's pages, and the /traces/{kind} links to them). gavel mounts it over a run's store; `query serve` opens its own store through the same Open.

Index

Constants

View Source
const (
	// Prefix names a store's result profiles, traces/<kind>, and its index
	// connection, connection://traces/traces.
	Prefix = "traces"
	// ProfilePrefix is the name of a kind's result profile less the kind.
	ProfilePrefix = tracing.ProfilePrefix
	// APIPrefix is where Handler serves the profile and sessions APIs, under
	// the path the host mounts it at.
	APIPrefix = "/api/v1"
)

Variables

This section is empty.

Functions

func Handler

func Handler(options Options) (http.Handler, error)

Handler serves options.Runtime's store, rooted at the path the host mounts it at (strip that prefix before it):

GET  /api/openapi.json                       the result profiles and session routes
GET  /api/v1/profile/traces%2F{kind}         a window of a stream (?stream, ?afterSeq, ?toSeq)
GET  /api/v1/traces/{kind}/export            a window downloaded (?stream, ?afterSeq, ?toSeq, ?format)
POST /api/v1/sessions/{id}/checkpoint        a running capture's reading, committed
     /api/v1/sessions...                     the sessions API over the captures

Every other path is 404.

func Open

func Open(options OpenOptions) (*tracing.Runtime, func() error, error)

Open opens the trace results store in options.Dir and returns the runtime that serves it and starts captures into it, with a session registry of its own a host may replace, and the close that stops using the store.

func ReadOnly

func ReadOnly(_ *http.Request, profile string, action sessions.Action) error

ReadOnly is an Authorize that serves a store's captures without letting a caller start, stop, extend or restart one; it may read them and have a running one checkpoint.

func Reopen added in v0.1.62

func Reopen(options ReopenOptions) (http.Handler, func() error, error)

Reopen serves the store a closed host left in options.Dir, read-only (ReadOnly), with the close that stops using it. A store that is gone is os.ErrNotExist; one that is there but does not open is an error.

Types

type OpenOptions

type OpenOptions struct {
	// Dir is the store's directory; Open creates it when it does not exist.
	Dir string
	// Kinds declares the result types the store's streams hold.
	Kinds *tracing.Kinds
	// Retention is how long a stream is kept; an expired one is swept away.
	Retention time.Duration
}

OpenOptions say which store Open opens and what it serves.

type Options

type Options struct {
	// Runtime is the open store served, and the captures running into it.
	Runtime *tracing.Runtime
	// Authorize decides what a caller may do with a capture; ReadOnly serves
	// the store without letting a caller start or stop one. Nil allows all.
	Authorize sessions.AuthorizeFunc
}

Options configure Handler.

type ReopenOptions added in v0.1.62

type ReopenOptions struct {
	// Dir is the directory a closed store was left in, such as a finished
	// run's; Reopen never creates it.
	Dir string
	// Kinds declares the result types the store's streams hold.
	Kinds *tracing.Kinds
}

ReopenOptions say which store Reopen serves.

Jump to

Keyboard shortcuts

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