Skip to main content

Documentation Index

Fetch the complete documentation index at: https://arize-ax.mintlify.dev/docs/llms.txt

Use this file to discover all available pages before exploring further.

The spans client methods are currently in ALPHA. The API may change without notice. A one-time warning is emitted on first use.
Spans are the unit of work captured for an LLM application — each trace is composed of one or more hierarchical spans. The Spans subclient lets you query spans within a project (filtered by time range and an optional filter DSL) and remove spans by ID.

List Spans

List returns a paginated list of spans matching the given filter. Unlike other List methods in this SDK, spans.List takes a body: the spans API uses POST because the filter DSL and projection list can be too large for a query string. Pagination stays in params. Signature:
func (c *Client) List(
    ctx context.Context,
    req ListRequest,
    params ListParams,
) (*SpanList, error)
Usage Example:
package main

import (
    "context"
    "errors"
    "fmt"
    "log"
    "time"

    "github.com/Arize-ai/client-go-v2"
    "github.com/Arize-ai/client-go-v2/spans"
)

func main() {
    client, err := arize.NewClient(arize.Config{APIKey: "your-api-key"})
    if err != nil {
        log.Fatal(err)
    }

    start := time.Now().Add(-24 * time.Hour)
    end := time.Now()
    filter := "status_code = 'ERROR'"

    resp, err := client.Spans.List(
        context.Background(),
        spans.ListRequest{
            ProjectId: "your-project-id",
            StartTime: &start,
            EndTime:   &end,
            Filter:    &filter,
        },
        spans.ListParams{},
    )
    if err != nil {
        var unauthorized *arize.UnauthorizedError
        if errors.As(err, &unauthorized) {
            log.Fatalf("unauthorized: %v", unauthorized)
        }
        log.Fatal(err)
    }

    for _, span := range resp.Spans {
        fmt.Printf("%s (trace=%s kind=%s)\n",
            span.Context.SpanId,
            span.Context.TraceId,
            span.Kind,
        )
    }
}

Delete Spans

Delete removes spans matching the given criteria. A nil *SpanDeletePartial return means all spans were fully deleted (HTTP 204). A non-nil *SpanDeletePartial means the server returned HTTP 200: the request was partially processed and only the IDs listed in SpanDeletePartial.DeletedSpanIds were confirmed deleted — the caller should retry for the remainder. Signature:
func (c *Client) Delete(
    ctx context.Context,
    req DeleteRequest,
) (*SpanDeletePartial, error)
Usage Example:
package main

import (
    "context"
    "errors"
    "fmt"
    "log"

    "github.com/Arize-ai/client-go-v2"
    "github.com/Arize-ai/client-go-v2/spans"
)

func main() {
    client, err := arize.NewClient(arize.Config{APIKey: "your-api-key"})
    if err != nil {
        log.Fatal(err)
    }

    partial, err := client.Spans.Delete(
        context.Background(),
        spans.DeleteRequest{
            ProjectId: "your-project-id",
            SpanIds:   []string{"span-id-1", "span-id-2"},
        },
    )
    if err != nil {
        var notFound *arize.NotFoundError
        if errors.As(err, &notFound) {
            log.Fatalf("project not found: %v", notFound)
        }
        log.Fatal(err)
    }

    if partial == nil {
        fmt.Println("all spans deleted")
        return
    }
    fmt.Printf("partial delete: confirmed %d span IDs — retry remaining\n",
        len(partial.DeletedSpanIds),
    )
}