Documentation
¶
Overview ¶
Package telemetry is the endpoint group for what the controller reads from the telemetry backends, such as the spans of a trace.
Package telemetry is the endpoint group for what the controller reads from the telemetry backends, such as the spans of a trace.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is a trace the backend does not have, or not yet. ErrNotFound = errors.New("trace not found") // ErrNoBackend is a controller with no tracing backend configured. ErrNoBackend = errors.New("no tracing backend is configured") )
var Group = endpoint.Register(endpoint.Define( "telemetry", "Read telemetry through the controller", endpoint.Area(area.Fleet), endpoint.SubDoc("trace", "Read a trace from the tracing backend"), endpoint.Title("Telemetry API"), endpoint.Tag("telemetry", "Telemetry", "Telemetry through the controller, such as the spans of a trace."), endpoint.Uses[Deps](), endpoint.Get[TraceInput, TraceResponse]("get"). Sub("trace"). Handle(Get). ID("GetTrace"). Permission(types.PermTraceRead). Describe("Get the spans of a trace"). Explain("Returns each span of a trace, read from the tracing backend at "+ "telemetry.tracing.url. The backend gets the spans a few seconds after the "+ "request, so a trace of a request that just ran can be not found yet. A token with a "+ "target scope gets a trace only when each target that the trace records is in its scope."). Returns("The spans of the trace."). Command("Show the span tree of a trace", "Shows each span of a trace as a tree: the request on the controller,\n"+ "the job, each agent that ran it with its host and status, and the\n"+ "commands and file changes under each. The NATS calls, which record the\n"+ "job's progress, are left out and counted; --all shows them. Each\n"+ "command prints the ID of its trace after its job ID.\n\n"+ "The controller reads the trace from the tracing backend at\n"+ "`telemetry.tracing.url`, so this host needs no access to the backend.\n"+ "The backend gets the spans a few seconds after the request: a trace\n"+ "that is not found yet is there after a few seconds."). Example("--id 26e448c9dbe1c4a8d216a98c675079c9"). Prints(sampleTrace). Example("--id 26e448c9dbe1c4a8d216a98c675079c9 --all"). Example("--id 26e448c9dbe1c4a8d216a98c675079c9 --json"). Errors( endpoint.NotFound(ErrNotFound, "The backend has no trace with this ID, or not yet, or a target of the trace is "+ "outside the token's target scope."), endpoint.Unavailable(ErrNoBackend, "No tracing backend is configured on the controller."), ), ))
Group is the telemetry group's definition.
Functions ¶
This section is empty.
Types ¶
type Deps ¶
type Deps struct {
// Traces reads traces from the tracing backend. Nil when no backend is
// configured; Get then answers 503.
Traces TraceReader
}
Deps is what the telemetry group's handlers use.
type TraceInput ¶
type TraceInput struct {
ID string `` /* 154-byte string literal not displayed */
All bool `` /* 136-byte string literal not displayed */
}
TraceInput names the trace to read.
type TraceNode ¶
type TraceNode struct {
Name string `` /* 236-byte string literal not displayed */
On string `json:"on" doc:"What ran the span: the role of its service, such as controller, agent or cli."`
Duration string `` /* 254-byte string literal not displayed */
Status string `` /* 252-byte string literal not displayed */
Detail string `json:"detail,omitempty" doc:"What the span acted on, as key=value pairs, led by error= on a failed span."`
ClockSkew string `` /* 264-byte string literal not displayed */
Span TraceSpan `` /* 264-byte string literal not displayed */
Children []TraceNode `json:"children,omitempty" doc:"The spans under this one, in start order."`
}
TraceNode is one span of the tree of a trace: what ran it, its status and what it acted on, then the span itself and its children.
type TraceReader ¶
TraceReader reads one trace from the tracing backend.
type TraceResponse ¶
type TraceResponse struct {
TraceID string `` /* 145-byte string literal not displayed */
Started time.Time `` /* 176-byte string literal not displayed */
Duration string `` /* 180-byte string literal not displayed */
Services []string ` json:"services,omitempty" doc:"The services that made the spans, in the order each first appears."`
FailedSpans int ` json:"failed_spans,omitempty" doc:"The number of spans that failed."`
NATSCalls int `` /* 162-byte string literal not displayed */
NATSTime string `` /* 180-byte string literal not displayed */
Spans []TraceNode `` /* 133-byte string literal not displayed */
// contains filtered or unexported fields
}
TraceResponse is one trace: its summary, then its spans as a tree.
func Get ¶
func Get( ctx context.Context, d Deps, in TraceInput, ) (TraceResponse, error)
Get is the spans of a trace, read from the tracing backend.
type TraceSpan ¶
type TraceSpan struct {
SpanID string `json:"span_id" doc:"The span ID."`
ParentSpanID string `json:"parent_span_id,omitempty" doc:"The ID of the parent span. Empty for the root."`
Name string `json:"name" doc:"The name of the span, such as job.process."`
Service string `json:"service" doc:"The service that made the span, such as osapi-agent."`
Kind string `json:"kind,omitempty" doc:"The span kind, such as server, client, producer or consumer."`
StartTime time.Time `json:"start_time" doc:"When the span started."`
DurationMs float64 `json:"duration_ms" doc:"How long the span took, in milliseconds."`
Status types.SpanStatus `json:"status" doc:"Whether the work of the span failed." validate:"enum"`
StatusMessage string `json:"status_message,omitempty" doc:"The error of a failed span."`
Attributes map[string]string `json:"attributes" doc:"The attributes of the span, each as text."`
}
TraceSpan is one span of a trace.