Documentation
¶
Index ¶
- Constants
- Variables
- func RedactLogBodySQL(column string) string
- type DB
- type Dependencies
- type DependencyNode
- type DependencyOptions
- type Edge
- type Health
- type HealthCounts
- type HealthTrend
- type LogEntry
- type Overview
- type Provenance
- type Result
- type Scope
- type Service
- func (s *Service) Dependencies(ctx context.Context, scope Scope, options DependencyOptions) (Result[Dependencies], error)
- func (s *Service) HealthErrorTrend(ctx context.Context, scope Scope) (HealthTrend, error)
- func (s *Service) Overview(ctx context.Context, scope Scope, limit int) (Overview, error)
- func (s *Service) Topology(ctx context.Context, scope Scope, limit int) (Topology, error)
- func (s *Service) Trace(ctx context.Context, scope Scope, traceID, service string, limit int) (Result[TraceDetail], error)
- type ServiceHealth
- type Topology
- type TraceDetail
- type TraceSpan
Constants ¶
const ( // SensitiveURLParamPattern redacts secret-bearing URL query parameter // values (?api_key=..., &token=...). SensitiveURLParamPattern = `(?i)([?&](?:api[_-]?key|access[_-]?token|auth(?:orization)?|client[_-]?secret|password|passwd|secret|token)=)[^&\s'"]+` // SensitiveAuthSchemePattern redacts HTTP auth-scheme credentials // (Bearer eyJ..., Basic dXNlcjpwYXNz). SensitiveAuthSchemePattern = `(?i)(\b(?:bearer|basic)\s+)[A-Za-z0-9._~+/=-]+` // SensitiveKeyValuePattern redacts bare key=value / key: value forms. // The trailing (?:\s+\[REDACTED\])? exists solely to collapse // SensitiveAuthSchemePattern's output ("Authorization: Bearer [REDACTED]" // -> "Authorization: [REDACTED]", see redact_test.go), which only works // because this pattern runs AFTER the auth-scheme pattern in // sensitiveLogPatterns. Reordering the slice silently changes results. SensitiveKeyValuePattern = `` /* 162-byte string literal not displayed */ // SensitiveJSONFieldPattern redacts quoted-key JSON string fields // ({"password":"hunter2"}), the dominant structured-log form and this // project's own logging convention. It replaces the entire quoted value, // so after SensitiveAuthSchemePattern has run, // {"Authorization":"Bearer x"} collapses to // {"Authorization":"[REDACTED]"}. Best-effort limits: only the exact key // names listed match (a compound key like "refresh_token" does NOT, // mirroring the \b behavior of SensitiveKeyValuePattern), only string // values are redacted (numeric/object values pass through), and escaped // quotes inside the value ("pa\"ss") are handled but an escaped quote // inside the KEY defeats the match. SensitiveJSONFieldPattern = `` /* 130-byte string literal not displayed */ )
Log-body redaction is the barrier between log-borne secrets and authenticated viewers who are allowed to inspect telemetry, so treat every change in this file as security-sensitive.
Coverage boundary: redaction is applied ONLY to log body fields on the read path — Logs entries, trace-correlated logs, panel reads (structured and SQL), variable options, empty-panel diagnosis, exemplars, and the SQL-side search filter built from these same patterns (see redactLogBodySQL). Span status_message, span/log attributes, and all on-disk data are NOT redacted.
The patterns are exported string constants (not just compiled regexps) so the identical RE2 source can be embedded in DuckDB regexp_replace() calls: DuckDB uses RE2, the same engine as Go's regexp, which keeps Go-side display redaction and SQL-side search redaction in lockstep (TestRedactSQLMatchesGo asserts the parity). Case-insensitivity comes from the inline (?i) flags, never from engine options.
Variables ¶
var ( ErrInvalidScope = errors.New("invalid observability query scope") ErrInvalidLimit = errors.New("invalid observability query limit") )
Functions ¶
func RedactLogBodySQL ¶
RedactLogBodySQL shares the existing read-path expression with panel projections.
Types ¶
type Dependencies ¶
type Dependencies struct {
Service string `json:"service"`
Direction string `json:"direction"`
Nodes []DependencyNode `json:"nodes"`
MaxDepth int `json:"max_depth"`
MaxNodes int `json:"max_nodes"`
Truncated bool `json:"truncated"`
DepthLimitReached bool `json:"depth_limit_reached"`
NodeLimitReached bool `json:"node_limit_reached"`
}
type DependencyNode ¶
type DependencyOptions ¶
type Health ¶
type Health string
const ( HealthHealthy Health = "healthy" HealthDegraded Health = "degraded" HealthUnhealthy Health = "unhealthy" // HealthUnknown is what a window with no telemetry reports. Silence is not // health: a namespace filter that matches nothing, an agent that stopped // exporting and an interval before onboarding all land here, and calling // any of them "healthy" states the opposite of what is known. HealthUnknown Health = "unknown" )
type HealthCounts ¶
type HealthTrend ¶
type Overview ¶
type Overview struct {
Health Health `json:"health"`
Counts HealthCounts `json:"counts"`
TotalSpans int64 `json:"total_spans"`
ErrorRate float64 `json:"error_rate"`
Services []ServiceHealth `json:"services"`
ServiceCount int `json:"service_count"`
}
type Provenance ¶
type Provenance struct {
Window string `json:"window"`
Generated time.Time `json:"generated_at"`
Complete bool `json:"complete"`
}
Provenance describes the observed window and freshness.
type Result ¶
type Result[T any] struct { Summary string `json:"summary"` Data T `json:"data"` Provenance Provenance `json:"provenance"` }
Result is the canonical query envelope shared by REST and MCP. Summary is deliberately compact model context; Data remains authoritative. UI selection is deliberately absent: MCP Apps link tools to UI resources through standard tool metadata rather than a Pitot-specific view registry.
type Scope ¶
type Scope struct {
Service string `json:"service,omitempty"`
Namespace string `json:"namespace"`
Start time.Time `json:"start"`
End time.Time `json:"end"`
}
Scope is the mandatory boundary for every telemetry query. Namespace is a query filter, not an authorization boundary: every MCP tool input exposes it (Server.scope copies input.Namespace into the Scope) and the HTTP API reads it from a query param, so any caller — including models — may select any namespace. Do not rely on it for access control.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) Dependencies ¶
func (s *Service) Dependencies(ctx context.Context, scope Scope, options DependencyOptions) (Result[Dependencies], error)
func (*Service) HealthErrorTrend ¶
type ServiceHealth ¶
type Topology ¶
type Topology struct {
Nodes []ServiceHealth `json:"nodes"`
Edges []Edge `json:"edges"`
}
type TraceDetail ¶
type TraceDetail struct {
TraceID string `json:"trace_id"`
DurationMS float64 `json:"duration_ms"`
HasError bool `json:"has_error"`
Services []string `json:"services"`
Spans []TraceSpan `json:"spans"`
Logs []LogEntry `json:"logs"`
// SpanCount and ServiceCount describe the trace. Spans and Services
// describe the page the limit admitted, which may be narrower.
SpanCount int `json:"span_count"`
ServiceCount int `json:"service_count"`
Truncated bool `json:"truncated"`
}
type TraceSpan ¶
type TraceSpan struct {
SpanID string `json:"span_id"`
ParentSpanID string `json:"parent_span_id,omitempty"`
Service string `json:"service"`
Operation string `json:"operation"`
Kind string `json:"kind"`
Start time.Time `json:"start"`
DurationMS float64 `json:"duration_ms"`
Status string `json:"status"`
StatusMessage string `json:"status_message,omitempty"`
}