Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddTracesOpenAPI ¶ added in v0.1.49
func AddTracesOpenAPI(current func() *tracing.Runtime) profiles.OpenAPIExtension
AddTracesOpenAPI describes the trace routes of the runtime current returns, as it is when the document is built; a server serving no trace kinds yet (current returns nil) describes none.
Types ¶
type Action ¶ added in v0.1.38
type Action string
Action is what a caller does with a session: read it, or control it.
const ( // ActionRead lists a session, or serves its info, events or result. ActionRead Action = "read" // ActionControl starts, stops, extends or restarts a session. ActionControl Action = "control" // ActionCheckpoint has a running trace capture take a reading now and // commit what it emitted, without changing when or whether it ends; a // host serving captures read-only may still allow it. ActionCheckpoint Action = "checkpoint" )
type AuthorizeFunc ¶ added in v0.1.38
AuthorizeFunc decides whether r may perform action on a session of profile. A non-nil error refuses. On a route naming a session id, a caller who may not read the session is answered 404 exactly as for a session that does not exist; a caller who may read it but not control or checkpoint it gets 403 with the error. Where the caller named the profile itself, a refusal is 403 with the error.
type ContextProvider ¶
type EventRecords ¶ added in v0.1.38
type EventRecords interface {
Meta(ctx context.Context, stream string) (recordstore.Meta, error)
Scan(ctx context.Context, stream string, afterSeq int64, fn func(seq int64, row recordstore.Row) error) error
Tail(ctx context.Context, stream string, afterSeq int64, fn func(seq int64, row recordstore.Row) error) error
}
EventRecords reads the record streams a session's status.events names: recordstore.Notifier is one.
type Options ¶
type Options struct {
Profiles ProfileStoreProvider
Context ContextProvider
// Registry holds the live sessions. When it has a Scope, a request lists,
// reads and controls only the live sessions of the scope its context names
// — another scope's is answered 404, as a missing one is — and Store must
// partition its records by the same scope.
Registry *query.SessionRegistry
// Store answers for sessions that are not live in the registry: the list,
// info, lineage, and the records restart and replay start from. Nil lists
// only the registry's sessions.
Store query.SessionStore
// EventLog replays the events of a stream session that recorded no
// status.events, after it left the registry.
EventLog SessionEventLog
// Records replays a session's status.events after its owner process is
// gone, and follows it while this process still writes it.
Records EventRecords
// Authorize decides whether r may read or control a session of the named
// profile. It is asked before a session starts, stops, extends or restarts
// (ActionControl) and before a session's info, events or result is served
// (ActionRead): routes that name no profile, so a gate on profile paths
// alone cannot cover them. A session the caller may not read is answered
// 404, as a missing one is, so its id never confirms it exists; any other
// refusal is answered 403 with its error. The list, its totals, its
// lookups and restartedAs leave out refused profiles. Nil allows
// every caller everything, which is right only when every profile served
// has the same permission. A connection trace session is named by its
// virtual profile, connection-<id>-sql-xevent.
Authorize AuthorizeFunc
// Principal names the caller of r, for a stop reason and the principal of
// a restarted session. Nil stops "via API" and restarts as the previous
// principal.
Principal func(r *http.Request) string
// Traces starts trace plugin captures, each authorized as its profile
// traces/<kind>. Nil serves no trace routes.
Traces *tracing.Runtime
// TraceStartError answers a trace start the runtime refused, when the host
// recognises the refusal and can describe it better than its error text
// (a missing database grant, say), and reports whether it answered. Nil,
// or false, answers the error as text.
TraceStartError func(w http.ResponseWriter, r *http.Request, err error) bool
}
type ProfileStoreProvider ¶
type ProfileStoreProvider func() (profilestore.Store, error)
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
func NewRunner ¶
func NewRunner(options RunnerOptions) (*Runner, error)
type RunnerOptions ¶
type RunnerOptions struct {
Profiles ProfileStoreProvider
Context ContextProvider
Stdout io.Writer
Stderr io.Writer
// BeforeExecute, when set, prepares a CLI session's data as it starts and
// before every later sample — the hook the profile service runs, so a
// session reads what a one-off run of the profile would.
BeforeExecute profilestore.BeforeExecuteFunc
}
type SessionEventLog ¶ added in v0.1.38
type SessionEventLog interface {
Events(ctx context.Context, id string) ([]query.Event, error)
// HasEvents reports whether the log holds any event of session id, which
// is what a session's eventsAvailable says without reading them all.
HasEvents(ctx context.Context, id string) (bool, error)
}
SessionEventLog holds the events a capture stream session emitted through the registry's EventSink, for replay after the session left the registry.