Documentation
¶
Index ¶
- Constants
- Variables
- func AllTools() []tools.ToolDefInterface
- func ToMCPHandler[T any](...) mcp.ToolHandlerFor[map[string]any, T]
- func ToServerHandler[T any](...) api.ToolHandlerFunc
- type Config
- type GetTraceByIDOutput
- type ListInstancesOutput
- type SearchTagValuesOutput
- type SearchTagsOutput
- type SearchTracesOutput
- type ToolHandler
- type ToolParams
- type Toolset
- func (t *Toolset) GetDescription() string
- func (t *Toolset) GetName() string
- func (t *Toolset) GetPrompts() []api.ServerPrompt
- func (t *Toolset) GetResourceTemplates() []api.ServerResourceTemplate
- func (t *Toolset) GetResources() []api.ServerResource
- func (t *Toolset) GetTools(_ api.Openshift) []api.ServerTool
- func (t *Toolset) GetTraceByIDHandler(params ToolParams) (GetTraceByIDOutput, error)
- func (t *Toolset) ListInstancesHandler(params ToolParams) (ListInstancesOutput, error)
- func (t *Toolset) SearchTagValuesHandler(params ToolParams) (SearchTagValuesOutput, error)
- func (t *Toolset) SearchTagsHandler(params ToolParams) (SearchTagsOutput, error)
- func (t *Toolset) SearchTracesHandler(params ToolParams) (SearchTracesOutput, error)
Constants ¶
const ServerPrompt = `` /* 430-byte string literal not displayed */
const ToolsetName = "traces"
Variables ¶
var DefaultConfig = &Config{ UseRoute: false, }
var GetTraceByIDTool = tools.ToolDef[GetTraceByIDOutput]{ Name: "tempo_get_trace_by_id", Description: `Retrieve a single distributed trace by its trace ID from Tempo. Returns the full trace with all its spans, including service names, operation names, durations, and attributes. Use this tool when you already have a specific trace ID, e.g. from search results or logs.`, Title: "Get trace by ID", Params: []tools.ParamDef{ tempoNamespaceParameter, tempoNameParameter, tempoTenantParameter, { Name: "traceid", Type: tools.ParamTypeString, Description: `The trace ID to retrieve, e.g. "26dad4a0e2b0dd9a440dd5ff203a24a4".`, Required: true, }, { Name: "start", Type: tools.ParamTypeString, Description: `Optional start of the time range in RFC 3339 format, e.g. "2025-01-01T00:00:00Z". Narrows the time range to improve query performance.`, }, { Name: "end", Type: tools.ParamTypeString, Description: `Optional end of the time range in RFC 3339 format, e.g. "2025-01-02T00:00:00Z". Narrows the time range to improve query performance.`, }, }, ReadOnly: true, Destructive: false, Idempotent: true, OpenWorld: true, }
var ListInstancesTool = tools.ToolDef[ListInstancesOutput]{ Name: "tempo_list_instances", Description: `List all Tempo instances available in the Kubernetes cluster. Call this tool first to discover available Tempo instances before using other Tempo tools, as the returned namespace, name, and tenant values are required parameters for all other Tempo tools. Always print the output of this tool in a table.`, Title: "List Tempo instances", ReadOnly: true, Destructive: false, Idempotent: true, OpenWorld: true, }
var SearchTagValuesTool = tools.ToolDef[SearchTagValuesOutput]{ Name: "tempo_search_tag_values", Description: `List the known values for a specific tag (attribute key) in Tempo. Use this tool to discover what values exist for a given tag, e.g. to find all service names (values of "resource.service.name") or all HTTP methods (values of "span.http.request.method"). This is useful for building accurate TraceQL queries with tempo_search_traces.`, Title: "Search tag values", Params: []tools.ParamDef{ tempoNamespaceParameter, tempoNameParameter, tempoTenantParameter, { Name: "tag", Type: tools.ParamTypeString, Description: `The fully qualified tag name to get values for, including its scope prefix, e.g. "resource.service.name" or "span.http.response.status_code". Use tempo_search_tags to discover available tag names.`, Required: true, }, { Name: "query", Type: tools.ParamTypeString, Description: `Optional TraceQL query to filter which traces are considered when listing values, e.g. '{ resource.service.name="payment-service" }' to only show tag values from the 'payment-service' service.`, }, { Name: "start", Type: tools.ParamTypeString, Description: `Optional start of the time range (in RFC 3339 format, e.g. "2025-01-01T00:00:00Z") to filter which traces are considered when listing values.`, }, { Name: "end", Type: tools.ParamTypeString, Description: `Optional end of the time range (in RFC 3339 format, e.g. "2025-01-01T00:00:00Z") to filter which traces are considered when listing values.`, }, { Name: "limit", Type: tools.ParamTypeNumber, Description: "Maximum number of tag values to return.", }, { Name: "maxStaleValues", Type: tools.ParamTypeNumber, Description: "Maximum number of consecutive blocks without new values before the search stops early. Higher values are more thorough but slower.", }, }, ReadOnly: true, Destructive: false, Idempotent: true, OpenWorld: true, }
var SearchTagsTool = tools.ToolDef[SearchTagsOutput]{ Name: "tempo_search_tags", Description: `List available tag names (attribute keys) in Tempo, grouped by scope. Use this tool to discover which attributes are available for building TraceQL queries with tempo_search_traces. For example, this tool may reveal tag names like "service.name" (in the "resource" scope) or "http.response.status_code" (in the "span" scope). To use these in TraceQL queries, prefix them with their scope, e.g. "resource.service.name" or "span.http.response.status_code".`, Title: "Search tags", Params: []tools.ParamDef{ tempoNamespaceParameter, tempoNameParameter, tempoTenantParameter, { Name: "scope", Type: tools.ParamTypeString, Description: `Filter tags to a specific scope. One of: "resource" (service-level attributes like service.name), "span" (individual span attributes like http.response.status_code), "intrinsic" (built-in fields like duration, status, name). If omitted, tags from all scopes are returned.`, }, { Name: "query", Type: tools.ParamTypeString, Description: `Optional TraceQL query to filter which traces are considered when listing tags, e.g. '{ resource.service.name="payment-service" }' to only show tags present in traces from the 'payment-service' service.`, }, { Name: "start", Type: tools.ParamTypeString, Description: `Optional start of the time range (in RFC 3339 format, e.g. "2025-01-01T00:00:00Z") to filter which traces are considered when listing tags.`, }, { Name: "end", Type: tools.ParamTypeString, Description: `Optional end of the time range (in RFC 3339 format, e.g. "2025-01-01T00:00:00Z") to filter which traces are considered when listing tags.`, }, { Name: "limit", Type: tools.ParamTypeNumber, Description: "Maximum number of tag names to return per scope.", }, { Name: "maxStaleValues", Type: tools.ParamTypeNumber, Description: "Maximum number of consecutive blocks without new tag names before the search stops early. Higher values are more thorough but slower.", }, }, ReadOnly: true, Destructive: false, Idempotent: true, OpenWorld: true, }
var SearchTracesTool = tools.ToolDef[SearchTracesOutput]{ Name: "tempo_search_traces", Description: `Search for distributed traces in Tempo using TraceQL. Use this tool to find traces matching specific criteria such as service name, HTTP status code, duration, or other span or resource attributes.`, Title: "Search traces", Params: []tools.ParamDef{ tempoNamespaceParameter, tempoNameParameter, tempoTenantParameter, { Name: "query", Type: tools.ParamTypeString, Description: `A TraceQL query expression. Format: query: "{ <filters joined by &&> }" Filters: - service name: resource.service.name="<value>" (string, use quotes) - HTTP status code: span.http.response.status_code=<code> (number, no quotes) - duration: duration><value like 100ms, 2s, 5m> (no quotes) - error status: status=error (keyword, NO quotes — do NOT write status="error") IMPORTANT: status values (error, ok, unset) are keywords, NOT strings. Write status=error, NEVER status="error". Operators: =, !=, >, <, >=, <= Common attributes: - resource.service.name (service name) - span.http.response.status_code (HTTP response code) - span.http.request.method (HTTP method like GET, POST) - span.url.full (request URL) - duration (trace duration, e.g. 100ms, 2s) - status (trace status: ok, error, unset) IMPORTANT: Always wrap filters in curly braces { }. Do NOT use SQL, PromQL, or Lucene syntax. Do NOT omit the "resource." or "span." prefix from attribute names If unsure which attributes to filter on, start with {} to return all traces, then use tempo_search_tags to discover available attributes. `, Required: true, }, { Name: "limit", Type: tools.ParamTypeNumber, Description: "Maximum number of traces to return. Defaults to the server-side limit if not specified.", }, { Name: "start", Type: tools.ParamTypeString, Description: `Start of the time range in RFC 3339 format, e.g. "2025-01-01T00:00:00Z". Use "NOW" for current time. Both start and end should be provided to search the full time range; if omitted, only a small window of recent data is searched.`, }, { Name: "end", Type: tools.ParamTypeString, Description: `End of the time range in RFC 3339 format, e.g. "2025-01-01T00:00:00Z". Use "NOW" for current time. Both start and end should be provided to search the full time range; if omitted, only a small window of recent data is searched.`, }, { Name: "spss", Type: tools.ParamTypeNumber, Description: "Maximum number of matching spans to return per trace.", }, }, ReadOnly: true, Destructive: false, Idempotent: true, OpenWorld: true, }
Functions ¶
func AllTools ¶
func AllTools() []tools.ToolDefInterface
func ToMCPHandler ¶
func ToMCPHandler[T any]( newTempoLoader func(ctx context.Context, url string) (tempoclient.Loader, error), dynamicClient dynamic.Interface, config *Config, handler ToolHandler[T], ) mcp.ToolHandlerFor[map[string]any, T]
func ToServerHandler ¶
func ToServerHandler[T any]( newTempoLoader func(params api.ToolHandlerParams, url string) (tempoclient.Loader, error), handler ToolHandler[T], ) api.ToolHandlerFunc
Types ¶
type Config ¶
type Config struct {
// AuthMode controls where the bearer token is obtained for authenticating against Tempo endpoints.
// Valid values: "header" (default), "kubeconfig".
AuthMode toolsetconfig.AuthMode `toml:"auth_mode,omitempty"`
// Insecure controls whether to skip TLS certificate verification.
Insecure bool `toml:"insecure,omitempty"`
// UseRoute controls whether to use OpenShift Routes for discovering Tempo endpoints.
UseRoute bool `toml:"useRoute,omitempty"`
}
func GetConfig ¶
func GetConfig(params api.ToolHandlerParams) *Config
func (*Config) GetAuthMode ¶
func (c *Config) GetAuthMode() toolsetconfig.AuthMode
type GetTraceByIDOutput ¶
type GetTraceByIDOutput struct {
Trace any `json:"trace" jsonschema:"The trace data with services, scopes and spans"`
}
GetTraceByIDOutput defines the output schema for the tempo_get_trace_by_id tool.
type ListInstancesOutput ¶
type ListInstancesOutput struct {
Instances []discovery.TempoInstance `json:"instances" jsonschema:"List of available Tempo instances"`
}
ListInstancesOutput defines the output schema for the tempo_list_instances tool.
type SearchTagValuesOutput ¶
type SearchTagValuesOutput struct {
TagValues any `json:"tagValues" jsonschema:"Known values for the specified tag, keyed by type"`
}
SearchTagValuesOutput defines the output schema for the tempo_search_tag_values tool.
type SearchTagsOutput ¶
type SearchTagsOutput struct {
Scopes []any `json:"scopes" jsonschema:"List of tag scopes with their tag names"`
}
SearchTagsOutput defines the output schema for the tempo_search_tags tool.
type SearchTracesOutput ¶
type SearchTracesOutput struct {
Traces []any `json:"traces" jsonschema:"List of matching traces with metadata"`
Metrics any `json:"metrics,omitempty" jsonschema:"Query performance metrics"`
}
SearchTracesOutput defines the output schema for the tempo_search_traces tool.
type ToolHandler ¶
type ToolHandler[T any] func(params ToolParams) (T, error)
ToolHandler is the signature shared by all tempo tool handler implementations.
type ToolParams ¶
type ToolParams struct {
// contains filtered or unexported fields
}
ToolParams is a subset of api.ToolHandlerParams and contains only fields required by tempo tool handlers.
type Toolset ¶
type Toolset struct {
NewTempoLoader func(params api.ToolHandlerParams, url string) (tempoclient.Loader, error)
}
Toolset implements the observability toolset for Tempo.
func (*Toolset) GetDescription ¶
GetDescription returns a human-readable description of the toolset.
func (*Toolset) GetPrompts ¶
func (t *Toolset) GetPrompts() []api.ServerPrompt
GetPrompts returns prompts provided by this toolset.
func (*Toolset) GetResourceTemplates ¶
func (t *Toolset) GetResourceTemplates() []api.ServerResourceTemplate
GetResourceTemplates returns resource templates provided by this toolset.
func (*Toolset) GetResources ¶
func (t *Toolset) GetResources() []api.ServerResource
GetResources returns resources provided by this toolset.
func (*Toolset) GetTools ¶
func (t *Toolset) GetTools(_ api.Openshift) []api.ServerTool
GetTools returns all tools provided by this toolset.
func (*Toolset) GetTraceByIDHandler ¶
func (t *Toolset) GetTraceByIDHandler(params ToolParams) (GetTraceByIDOutput, error)
func (*Toolset) ListInstancesHandler ¶
func (t *Toolset) ListInstancesHandler(params ToolParams) (ListInstancesOutput, error)
func (*Toolset) SearchTagValuesHandler ¶
func (t *Toolset) SearchTagValuesHandler(params ToolParams) (SearchTagValuesOutput, error)
func (*Toolset) SearchTagsHandler ¶
func (t *Toolset) SearchTagsHandler(params ToolParams) (SearchTagsOutput, error)
func (*Toolset) SearchTracesHandler ¶
func (t *Toolset) SearchTracesHandler(params ToolParams) (SearchTracesOutput, error)
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Source: https://github.com/jaegertracing/jaeger-operator/blob/88fd9c6ef1d254dbf7946d2cfaf9d42acecdea4c/pkg/util/dns_name.go (ASL 2.0 license) Must follow same algorithm as service name generation in tempo operator: https://github.com/grafana/tempo-operator/blob/9c3430969265e23b2e9fc3103ab608624195e15e/internal/manifests/naming/naming.go#L13 https://github.com/grafana/tempo-operator/blob/9c3430969265e23b2e9fc3103ab608624195e15e/internal/manifests/naming/sanitize.go
|
Source: https://github.com/jaegertracing/jaeger-operator/blob/88fd9c6ef1d254dbf7946d2cfaf9d42acecdea4c/pkg/util/dns_name.go (ASL 2.0 license) Must follow same algorithm as service name generation in tempo operator: https://github.com/grafana/tempo-operator/blob/9c3430969265e23b2e9fc3103ab608624195e15e/internal/manifests/naming/naming.go#L13 https://github.com/grafana/tempo-operator/blob/9c3430969265e23b2e9fc3103ab608624195e15e/internal/manifests/naming/sanitize.go |