Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/tool_catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,16 +448,16 @@ pub fn oss_read_tool_specs() -> Vec<ToolSpec> {
ToolSpec::new(
"get_traces",
"Get traces",
"List bounded traces or spans from caller-visible trace datasets.",
"List bounded traces or spans from one caller-visible trace dataset.",
object_schema(
json!({
"datasets": { "type": "array", "minItems": 1, "maxItems": 10, "items": { "type": "string" } },
"dataset": string_property("One trace dataset."),
"serviceName": { "type": "string" },
"startTime": string_property("RFC3339 range start."),
"endTime": string_property("RFC3339 range end."),
"limit": { "type": "integer", "minimum": 1, "maximum": 500, "default": 100 }
}),
&["startTime", "endTime"],
&["dataset", "startTime", "endTime"],
),
),
ToolSpec::new(
Expand All @@ -467,11 +467,11 @@ pub fn oss_read_tool_specs() -> Vec<ToolSpec> {
object_schema(
json!({
"traceId": string_property("Trace ID."),
"datasets": { "type": "array", "minItems": 1, "maxItems": 10, "items": { "type": "string" } },
"dataset": string_property("One trace dataset."),
"startTime": string_property("RFC3339 range start."),
"endTime": string_property("RFC3339 range end.")
}),
&["traceId", "startTime", "endTime"],
&["traceId", "dataset", "startTime", "endTime"],
),
),
ToolSpec::new(
Expand Down
45 changes: 6 additions & 39 deletions src/tool_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@ use serde_json::{Value, json};
use ulid::Ulid;

use crate::{
handlers::{
TelemetryType,
http::{
alerts, cluster, health_check, logstream,
modal::query::querier_logstream,
query, rbac, role, targets,
users::{dashboards, filters},
},
handlers::http::{
alerts, cluster, health_check, logstream,
modal::query::querier_logstream,
query, rbac, role, targets,
users::{dashboards, filters},
},
parseable::PARSEABLE,
prism::logstream::get_prism_logstream_info,
Expand Down Expand Up @@ -558,42 +555,12 @@ async fn execute_alert_target_tool(
}
}

fn trace_datasets(arguments: &Value, context: OssToolContext<'_>) -> Vec<String> {
arguments
.get("datasets")
.and_then(Value::as_array)
.map(|datasets| {
datasets
.iter()
.filter_map(Value::as_str)
.take(10)
.map(str::to_owned)
.collect::<Vec<_>>()
})
.filter(|datasets| !datasets.is_empty())
.unwrap_or_else(|| {
visible_datasets(context.tenant_id, context.session_key)
.into_iter()
.filter(|dataset| {
PARSEABLE
.get_stream(dataset, context.tenant_id)
.is_ok_and(|stream| {
stream.metadata.read().is_ok_and(|metadata| {
metadata.telemetry_type == TelemetryType::Traces
})
})
})
.take(10)
.collect()
})
}

async fn execute_trace_tool(
name: &str,
arguments: &Value,
context: OssToolContext<'_>,
) -> Result<Value, String> {
let datasets = trace_datasets(arguments, context);
let datasets = [required_string(arguments, "dataset")?.to_owned()];
let start_time = required_string(arguments, "startTime")?.to_owned();
let end_time = required_string(arguments, "endTime")?.to_owned();
let limit = bounded_integer(arguments, "limit", 100, 1, 500) as usize;
Expand Down
Loading