func (*JobClient) QuerySpans(
ctx context.Context,
jobID uuid.UUID,
options ...job.TelemetryQueryOption,
) iter.Seq2[*workflows.Span, error]
Query spans emitted while running a job.
The spans are lazily loaded and returned as a sequence of spans. Use Collect to transform the sequence into a slice.
Parameters
The ID of the job to query spans for.
options
[]job.TelemetryQueryOption
Options for querying spans.
Options
job.WithCursor(cursor *job.Cursor)
Start the query after the cursor returned by a previous page.
job.WithLimit(limit int64)
Limit the total number of spans yielded by the sequence.
job.WithSortDirection(direction job.SortDirection)
Sort spans by start time. Use job.Ascending for oldest first or job.Descending for newest first.
Returns
A sequence of spans. Each span includes StartTime, Name, StatusCode, Attributes, and Duration().
import (
"fmt"
"log/slog"
"time"
"github.com/google/uuid"
"github.com/tilebox/tilebox-go/workflows/v1"
"github.com/tilebox/tilebox-go/workflows/v1/job"
)
jobID := uuid.MustParse("019e07b1-916b-0630-f3ba-f1c33235d174")
for span, err := range client.Jobs.QuerySpans(
ctx,
jobID,
job.WithSortDirection(job.Ascending),
) {
if err != nil {
slog.ErrorContext(ctx, "failed to query job spans", slog.Any("error", err))
return
}
fmt.Printf("%s %-40s %s\n",
span.StartTime.Format(time.RFC3339),
span.Name,
span.Duration(),
)
}