Telemetry
c.Telemetry calls the API's Telemetry group. Telemetry through the controller,
such as the spans of a trace.
Methods
| Method | Returns | Permission | Description |
|---|---|---|---|
Get(ctx, id, params) | *Response[TraceResponse] | trace:read | Get the spans of a trace. |
Get
func (s *TelemetryService) Get(
ctx context.Context,
id string,
params TelemetryGetParams,
) (*Response[TraceResponse], error)
Get the spans of a trace.
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.
It sends GET /api/telemetry/trace/{id}, and needs the permission trace:read.
The examples of the method's definition:
Get the spans of a trace, go run telemetry.go get:
resp, err := c.Telemetry.Get(ctx, "26e448c9dbe1c4a8d216a98c675079c9", client.TelemetryGetParams{})
Get the spans of a trace, with --id 26e448c9dbe1c4a8d216a98c675079c9 --all,
go run telemetry.go get-2:
resp, err := c.Telemetry.Get(ctx, "26e448c9dbe1c4a8d216a98c675079c9", client.TelemetryGetParams{All: true})
Types
The fields of each type are the properties of its schema in the API's spec.
SpanStatus
SpanStatus is whether the work of a span failed.
A string, one of ok, error.
TraceNode
| Field | Type | Description |
|---|---|---|
Children | []TraceNode | The spans under this one, in start order. |
ClockSkew | string | How far the span and the spans under it were moved forward, as a Go duration, because the span started before its parent: the clock of its host is behind. Empty when the span was not moved. |
Detail | string | What the span acted on, as key=value pairs, led by error= on a failed span. |
Duration | string | How long the span took, as a Go duration. |
Name | string | The name of the span, such as job.process. |
On | string | What ran the span: the role of its service, such as controller, agent or cli. |
Span | TraceSpan | |
Status | string | The job's status on a job.process, changed or unchanged on a behavior write, and ok or error on other spans. |
TraceResponse
| Field | Type | Description |
|---|---|---|
Duration | string | From the start of the first span to the end of the last, as a Go duration. |
FailedSpans | int | The number of spans that failed. |
NATSCalls | int | The number of NATS calls left out, the bookkeeping of the job queue. all shows them. |
NATSTime | string | The time that the NATS calls left out took, as a Go duration. |
Services | []string | The services that made the spans, in the order each first appears. |
Spans | []TraceNode | The spans that have no parent in the trace, each with its children, in start order. |
Started | time.Time | When the first span started. |
TraceID | string | The trace ID. |
TraceSpan
| Field | Type | Description |
|---|---|---|
Attributes | map[string]string | The attributes of the span, each as text. |
DurationMS | float64 | How long the span took, in milliseconds. |
Kind | string | The span kind, such as server, client, producer or consumer. |
Name | string | The name of the span, such as job.process. |
ParentSpanID | string | The ID of the parent span. Empty for the root. |
Service | string | The service that made the span, such as osapi-agent. |
SpanID | string | The span ID. |
StartTime | time.Time | When the span started. |
Status | SpanStatus | SpanStatus is whether the work of a span failed. |
StatusMessage | string | The error of a failed span. |
Example
examples/sdk/client/telemetry.go
runs each example of this page. With no argument, it lists them.