API reference

Traces API Reference


Get traces

Get traces allows you to query traces from the Metoro backend. You can filter traces based on time, service name, attributes, and regexes.

The endpoint will only return 100 traces per request, subsequent requests can be made by passing the prevEndTime field in the request.

POST https://us-east.metoro.io/api/v1/traces

The body of the request should be a GetTracesRequest object.

type GetTracesRequest struct {
    // Service name, acts as a filter to get traces for a specific service
    ServiceNames []string `json:"serviceNames"`
    
    // Start time of when to get the traces in seconds since epoch
    StartTime int64 `json:"startTime"`

    // End time of when to get the traces in seconds since epoch
    EndTime int64 `json:"endTime"`
    
    // The filters to apply to the traces, so for example, if you want to get traces for a specific service
    // you can pass in a filter like {"service_name": ["microservice_a"]}
    Filters map[string][]string `json:"filters"`

    // ExcludeFilters are filters that should be excluded from the traces
    // For example, if you want to get traces for all services except microservice_a you can pass in
    // {"service_name": ["microservice_a"]}
    ExcludeFilters map[string][]string `json:"excludeFilters"`

    // Previous page endTime in nanoseconds, used to get the next page of traces if there are more traces than the page size
    // If omitted, the first page of traces will be returned
    PrevEndTime *int64 `json:"prevEndTime"`

    // RegexFilter is a regex to filter the traces
    RegexFilter *string `json:"regexFilter"`

    // Ascending is a flag to determine if the traces should be returned in ascending order
    Ascending bool `json:"ascending"`
}

The response will be a GetTracesResponse object.

type GetTracesResponse struct {
    // The traces that match the filters
    Traces []Trace `json:"traces"`
}

type Trace struct {
    // The id of the trace
    TraceId string `json:"traceId"`
    
    // The time that the trace was emitted in milliseconds since the epoch
    Time int64 `json:"time"`
    
    // The attributes of the trace
    SpanAttributes map[string]string `json:"spanAttributes"`

    // The attributes of the resource that emitted the trace
    ResourceAttributes map[string]string `json:"resourceAttributes"`

    // Service name
    ServiceName string `json:"serviceName"`

    // Display Service name
    DisplayServiceName string `json:"displayServiceName"`

    // Client name
    ClientName string `json:"clientName"`

    // Display Client name
    DisplayClientName string `json:"displayClientName"`

    // Span Id
    SpanId string `json:"spanId"`
    
    // The duration of the trace
    Duration int64 `json:"duration"`
    
    // The parent span id
    ParentSpanId string `json:"parentSpanId"`
}
Previous
Logs