The platform for continuously improving AI agents.
syntax = "proto3";
package api.v1;
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
service TraceService {
rpc ListTraces(ListTracesRequest) returns (ListTracesResponse);
rpc GetTrace(GetTraceRequest) returns (GetTraceResponse);
rpc ListServices(ListServicesRequest) returns (ListServicesResponse);
rpc ListModels(ListModelsRequest) returns (ListModelsResponse);
rpc ListMetrics(ListMetricsRequest) returns (ListMetricsResponse);
rpc ListEvents(ListEventsRequest) returns (ListEventsResponse);
rpc ListLogs(ListLogsRequest) returns (ListLogsResponse);
rpc GetTelemetryMetrics(GetTelemetryMetricsRequest) returns (GetTelemetryMetricsResponse);
rpc QueryMetrics(QueryMetricsRequest) returns (QueryMetricsResponse);
}
message Span {
string span_id = 1;
string trace_id = 2;
optional string parent_span_id = 3;
string name = 4;
// OTel SpanKind: 0=UNSPECIFIED 1=INTERNAL 2=SERVER 3=CLIENT 4=PRODUCER 5=CONSUMER
int32 kind = 5;
int64 start_time_ns = 6;
int64 end_time_ns = 7;
int64 duration_ns = 8;
// OTel StatusCode: 0=UNSET 1=OK 2=ERROR
int32 status_code = 9;
string status_message = 10;
string service_name = 11;
google.protobuf.Struct resource_attributes = 12;
string scope_name = 13;
string scope_version = 14;
google.protobuf.Struct attributes = 15;
google.protobuf.ListValue events = 16;
google.protobuf.ListValue links = 17;
google.protobuf.Timestamp received_at = 18;
}
// Unset fields mean no span reported that value.
message Usage {
optional int64 total_tokens = 1;
optional double total_cost = 2;
optional int64 cache_read_tokens = 3;
optional string model = 4;
}
message SpanRow {
Span span = 1;
// Trace-wide totals for a trace head row; the span's own usage with all_spans.
Usage usage = 2;
}
enum OrderField {
ORDER_FIELD_UNSPECIFIED = 0;
ORDER_FIELD_START_TIME = 1;
ORDER_FIELD_DURATION = 2;
ORDER_FIELD_NAME = 3;
ORDER_FIELD_STATUS_CODE = 4;
ORDER_FIELD_SERVICE_NAME = 5;
ORDER_FIELD_TOTAL_TOKENS = 6;
ORDER_FIELD_TOTAL_COST = 7;
ORDER_FIELD_MODEL = 8;
}
message ListTracesRequest {
// Default 50, max 500.
int32 page_size = 1;
string page_token = 2;
// One row per span instead of one head row per trace.
bool all_spans = 3;
string trace_id = 4;
string span_id = 5;
string name_contains = 6;
repeated string service_names = 7;
optional int32 status_code = 8;
optional bool has_error = 9;
optional int64 start_time_ns_gte = 10;
optional int64 start_time_ns_lte = 11;
optional int64 duration_ns_gte = 12;
optional int64 duration_ns_lte = 13;
// A trace matches when any of its spans reported this model.
string model = 14;
optional bool has_model = 15;
optional int64 total_tokens_gte = 16;
optional int64 total_tokens_lte = 17;
optional double total_cost_gte = 18;
optional double total_cost_lte = 19;
// Defaults to start time; descending unless ascending is set.
OrderField order_by = 20;
bool ascending = 21;
}
message ListTracesResponse {
repeated SpanRow rows = 1;
string next_page_token = 2;
int64 total_count = 3;
}
message GetTraceRequest {
string trace_id = 1;
}
message GetTraceResponse {
string trace_id = 1;
Span root = 2;
int32 span_count = 3;
Usage usage = 4;
repeated Span spans = 5;
}
message ListServicesRequest {}
message ListServicesResponse {
repeated string service_names = 1;
}
message ListModelsRequest {}
message ListModelsResponse {
repeated string models = 1;
}
message MetricPoint {
string metric_name = 1;
string description = 2;
string unit = 3;
string metric_type = 4;
optional string temporality = 5;
optional bool is_monotonic = 6;
string service_name = 7;
google.protobuf.Struct resource_attributes = 8;
string scope_name = 9;
string scope_version = 10;
google.protobuf.Struct attributes = 11;
optional int64 start_time_ns = 12;
int64 time_ns = 13;
optional int64 int_value = 14;
optional double double_value = 15;
optional int64 count = 16;
optional double sum = 17;
optional double min = 18;
optional double max = 19;
google.protobuf.Value buckets = 20;
google.protobuf.Timestamp received_at = 21;
optional string trace_id = 22;
optional string span_id = 23;
}
message ListMetricsRequest {
int32 page_size = 1;
string page_token = 2;
string name_contains = 3;
repeated string service_names = 4;
string metric_type = 5;
optional int64 start_time_ns_gte = 6;
optional int64 start_time_ns_lte = 7;
string trace_id = 8;
string span_id = 9;
}
message ListMetricsResponse {
repeated MetricPoint points = 1;
string next_page_token = 2;
int64 total_count = 3;
}
message SpanEvent {
string trace_id = 1;
string span_id = 2;
string span_name = 3;
string service_name = 4;
string name = 5;
int64 time_ns = 6;
google.protobuf.Struct attributes = 7;
google.protobuf.Timestamp received_at = 8;
}
message ListEventsRequest {
int32 page_size = 1;
string page_token = 2;
string trace_id = 3;
string span_id = 4;
string name_contains = 5;
repeated string service_names = 6;
optional int64 start_time_ns_gte = 7;
optional int64 start_time_ns_lte = 8;
}
message ListEventsResponse {
repeated SpanEvent events = 1;
string next_page_token = 2;
int64 total_count = 3;
}
message LogRecord {
int64 time_ns = 1;
int64 observed_time_ns = 2;
optional string trace_id = 3;
optional string span_id = 4;
int32 severity_number = 5;
string severity_text = 6;
google.protobuf.Value body = 7;
string service_name = 8;
google.protobuf.Struct resource_attributes = 9;
string scope_name = 10;
string scope_version = 11;
google.protobuf.Struct attributes = 12;
google.protobuf.Timestamp received_at = 13;
}
message ListLogsRequest {
int32 page_size = 1;
string page_token = 2;
string trace_id = 3;
string span_id = 4;
string body_contains = 5;
repeated string service_names = 6;
optional int32 severity_min = 7;
optional int64 start_time_ns_gte = 8;
optional int64 start_time_ns_lte = 9;
}
message ListLogsResponse {
repeated LogRecord logs = 1;
string next_page_token = 2;
int64 total_count = 3;
}
message GetTelemetryMetricsRequest {
repeated string service_names = 1;
repeated string models = 2;
optional int64 start_time_ns = 3;
optional int64 end_time_ns = 4;
int64 bucket_seconds = 5;
}
message TelemetryBucket {
int64 bucket_start_ns = 1;
int64 span_count = 2;
int64 trace_count = 3;
int64 error_count = 4;
double p50_duration_ms = 5;
double p95_duration_ms = 6;
double p99_duration_ms = 7;
int64 input_tokens = 8;
int64 output_tokens = 9;
optional double cost_usd = 10;
}
message ServiceMetricSummary {
string service_name = 1;
int64 trace_count = 2;
int64 span_count = 3;
int64 error_count = 4;
double error_rate = 5;
double p50_duration_ms = 6;
double p95_duration_ms = 7;
int64 total_tokens = 8;
optional double cost_usd = 9;
}
message ModelMetricSummary {
string model = 1;
int64 call_count = 2;
int64 error_count = 3;
double p50_duration_ms = 4;
double p95_duration_ms = 5;
int64 input_tokens = 6;
int64 output_tokens = 7;
optional double cost_usd = 8;
}
message GetTelemetryMetricsResponse {
int64 total_traces = 1;
int64 total_spans = 2;
int64 error_spans = 3;
double error_rate = 4;
double p50_duration_ms = 5;
double p95_duration_ms = 6;
double p99_duration_ms = 7;
double avg_duration_ms = 8;
int64 total_input_tokens = 9;
int64 total_output_tokens = 10;
int64 total_tokens = 11;
optional double total_cost_usd = 12;
int64 bucket_seconds = 13;
repeated TelemetryBucket buckets = 14;
repeated ServiceMetricSummary by_service = 15;
repeated ModelMetricSummary by_model = 16;
}
message QueryMetricsRequest {
string metric_name = 1;
repeated string service_names = 2;
optional int64 start_time_ns = 3;
optional int64 end_time_ns = 4;
int64 bucket_seconds = 5;
string aggregation = 6;
string group_by = 7;
}
message MetricCatalogEntry {
string name = 1;
string kind = 2;
string unit = 3;
string description = 4;
repeated string services = 5;
int64 point_count = 6;
optional double latest_value = 7;
int64 latest_time_ns = 8;
repeated double sparkline = 9;
repeated string attribute_keys = 10;
}
message MetricSummaryStats {
optional double latest = 1;
optional double avg = 2;
optional double min = 3;
optional double max = 4;
optional double p50 = 5;
optional double p95 = 6;
optional double p99 = 7;
int64 total_points = 8;
}
message MetricSeriesPoint {
int64 bucket_start_ns = 1;
double value = 2;
int64 count = 3;
}
message MetricSeries {
string label = 1;
repeated MetricSeriesPoint points = 2;
}
message HistogramBucketSummary {
optional double upper_bound = 1;
string label = 2;
int64 count = 3;
}
message MetricExemplar {
int64 time_ns = 1;
double value = 2;
string trace_id = 3;
string span_id = 4;
string service_name = 5;
}
message QueryMetricsResponse {
repeated MetricCatalogEntry catalog = 1;
MetricCatalogEntry selected_metric = 2;
MetricSummaryStats summary = 3;
repeated MetricSeries series = 4;
repeated HistogramBucketSummary histogram_buckets = 5;
repeated MetricExemplar exemplars = 6;
int64 bucket_seconds = 7;
}