Files
PRADEEP KUMARandGitHub 776b0bfde2 adds two new tools to aggregate logs and a generic log search (#54)
aggregate log under the hood uses query builder only but now llm passes
multiple input to the tool to filter.

search log is generic log search not tight with error logs or logs for
services.
ideally we can even remove other logs related tools like search log by
service, get error logs but for now keeping.
2026-02-20 16:39:10 +05:30

41 lines
1.1 KiB
Go

package tools
import (
"fmt"
"strings"
)
// parseAggregateTracesArgs validates and parses arguments for the aggregate_traces tool.
func parseAggregateTracesArgs(args map[string]any) (*AggregateRequest, error) {
service, _ := args["service"].(string)
operation, _ := args["operation"].(string)
errorFilter, _ := args["error"].(string)
filter, _ := args["filter"].(string)
filterExpr := buildTraceFilterExpr(filter, service, operation, errorFilter)
return parseAggregateArgs(args, "traces", filterExpr)
}
// buildTraceFilterExpr combines free-form filter with trace-specific shortcut filters.
func buildTraceFilterExpr(query, service, operation, errorFilter string) string {
var parts []string
if query != "" {
parts = append(parts, query)
}
if service != "" {
parts = append(parts, fmt.Sprintf("service.name = '%s'", service))
}
if operation != "" {
parts = append(parts, fmt.Sprintf("name = '%s'", operation))
}
if errorFilter != "" {
switch errorFilter {
case "true":
parts = append(parts, "hasError = true")
case "false":
parts = append(parts, "hasError = false")
}
}
return strings.Join(parts, " AND ")
}