Documentation
¶
Overview ¶
Code generated by forge. DO NOT EDIT. forge:hash=eb9265343f518c9273f5498fae76fb044b9e11a5393e975fc8ed4a51dba25652 forge-owned: regenerated every run — do not edit (forge project disown to take ownership) Source: contract.go in this package.
To customize: edit contract.go (the interface IS the public surface) and re-run "forge generate". This file is regenerated unconditionally.
Package obsbackend reads telemetry for `forge obs`: the env -> backend resolver, the ClickHouse runner, and the two backends: the local one over the project's ClickStack and the cloud one over the control plane's ObservabilityService. Backend (contract.go) is what the verbs read through.
Index ¶
- Constants
- Variables
- func AggOf(a obsquery.Agg, quantile float64) (string, float64)
- func AsAny(v any) []any
- func AsFloat(v any) float64
- func AsFloats(v any) []float64
- func AsInt(v any) int64
- func AsString(v any) string
- func AsStringMap(v any) map[string]string
- func AsStrings(v any) []string
- func AsTime(v any) time.Time
- func AsUint(v any) uint64
- func Cmd(argv ...string) string
- func LocalScope(n Narrow, env string) obsquery.Scope
- func MapCloudError(err error) error
- func MetricTypeName(t obsquery.MetricType) string
- func ParamArgs(params map[string]string) []string
- func ReservedParamList() string
- func RowsOf(r Result) obsquery.Rows
- func SQLShape(sql string) string
- func SuggestedOf(err error) []string
- func WithTrace(query, traceID string) string
- type AddIssueCommentRequest
- type AddIssueCommentResult
- type Alert
- type AlertReader
- type AssignIssueRequest
- type AssignIssueResult
- type AssignmentChange
- type Backend
- type Caller
- type Change
- type ChangesReader
- type ChangesRequest
- type ChangesResult
- type ChatLink
- type Cloud
- func (c Cloud) AddIssueComment(ctx context.Context, req AddIssueCommentRequest) (AddIssueCommentResult, error)
- func (c Cloud) Alerts(ctx context.Context) ([]Alert, error)
- func (c Cloud) AssignIssue(ctx context.Context, req AssignIssueRequest) (AssignIssueResult, error)
- func (c Cloud) Changes(ctx context.Context, req ChangesRequest) (ChangesResult, error)
- func (c Cloud) Endpoints(ctx context.Context, req EndpointsRequest) (EndpointsResult, error)
- func (c Cloud) GetIssue(ctx context.Context, req GetIssueRequest) (GetIssueResult, error)
- func (c Cloud) GetSession(ctx context.Context, req GetSessionRequest) (GetSessionResult, error)
- func (c Cloud) Info() Info
- func (c Cloud) ListIssueEvents(ctx context.Context, req ListIssueEventsRequest) (ListIssueEventsResult, error)
- func (c Cloud) ListIssueTimeline(ctx context.Context, req ListIssueTimelineRequest) (ListIssueTimelineResult, error)
- func (c Cloud) ListIssues(ctx context.Context, req ListIssuesRequest) (ListIssuesResult, error)
- func (c Cloud) ListSessions(ctx context.Context, req ListSessionsRequest) (ListSessionsResult, error)
- func (c Cloud) Logs(ctx context.Context, req LogsRequest) (LogsResult, error)
- func (c Cloud) MetricsDescribe(ctx context.Context, req MetricsDescribeRequest) (MetricsDescribeResult, error)
- func (c Cloud) MetricsExemplars(ctx context.Context, req MetricsExemplarsRequest) (MetricsExemplarsResult, error)
- func (c Cloud) MetricsList(ctx context.Context, req MetricsListRequest) (MetricsListResult, error)
- func (c Cloud) MetricsQuery(ctx context.Context, req MetricsQueryRequest) (MetricsQueryResult, error)
- func (c Cloud) Overview(ctx context.Context, req OverviewRequest) (OverviewResult, error)
- func (c Cloud) Query(ctx context.Context, req QueryRequest) (QueryResult, error)
- func (c Cloud) ReleaseHealth(ctx context.Context, req HealthRequest) (HealthResult, error)
- func (c Cloud) TelemetryDeliveries(ctx context.Context) (DeliveriesResult, error)
- func (c Cloud) Trace(ctx context.Context, req TraceRequest) (TraceResult, error)
- func (c Cloud) Traces(ctx context.Context, req TracesRequest) (TracesResult, error)
- func (c Cloud) UpdateIssueStatus(ctx context.Context, req UpdateIssueStatusRequest) (UpdateIssueStatusResult, error)
- type Column
- type ComposeFunc
- type Decision
- type DeliveriesResult
- type DeliveryReader
- type Destination
- type DockerRunner
- type Endpoint
- type EndpointsRequest
- type EndpointsResult
- type Error
- type ExecFunc
- type Facts
- type Filter
- type GetIssueRequest
- type GetIssueResult
- type GetSessionRequest
- type GetSessionResult
- type HealthReader
- type HealthRequest
- type HealthResult
- type Info
- type Issue
- type IssueActor
- type IssueComment
- type IssueEvent
- type IssueFrame
- type IssueReader
- type IssueRelease
- type IssueUser
- type IssueVersion
- type LedgerReader
- type Limits
- type ListIssueEventsRequest
- type ListIssueEventsResult
- type ListIssueTimelineRequest
- type ListIssueTimelineResult
- type ListIssuesRequest
- type ListIssuesResult
- type ListSessionsRequest
- type ListSessionsResult
- type Local
- func (l Local) AddIssueComment(context.Context, AddIssueCommentRequest) (AddIssueCommentResult, error)
- func (l Local) AssignIssue(context.Context, AssignIssueRequest) (AssignIssueResult, error)
- func (l Local) Changes(ctx context.Context, req ChangesRequest) (ChangesResult, error)
- func (l Local) Endpoints(ctx context.Context, req EndpointsRequest) (EndpointsResult, error)
- func (l Local) GetIssue(ctx context.Context, req GetIssueRequest) (GetIssueResult, error)
- func (l Local) GetSession(ctx context.Context, req GetSessionRequest) (GetSessionResult, error)
- func (l Local) Info() Info
- func (l Local) ListIssueEvents(ctx context.Context, req ListIssueEventsRequest) (ListIssueEventsResult, error)
- func (l Local) ListIssueTimeline(_ context.Context, req ListIssueTimelineRequest) (ListIssueTimelineResult, error)
- func (l Local) ListIssues(ctx context.Context, req ListIssuesRequest) (ListIssuesResult, error)
- func (l Local) ListSessions(ctx context.Context, req ListSessionsRequest) (ListSessionsResult, error)
- func (l Local) Logs(ctx context.Context, req LogsRequest) (LogsResult, error)
- func (l Local) MetricsDescribe(ctx context.Context, req MetricsDescribeRequest) (MetricsDescribeResult, error)
- func (l Local) MetricsExemplars(ctx context.Context, req MetricsExemplarsRequest) (MetricsExemplarsResult, error)
- func (l Local) MetricsList(ctx context.Context, req MetricsListRequest) (MetricsListResult, error)
- func (l Local) MetricsQuery(ctx context.Context, req MetricsQueryRequest) (MetricsQueryResult, error)
- func (l Local) Overview(ctx context.Context, req OverviewRequest) (OverviewResult, error)
- func (l Local) Query(ctx context.Context, req QueryRequest) (QueryResult, error)
- func (l Local) ReleaseHealth(ctx context.Context, req HealthRequest) (HealthResult, error)
- func (l Local) Trace(ctx context.Context, req TraceRequest) (TraceResult, error)
- func (l Local) Traces(ctx context.Context, req TracesRequest) (TracesResult, error)
- func (l Local) UpdateIssueStatus(context.Context, UpdateIssueStatusRequest) (UpdateIssueStatusResult, error)
- type LogRecord
- type LogsRequest
- type LogsResult
- type MetricAttribute
- type MetricAttributeSpec
- type MetricExemplar
- type MetricInfo
- type MetricMeta
- type MetricPoint
- type MetricSeries
- type MetricsCompare
- type MetricsDescribeRequest
- type MetricsDescribeResult
- type MetricsExemplarsRequest
- type MetricsExemplarsResult
- type MetricsListRequest
- type MetricsListResult
- type MetricsQueryRequest
- type MetricsQueryResult
- type MockAlertReader
- type MockBackend
- func (m *MockBackend) Endpoints(ctx context.Context, req EndpointsRequest) (EndpointsResult, error)
- func (m *MockBackend) Info() Info
- func (m *MockBackend) Logs(ctx context.Context, req LogsRequest) (LogsResult, error)
- func (m *MockBackend) MetricsDescribe(ctx context.Context, req MetricsDescribeRequest) (MetricsDescribeResult, error)
- func (m *MockBackend) MetricsExemplars(ctx context.Context, req MetricsExemplarsRequest) (MetricsExemplarsResult, error)
- func (m *MockBackend) MetricsList(ctx context.Context, req MetricsListRequest) (MetricsListResult, error)
- func (m *MockBackend) MetricsQuery(ctx context.Context, req MetricsQueryRequest) (MetricsQueryResult, error)
- func (m *MockBackend) Query(ctx context.Context, req QueryRequest) (QueryResult, error)
- func (m *MockBackend) Trace(ctx context.Context, req TraceRequest) (TraceResult, error)
- func (m *MockBackend) Traces(ctx context.Context, req TracesRequest) (TracesResult, error)
- type MockChangesReader
- type MockDeliveryReader
- type MockHealthReader
- type MockIssueReader
- func (m *MockIssueReader) AddIssueComment(ctx context.Context, req AddIssueCommentRequest) (AddIssueCommentResult, error)
- func (m *MockIssueReader) AssignIssue(ctx context.Context, req AssignIssueRequest) (AssignIssueResult, error)
- func (m *MockIssueReader) GetIssue(ctx context.Context, req GetIssueRequest) (GetIssueResult, error)
- func (m *MockIssueReader) ListIssueEvents(ctx context.Context, req ListIssueEventsRequest) (ListIssueEventsResult, error)
- func (m *MockIssueReader) ListIssueTimeline(ctx context.Context, req ListIssueTimelineRequest) (ListIssueTimelineResult, error)
- func (m *MockIssueReader) ListIssues(ctx context.Context, req ListIssuesRequest) (ListIssuesResult, error)
- func (m *MockIssueReader) UpdateIssueStatus(ctx context.Context, req UpdateIssueStatusRequest) (UpdateIssueStatusResult, error)
- type MockOverviewReader
- type MockSessionReader
- type Narrow
- type OverviewReader
- type OverviewRequest
- type OverviewResult
- type QueryRequest
- type QueryResult
- type REDSummary
- type Range
- type Result
- type Runner
- type ServiceOverview
- type SessionEntry
- type SessionReader
- type SessionSummary
- type Span
- type SpanEvent
- type Statement
- type StatusChange
- type TelemetryDelivery
- type TimelineEntry
- type TraceRequest
- type TraceResult
- type TraceSummary
- type TracesRequest
- type TracesResult
- type Tree
- type TreeNode
- type UpdateIssueStatusRequest
- type UpdateIssueStatusResult
Constants ¶
const ( ExitWrong = 1 ExitUndetermined = 2 )
The exit statuses forge's agent verbs share (internal/cli/exitcodes.go): 1 means "we looked, and it is wrong"; 2 means "we could not look". A backend error carries one so the CLI reports the same code the document stamps.
const ( ChangePromotion = "promotion" ChangeFailedDeploy = "failed_deploy" ChangeActivity = "activity" ChangeSession = "session" )
Change kinds.
const ( IssueNew = "new" IssueUnresolved = "unresolved" IssueResolved = "resolved" IssueRegressed = "regressed" IssueIgnored = "ignored" )
Issue statuses (DESIGN §5.5). A local issue is always IssueUnresolved.
const ( PlatformServer = "server" PlatformBrowser = "browser" )
Issue platforms.
const ( ResolveNow = "now" ResolveNextRelease = "next" ResolveVersion = "version" )
Resolve-in kinds of a resolve.
const ( TimelineStatus = "status" TimelineComment = "comment" TimelineAssignment = "assignment" TimelineChat = "chat" ActorUser = "user" ActorMachine = "machine" ActorSystem = "system" )
Timeline entry kinds, and the kinds of actor that made one.
const ( DeliveryDelivered = "delivered" DeliveryWithdrawn = "withdrawn" )
Telemetry-token delivery states that leave a working token in place (or need none). The others are the control plane's DeliveryState names, lower case and unprefixed: pending, failing, expired, unbound, disabled.
const ( MaxTreeDepth = 8 MaxTreeSpans = 100 )
Trace-tree caps (DESIGN §8.1, Sentry's overview discipline). --full lifts them.
const ( BackendLocal = "local" BackendCloud = "cloud" )
Backend names, as they appear in every document's scope.
const AggNames = "rate, increase, sum, avg, min, max, last, count, quantile (p50, p95 and p99 are the quantiles 0.5, 0.95 and 0.99)"
AggNames lists the --agg values, for help text.
const AlertFiring = "firing"
AlertFiring is the state of an alert that fired; the other state the control plane reports is "pending".
const SlowWindow = obsquery.MaxTraceLimit
SlowWindow is how many of the newest matching traces a Slow request sorts.
Variables ¶
var IssueStatuses = []string{IssueNew, IssueUnresolved, IssueResolved, IssueRegressed, IssueIgnored}
IssueStatuses are the statuses a request may filter on, in lifecycle order.
Functions ¶
func AggOf ¶
AggOf is the dashspec aggregation an evaluator aggregation resolves to, and its quantile level (0 unless the aggregation is a quantile).
func AsStringMap ¶
AsStringMap reads a Map(String, String) cell.
func AsTime ¶
AsTime reads a DateTime / DateTime64 cell (rendered in UTC: the client runs with session_timezone=UTC).
func Cmd ¶
Cmd joins argv into a runnable command line, single-quoting any word the shell would split. It mirrors obsout.Command; obsbackend stays free of the output layer so the cloud backend can share it.
func LocalScope ¶
LocalScope is the scope of every local query: the project's own ClickStack (`default` database), narrowed to the env by deployment.environment.name. The env is a filter, not an environment restriction: local telemetry carries no reliant.env.id.
func MapCloudError ¶
MapCloudError classifies a control-plane failure (DESIGN §10): exit 1 when the request is wrong (InvalidArgument, NotFound, OutOfRange, Aborted, a refused policy), exit 2 when forge could not look (Unavailable, Unauthenticated, PermissionDenied, ResourceExhausted, FailedPrecondition, DeadlineExceeded, a transport failure). A refused read is "could not look": a gate must never read it as a pass.
func MetricTypeName ¶
func MetricTypeName(t obsquery.MetricType) string
MetricTypeName is "gauge", "sum", "histogram", "exp_histogram" or "summary"; "" for an unknown kind.
func ParamArgs ¶
ParamArgs renders a statement's bound parameters as clickhouse-client flags, sorted so the same statement always has the same argv.
func ReservedParamList ¶
func ReservedParamList() string
ReservedParamList names the scope parameters, for help text.
func RowsOf ¶
RowsOf adapts a decoded runner Result to the cursor pkg/obsquery reads, so the evaluator runs over the local runner exactly as it runs over clickhouse-go on the control plane.
func SQLShape ¶
SQLShape is a statement with every literal removed: strings and numbers become ?, comments and runs of whitespace collapse, keywords lower-case. It is what the raw-SQL usage counter logs (DESIGN §14 D2 condition 2): enough to see WHICH constructs callers reach for that the structured verbs lack, and nothing a caller typed as a value (an id, an email, a trace id).
Identifiers and function names are kept: they are the signal.
func SuggestedOf ¶
SuggestedOf returns the remedy commands of the first *Error in err's chain.
Types ¶
type AddIssueCommentRequest ¶
AddIssueCommentRequest comments on an issue.
type AddIssueCommentResult ¶
type AddIssueCommentResult struct {
Comment IssueComment
}
AddIssueCommentResult is the comment as stored.
type Alert ¶
type Alert struct {
Rule string `json:"rule"`
State string `json:"state"`
Fingerprint string `json:"fingerprint,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// Summary is the rule's summary annotation, when it has one.
Summary string `json:"summary,omitempty"`
// Why is the alert's why-fired payload (alerting.Why), as the control
// plane carries it in the `why` annotation. Nil for an alert whose rule
// attaches none.
Why json.RawMessage `json:"why,omitempty"`
ActiveAt time.Time `json:"active_at,omitzero"`
FiringAt time.Time `json:"firing_at,omitzero"`
Value float64 `json:"value"`
}
Alert is one active instance of an alert rule: firing, or pending (its condition holds but its `for` has not elapsed).
type AlertReader ¶
AlertReader lists the env's active alerts, firing or pending. Only the cloud backend implements it: locally the alert state is the `alerts` workload's own (`forge obs alerts check` evaluates the rules once).
type AssignIssueRequest ¶
AssignIssueRequest assigns an issue. Assignee is a user id or "me" (resolved by the server from the credential's acting user); "" clears it.
type AssignIssueResult ¶
type AssignIssueResult struct {
Issue Issue
}
AssignIssueResult is the issue after the write.
type AssignmentChange ¶
type AssignmentChange struct {
From, To *IssueUser
}
AssignmentChange is an assignment entry; a nil side is "unassigned".
type Backend ¶
type Backend interface {
Info() Info
Logs(ctx context.Context, req LogsRequest) (LogsResult, error)
Traces(ctx context.Context, req TracesRequest) (TracesResult, error)
Trace(ctx context.Context, req TraceRequest) (TraceResult, error)
Endpoints(ctx context.Context, req EndpointsRequest) (EndpointsResult, error)
MetricsList(ctx context.Context, req MetricsListRequest) (MetricsListResult, error)
MetricsQuery(ctx context.Context, req MetricsQueryRequest) (MetricsQueryResult, error)
MetricsDescribe(ctx context.Context, req MetricsDescribeRequest) (MetricsDescribeResult, error)
MetricsExemplars(ctx context.Context, req MetricsExemplarsRequest) (MetricsExemplarsResult, error)
Query(ctx context.Context, req QueryRequest) (QueryResult, error)
}
Backend is what a `forge obs` verb reads telemetry through. The local backend (the project's ClickStack) is the first implementation; the cloud backend (the control plane's ObservabilityService) is the second. Both compile with pkg/obsquery.
type Caller ¶
Caller is what the cloud backend needs from a control-plane client. *cloud.Client satisfies it; tests substitute a fake.
type Change ¶
type Change struct {
Kind string `json:"kind"`
At time.Time `json:"at"`
Summary string `json:"summary"`
Version string `json:"version,omitempty"`
PromotionID string `json:"promotion_id,omitempty"`
Direction string `json:"direction,omitempty"`
Verb string `json:"verb,omitempty"`
Target string `json:"target,omitempty"`
Actor string `json:"actor,omitempty"`
Via string `json:"via,omitempty"`
}
Change is one row of the feed.
type ChangesReader ¶
type ChangesReader interface {
Changes(ctx context.Context, req ChangesRequest) (ChangesResult, error)
}
ChangesReader lists what changed in an env: promotions, failed deploys and activity (`forge obs changes`).
type ChangesRequest ¶
type ChangesRequest struct {
Env string
// Range bounds the rows, newest first.
Range Range
Limit int
// Project is the forge project whose promotions are listed (cloud).
Project string
}
ChangesRequest asks what changed in an env.
type ChangesResult ¶
type ChangesResult struct {
Changes []Change
// Omitted counts rows the Limit cut.
Omitted int
// Current is the promotion in force at the end of the range, whether or
// not it falls inside it; nil when the env has none on record.
Current *Change
// CurrentUnsettled says Current's rollout had not been reported finished:
// a promotion is intent, and the env may still be serving the one before.
CurrentUnsettled bool
Warnings []string
}
ChangesResult is the feed, newest first.
type Cloud ¶
Cloud reads one env's telemetry from the control plane.
func (Cloud) AddIssueComment ¶
func (c Cloud) AddIssueComment(ctx context.Context, req AddIssueCommentRequest) (AddIssueCommentResult, error)
AddIssueComment implements IssueReader over IssuesService.AddIssueComment.
func (Cloud) Alerts ¶
Alerts implements AlertReader over ListAlerts for this env: firing first, then pending, each oldest first (the longest-standing problem leads).
func (Cloud) AssignIssue ¶
func (c Cloud) AssignIssue(ctx context.Context, req AssignIssueRequest) (AssignIssueResult, error)
AssignIssue implements IssueReader over IssuesService.AssignIssue. Like UpdateIssueStatus it reads the issue first and sends the row version it read as expected_version: a write over a state the caller never saw is Aborted, reported as "changed since you read it", and never retried.
func (Cloud) Changes ¶
func (c Cloud) Changes(ctx context.Context, req ChangesRequest) (ChangesResult, error)
Changes implements ChangesReader: the env's promotions and failed deploys (internal/releasetimeline over the control plane's deploy ledger) merged with its activity feed. A source that cannot be read costs its rows, not the feed, and says so in Warnings.
func (Cloud) Endpoints ¶
func (c Cloud) Endpoints(ctx context.Context, req EndpointsRequest) (EndpointsResult, error)
Endpoints implements Backend: the endpoints table panel, run by QueryPanel. The control plane weights spans for tail sampling, so counts are real request counts, not stored spans.
func (Cloud) GetIssue ¶
func (c Cloud) GetIssue(ctx context.Context, req GetIssueRequest) (GetIssueResult, error)
GetIssue implements IssueReader over IssuesService.GetIssue. An issue of another environment than the one named is not served: the id is the control plane's, but the document says which env it is about.
func (Cloud) GetSession ¶
func (c Cloud) GetSession(ctx context.Context, req GetSessionRequest) (GetSessionResult, error)
GetSession implements SessionReader: GetSession, then one page of GetSessionTimeline. A session the scope cannot see is NotFound from both, so the summary answers it and the timeline is not asked for.
func (Cloud) ListIssueEvents ¶
func (c Cloud) ListIssueEvents(ctx context.Context, req ListIssueEventsRequest) (ListIssueEventsResult, error)
ListIssueEvents implements IssueReader. The time range is left to the control plane's default (the issue's first to its last event): an issue's newest events are wanted whatever the verb's --since says.
func (Cloud) ListIssueTimeline ¶
func (c Cloud) ListIssueTimeline(ctx context.Context, req ListIssueTimelineRequest) (ListIssueTimelineResult, error)
ListIssueTimeline implements IssueReader over IssuesService.ListIssueTimeline. The control plane lists oldest first and exposes no way to start from the end, so the newest req.Limit entries are the tail of a walk over every page.
func (Cloud) ListIssues ¶
func (c Cloud) ListIssues(ctx context.Context, req ListIssuesRequest) (ListIssuesResult, error)
ListIssues implements IssueReader over IssuesService.ListIssues.
func (Cloud) ListSessions ¶
func (c Cloud) ListSessions(ctx context.Context, req ListSessionsRequest) (ListSessionsResult, error)
ListSessions implements SessionReader over RumService.ListSessions.
func (Cloud) Logs ¶
func (c Cloud) Logs(ctx context.Context, req LogsRequest) (LogsResult, error)
Logs implements Backend over SearchLogs.
func (Cloud) MetricsDescribe ¶
func (c Cloud) MetricsDescribe(ctx context.Context, req MetricsDescribeRequest) (MetricsDescribeResult, error)
MetricsDescribe implements Backend over GetMetric.
func (Cloud) MetricsExemplars ¶
func (c Cloud) MetricsExemplars(ctx context.Context, req MetricsExemplarsRequest) (MetricsExemplarsResult, error)
MetricsExemplars implements Backend over ListMetricExemplars.
func (Cloud) MetricsList ¶
func (c Cloud) MetricsList(ctx context.Context, req MetricsListRequest) (MetricsListResult, error)
MetricsList implements Backend over ListMetrics.
func (Cloud) MetricsQuery ¶
func (c Cloud) MetricsQuery(ctx context.Context, req MetricsQueryRequest) (MetricsQueryResult, error)
MetricsQuery implements Backend over QueryPanel: the control plane runs the same obsquery.EvalMetricPanel the local backend does, so the same panel over the same data returns the same series.
func (Cloud) Overview ¶
func (c Cloud) Overview(ctx context.Context, req OverviewRequest) (OverviewResult, error)
Overview implements OverviewReader over GetServiceOverview. The control plane compiles the same pkg/obsquery overview the local backend runs.
func (Cloud) Query ¶
func (c Cloud) Query(ctx context.Context, req QueryRequest) (QueryResult, error)
Query implements Backend: a sql panel (raw SQL bound to the scope) or the given panel, run by QueryPanel.
func (Cloud) ReleaseHealth ¶
func (c Cloud) ReleaseHealth(ctx context.Context, req HealthRequest) (HealthResult, error)
ReleaseHealth implements HealthReader: GetReleaseHealth for the env and promotion, mapped onto a releasehealth.Report. The control plane judges with the env's recorded policy; the caller re-judges a different --fail-on with releasehealth.Rejudge.
func (Cloud) TelemetryDeliveries ¶
func (c Cloud) TelemetryDeliveries(ctx context.Context) (DeliveriesResult, error)
TelemetryDeliveries implements DeliveryReader over ListTelemetryDeliveries for this env.
func (Cloud) Trace ¶
func (c Cloud) Trace(ctx context.Context, req TraceRequest) (TraceResult, error)
Trace implements Backend over GetTrace, and SearchLogs for the logs that carry the trace id.
func (Cloud) Traces ¶
func (c Cloud) Traces(ctx context.Context, req TracesRequest) (TracesResult, error)
Traces implements Backend over ListTraces. --slow is the control plane's DURATION_DESC order: the slowest first under span weighting, across every matching trace, not only the newest SlowWindow.
func (Cloud) UpdateIssueStatus ¶
func (c Cloud) UpdateIssueStatus(ctx context.Context, req UpdateIssueStatusRequest) (UpdateIssueStatusResult, error)
UpdateIssueStatus implements IssueReader. It reads the issue first, to learn its environment and row version, and sends the version back as expected_version: a write over a state the caller never saw is refused (Aborted), and the caller is told to re-read.
type ComposeFunc ¶
ComposeFunc is the project's `docker compose` runner (internal/doctor's ComposeRunner, which has this shape).
type Decision ¶
type Decision struct {
Backend string
// Reason is one line a human header can show: "no destination: host
// processes feed the local ClickStack".
Reason string
}
Decision is the backend an env resolves to and why.
type DeliveriesResult ¶
type DeliveriesResult struct {
// Enabled says the control plane's delivery reconciler is on; when it is
// off nothing keeps any token valid.
Enabled bool
Deliveries []TelemetryDelivery
}
DeliveriesResult is the env's telemetry-token deliveries.
type DeliveryReader ¶
type DeliveryReader interface {
TelemetryDeliveries(ctx context.Context) (DeliveriesResult, error)
}
DeliveryReader reads whether the control plane has delivered a working telemetry token into the clusters that ship the env's telemetry. Only the cloud backend implements it: a local stack needs no token.
type Destination ¶
type Destination struct {
Endpoint string
// TokenFromControlPlane marks the destination as the Reliant control
// plane's own telemetry intake.
TokenFromControlPlane bool
}
Destination is Observability.destination.
type DockerRunner ¶
type DockerRunner struct {
Exec ExecFunc
// Env names the env in the remedy commands of a "not running" error.
Env string
}
DockerRunner runs statements through clickhouse-client inside the ClickStack container, with the credentials it already holds. The SQL and every parameter travel as positional arguments of `sh -c`, never interpolated into the script, and every value is bound server-side (--param_pN=).
type Endpoint ¶
type Endpoint struct {
Service string
Name string
Requests float64
Errors float64
ErrorRatio float64
RatePerSecond float64
P50Ms float64
P95Ms float64
P99Ms float64
}
Endpoint is the RED summary of one server span name of one service.
type EndpointsRequest ¶
type EndpointsRequest struct {
Narrow
// Sort is "requests" (default), "p95", "errors" or "rate".
Sort string
Top int
}
EndpointsRequest ranks server spans by name.
type EndpointsResult ¶
type EndpointsResult struct {
Endpoints []Endpoint
// Omitted counts endpoints the Top cap cut.
Omitted int
Statements []Statement
}
EndpointsResult is the ranked endpoints.
type Error ¶
type Error struct {
Code int
Msg string
// Suggested are complete, runnable commands that remedy the failure.
Suggested []string
Err error
}
Error is a backend failure with the process status it produces and the commands that remedy it. It satisfies the ExitCode() int interface forge's error-to-status resolution reads, so a backend never imports the CLI.
func Undetermined ¶
Undetermined is a failure to look: the stack is down, the backend is unreachable.
func Wrong ¶
Wrong is a failure of the request: the statement was refused, the thing asked for does not exist.
type ExecFunc ¶
ExecFunc runs `sh -c script sh args...` inside the ClickHouse container and returns its stdout. The default is docker compose exec; tests substitute docker exec against a container of their own.
func ComposeExec ¶
func ComposeExec(compose ComposeFunc, projectDir string, project func(context.Context) []string) ExecFunc
ComposeExec runs the script in the local ClickStack's compose service. project is the `-p <name>` prefix selecting the compose project `forge env up` started the env's stack in (the bare default project is one it never starts); it is resolved per call, so a stack started after the command began is still found.
type Facts ¶
type Facts struct {
Env string
// Declared is false when the env has no observability block at all;
// Enabled is the block's own switch.
Declared, Enabled bool
// Destination is the env's declared telemetry destination; nil sends
// host processes to the local ClickStack.
Destination *Destination
// HasHosted is true when anything in the env is bound to forge.OnHosted.
HasHosted bool
// HasLocal is true when a workload of the env runs on this machine (host
// process or docker compose): only then can the local ClickStack hold its
// telemetry. An env whose workloads all deploy to a cluster has none.
HasLocal bool
// HasCluster is true when a workload deploys to a declared cluster.
// Without local workloads, its services are reached through ControlPlane,
// not through this machine's ClickStack. It does not imply hosted runtime.
HasCluster bool
// LocalLifecycle is the env's explicit local/ephemeral lifecycle. Local
// host processes may share that scratch env with a developer's cluster.
LocalLifecycle bool
// ControlPlane is the env's control_plane endpoint; "" when it declares none.
ControlPlane string
// ReleaseHealth is the env's recorded release-health policy; nil means
// every default.
ReleaseHealth *release.ShapeReleaseHealth
}
Facts are what an env's resolved KCL says about where its telemetry goes (`forge env shape`): the whole input of Resolve. The CLI extracts them from the rendered entities, so this package never learns the render's types.
type Filter ¶
Filter is a --filter key=value (or key!=value) predicate over the server's attribute allowlist (obsquery.AllowedKeys).
func ParseFilter ¶
ParseFilter reads a --filter value: key=value or key!=value.
type GetIssueRequest ¶
GetIssueRequest reads one issue and what is needed to fix it.
type GetIssueResult ¶
type GetIssueResult struct {
Issue Issue
LatestEvent *IssueEvent
Frames []IssueFrame
ByVersion []IssueVersion
// CoOccurring are the ids of issues that fired in the same traces.
CoOccurring []string
// Incident are the ids of the other issues of this issue's incident (the
// same cause, first fired close in time), when it is part of one.
Incident []string
FirstRelease *IssueRelease
Statements []Statement
}
GetIssueResult is one issue in full.
type GetSessionRequest ¶
type GetSessionRequest struct {
Narrow
ID string
// Limit is the timeline page size; PageToken resumes it.
Limit int
PageToken string
}
GetSessionRequest reads one session and a page of its timeline. A zero Narrow.Range leaves the search window to the backend: the control plane finds the session within 30 days, the local backend looks back 30 days.
type GetSessionResult ¶
type GetSessionResult struct {
Session SessionSummary
Timeline []SessionEntry
NextPageToken string
Statements []Statement
}
GetSessionResult is a session's summary and one page of its timeline, oldest entry first.
type HealthReader ¶
type HealthReader interface {
ReleaseHealth(ctx context.Context, req HealthRequest) (HealthResult, error)
}
HealthReader judges a release: the windows before and after a promotion, per service, and what the release opened (`forge obs check`). The local backend judges from the ClickStack with pkg/releasehealth; the cloud backend asks the control plane's GetReleaseHealth, which applies the same rule.
type HealthRequest ¶
type HealthRequest struct {
// Cloud: the promotion to judge, by id or by release version. Both empty
// means the env's current promotion.
PromotionID string
Release string
// Local: the instant to judge from. There are no promotions locally, so
// the caller names one (`--since`, or the start of the last `forge env up`).
PromotedAt time.Time
// Now is the clock.
Now time.Time
// Options pick the thresholds. Local applies them all; cloud sends the
// window and the named overrides and leaves fail_on to the caller
// (releasehealth.Rejudge).
Options releasehealth.Options
}
HealthRequest asks for a release's health.
type HealthResult ¶
type HealthResult struct {
Report releasehealth.Report
// Statements are what a local judgement ran.
Statements []Statement
}
HealthResult is the judged release.
type Info ¶
type Info struct {
Env string
Backend string
// EnvID is the control plane's id for the env, on the cloud backend.
EnvID string
}
Info says what a backend is bound to.
type Issue ¶
type Issue struct {
// ID is what `forge obs issue <id>` takes: "sfp1-<fingerprint>" locally,
// the control plane's id in the cloud.
ID string
Platform string
// Source is the issue source (obsquery.LogKeyIssueSource) its events
// carry; "" for an error.
Source string
// EnvID is the control plane's id for the issue's environment (cloud only).
EnvID string
Service string
Fingerprint string
Title string
Culprit string
ExceptionType string
Status string
FirstSeen time.Time
LastSeen time.Time
FirstVersion string
LastVersion string
// Events and Affected are over the queried range. Affected counts
// AffectedUnit: users when the issue's events name them, else the chats,
// threads or workflows they ran for, else traces (server) or sessions
// (browser). Never a bare number: an unknown unit is "".
Events int64
Affected int64
AffectedUnit string
ResolvedAt time.Time
ResolvedVersion string
RegressedAt time.Time
IgnoredUntil time.Time
// Version is the row version a triage write must echo; 0 locally.
Version int32
// LatestTraceID is the trace of the newest event, when the list knows it
// (the local grouping does; the control plane answers it in GetIssue).
LatestTraceID string
// Assignee is who the issue is assigned to; nil when unassigned (always
// nil locally).
Assignee *IssueUser
// IncidentKey is shared by the issues of one incident: issues with the
// same cause (obsquery.ServerCause) that first fired within a window of
// one another. Empty for an issue that is not part of one. RelatedCount
// is how many OTHER issues carry the same key. Issues are never merged.
IncidentKey string
RelatedCount int
}
Issue is one group of errors.
type IssueActor ¶
IssueActor is who did something: a person, a machine credential or the system.
type IssueComment ¶
type IssueComment struct {
ID string
IssueID string
Author *IssueUser
Body string
CreatedAt time.Time
UpdatedAt time.Time
}
IssueComment is one comment on an issue. Body is plain text or markdown, verbatim.
type IssueEvent ¶
type IssueEvent struct {
Time time.Time
TraceID string
SpanID string
Version string
Message string
Attributes map[string]string
SessionID string
URLPath string
}
IssueEvent is one occurrence of an issue.
type IssueFrame ¶
IssueFrame is one stack frame, innermost first.
type IssueReader ¶
type IssueReader interface {
ListIssues(ctx context.Context, req ListIssuesRequest) (ListIssuesResult, error)
GetIssue(ctx context.Context, req GetIssueRequest) (GetIssueResult, error)
ListIssueEvents(ctx context.Context, req ListIssueEventsRequest) (ListIssueEventsResult, error)
UpdateIssueStatus(ctx context.Context, req UpdateIssueStatusRequest) (UpdateIssueStatusResult, error)
ListIssueTimeline(ctx context.Context, req ListIssueTimelineRequest) (ListIssueTimelineResult, error)
AddIssueComment(ctx context.Context, req AddIssueCommentRequest) (AddIssueCommentResult, error)
AssignIssue(ctx context.Context, req AssignIssueRequest) (AssignIssueResult, error)
}
IssueReader is what `forge obs issues|issue` read and write through. Both backends implement it. The local one groups ERROR logs at query time and keeps no state, so its UpdateIssueStatus is always a refusal; the cloud one is the control plane's IssuesService.
type IssueRelease ¶
type IssueRelease struct {
Version string
GitCommit string
CommitRange string
PromotedAt time.Time
}
IssueRelease is the release an issue first appeared in.
type IssueVersion ¶
type IssueVersion struct {
Version string
Events int64
Affected int64
AffectedUnit string
FirstSeen time.Time
LastSeen time.Time
}
IssueVersion is the events of an issue in one service version.
type LedgerReader ¶
type LedgerReader interface {
releasetimeline.LedgerReader
SessionsFor(env string) ([]release.LocalSession, error)
}
LedgerReader is the part of the machine ledger the change feed reads: the timeline's readers plus the local stacks (`forge env up` sessions).
type Limits ¶
type Limits struct {
Timeout time.Duration
// MaxRows is the result row cap; 0 = none.
MaxRows int
// Break ends the result at MaxRows (a partial result) instead of failing
// the statement. Raw SQL uses it so a wide SELECT returns its first rows.
Break bool
}
Limits bound one statement. The runner always applies readonly=2.
func DefaultLimits ¶
func DefaultLimits() Limits
DefaultLimits are a structured verb's: a generous row cap that throws, so a statement that returns more than its own LIMIT is a bug and not a silent cut.
type ListIssueEventsRequest ¶
ListIssueEventsRequest lists the newest events of an issue.
type ListIssueEventsResult ¶
type ListIssueEventsResult struct {
Events []IssueEvent
NextPageToken string
Truncated bool
Statements []Statement
}
ListIssueEventsResult is a page of events, newest first.
type ListIssueTimelineRequest ¶
ListIssueTimelineRequest reads the newest Limit entries of an issue's timeline.
type ListIssueTimelineResult ¶
type ListIssueTimelineResult struct {
Entries []TimelineEntry
// IssueID is the issue the timeline is of: the requested one, or the one
// it was merged into.
IssueID string
// Omitted counts older entries the Limit cut.
Omitted int
}
ListIssueTimelineResult is the newest entries, oldest first.
type ListIssuesRequest ¶
type ListIssuesRequest struct {
Narrow
// Statuses filters on these (IssueStatuses); empty is the open ones.
Statuses []string
// Platform is "", PlatformServer or PlatformBrowser.
Platform string
// Source lists the issues of this issue source; "" lists errors.
Source string
// Assignee keeps issues assigned to this user id, or "me" (the verified
// credential's acting user). Empty keeps every issue unless Unassigned.
Assignee string
// Unassigned keeps issues with no assignee; exclusive with Assignee.
Unassigned bool
// SinceRelease keeps issues first seen in this release version.
SinceRelease string
// SincePromotion keeps issues first seen at or after this promotion.
SincePromotion string
Sort string
Limit int
PageToken string
// IncidentWindow is how close in first-seen time issues of one cause must
// be to share an incident; zero is obsquery.DefaultIncidentWindow.
IncidentWindow time.Duration
}
ListIssuesRequest lists the issues of the narrowed scope.
type ListIssuesResult ¶
type ListIssuesResult struct {
Issues []Issue
// NextPageToken resumes the cloud list. A local list has no pages:
// Truncated says the Limit cut it.
NextPageToken string
Truncated bool
Statements []Statement
}
ListIssuesResult is a page of issues.
type ListSessionsRequest ¶
type ListSessionsRequest struct {
Narrow
HasError bool
HasReplay bool
// UserID keeps one user's sessions; PathContains those whose entry path
// contains it, case-insensitively.
UserID string
PathContains string
Limit int
PageToken string
}
ListSessionsRequest lists the sessions that started in the narrowed range, newest first.
type ListSessionsResult ¶
type ListSessionsResult struct {
Sessions []SessionSummary
NextPageToken string
Statements []Statement
}
ListSessionsResult is a page of sessions.
type Local ¶
type Local struct {
Env string
Runner Runner
// Ledger opens this machine's release ledger, for `forge obs changes`.
// Nil when the caller has none; a read that needs it then fails with a
// remedy rather than a panic.
Ledger func() (LedgerReader, error)
// Declared reads the metrics schemas this project declares
// (bin/observability/metrics-schema.json), for `forge obs metrics list`
// and `describe`. Nil when the caller has none.
Declared func() []metrics.Schema
}
Local is the backend over the project's own ClickStack. Every verb compiles with pkg/obsquery against the `default` database (obsquery.LocalDatabase) and runs the statement through Runner.
func (Local) AddIssueComment ¶
func (l Local) AddIssueComment(context.Context, AddIssueCommentRequest) (AddIssueCommentResult, error)
AddIssueComment implements IssueReader: local issues carry no state.
func (Local) AssignIssue ¶
func (l Local) AssignIssue(context.Context, AssignIssueRequest) (AssignIssueResult, error)
AssignIssue implements IssueReader: local issues carry no state.
func (Local) Changes ¶
func (l Local) Changes(ctx context.Context, req ChangesRequest) (ChangesResult, error)
Changes implements ChangesReader over this machine's ledger: the env's promotions and failed applies, and the times its local stack started. There is no activity feed locally.
func (Local) Endpoints ¶
func (l Local) Endpoints(ctx context.Context, req EndpointsRequest) (EndpointsResult, error)
Endpoints implements Backend. The table is the busiest MaxTableRows endpoints; a different sort re-ranks within them.
func (Local) GetIssue ¶
func (l Local) GetIssue(ctx context.Context, req GetIssueRequest) (GetIssueResult, error)
GetIssue implements IssueReader: the issue, its newest event, the frame that logged it, its per-version counts and the issues sharing its traces.
func (Local) GetSession ¶
func (l Local) GetSession(ctx context.Context, req GetSessionRequest) (GetSessionResult, error)
GetSession implements SessionReader: the summary first, which also tells the timeline read which days to look at.
func (Local) ListIssueEvents ¶
func (l Local) ListIssueEvents(ctx context.Context, req ListIssueEventsRequest) (ListIssueEventsResult, error)
ListIssueEvents implements IssueReader.
func (Local) ListIssueTimeline ¶
func (l Local) ListIssueTimeline(_ context.Context, req ListIssueTimelineRequest) (ListIssueTimelineResult, error)
ListIssueTimeline implements IssueReader: a local issue has no discussion.
func (Local) ListIssues ¶
func (l Local) ListIssues(ctx context.Context, req ListIssuesRequest) (ListIssuesResult, error)
ListIssues implements IssueReader.
func (Local) ListSessions ¶
func (l Local) ListSessions(ctx context.Context, req ListSessionsRequest) (ListSessionsResult, error)
ListSessions implements SessionReader.
func (Local) Logs ¶
func (l Local) Logs(ctx context.Context, req LogsRequest) (LogsResult, error)
Logs implements Backend.
func (Local) MetricsDescribe ¶
func (l Local) MetricsDescribe(ctx context.Context, req MetricsDescribeRequest) (MetricsDescribeResult, error)
MetricsDescribe implements Backend: the catalog entry, the export interval, every attribute key with its distinct-value estimate, and the declared spec.
func (Local) MetricsExemplars ¶
func (l Local) MetricsExemplars(ctx context.Context, req MetricsExemplarsRequest) (MetricsExemplarsResult, error)
MetricsExemplars implements Backend: the sampled observations of a metric, the ones whose trace is stored first.
func (Local) MetricsList ¶
func (l Local) MetricsList(ctx context.Context, req MetricsListRequest) (MetricsListResult, error)
MetricsList implements Backend: the catalog over every metric kind, joined with the declared schemas this machine has.
func (Local) MetricsQuery ¶
func (l Local) MetricsQuery(ctx context.Context, req MetricsQueryRequest) (MetricsQueryResult, error)
MetricsQuery implements Backend: the panel through obsquery.EvalMetricPanel, the evaluator the control plane runs, over this backend's runner.
func (Local) Overview ¶
func (l Local) Overview(ctx context.Context, req OverviewRequest) (OverviewResult, error)
Overview implements OverviewReader over the local ClickStack: the overview's RED statement (server spans) and its log statement (error-level records), merged by service. A service that only logged has zero request figures, as on the control plane.
func (Local) Query ¶
func (l Local) Query(ctx context.Context, req QueryRequest) (QueryResult, error)
Query implements Backend.
func (Local) ReleaseHealth ¶
func (l Local) ReleaseHealth(ctx context.Context, req HealthRequest) (HealthResult, error)
ReleaseHealth implements HealthReader.
func (Local) Trace ¶
func (l Local) Trace(ctx context.Context, req TraceRequest) (TraceResult, error)
Trace implements Backend.
func (Local) Traces ¶
func (l Local) Traces(ctx context.Context, req TracesRequest) (TracesResult, error)
Traces implements Backend.
func (Local) UpdateIssueStatus ¶
func (l Local) UpdateIssueStatus(context.Context, UpdateIssueStatusRequest) (UpdateIssueStatusResult, error)
UpdateIssueStatus implements IssueReader: local issues carry no state.
type LogRecord ¶
type LogRecord struct {
Time time.Time
Severity string
SeverityNumber int
Service string
Body string
TraceID string
SpanID string
Attributes map[string]string
// Hash is the keyset hash of the row (follow mode resumes from it).
Hash uint64
}
LogRecord is one log line.
type LogsRequest ¶
type LogsRequest struct {
Narrow
Query string
Severities []string
TraceID string
Oldest bool
Limit int
PageToken string
}
LogsRequest is a log search. Query is the log query language (obsquery.ParseLogQuery); TraceID narrows to one trace.
type LogsResult ¶
LogsResult is a page of logs in the order requested.
type MetricAttribute ¶
type MetricAttribute struct {
Key string
Resource bool
// DistinctEstimate is the estimated number of values over the range.
DistinctEstimate int64
// Enumerated is the declared closed value set; empty when open.
Enumerated []string
// HighCardinality: grouping by the key could exceed the series cap.
HighCardinality bool
}
MetricAttribute is one attribute key of a metric.
type MetricAttributeSpec ¶
MetricAttributeSpec is one attribute a release declares for a metric, with the closed value set when the declaration enumerates one.
type MetricExemplar ¶
type MetricExemplar struct {
Time time.Time
Value float64
TraceID string
SpanID string
Attributes map[string]string
// TraceStored: the trace is in the trace store. false means it was sampled
// out and the trace view would be empty.
TraceStored bool
}
MetricExemplar is one sampled observation of a metric.
type MetricInfo ¶
type MetricInfo struct {
Name string
Unit string
Description string
// Type is "gauge", "sum", "histogram", "exp_histogram" or "summary".
Type string
// Monotonic is a sum that is a counter, not an up-down counter.
Monotonic bool
// Temporality is "delta", "cumulative", or "" (a gauge, or not known).
Temporality string
// Services are up to 10 service.name values that emit it; ServiceCount is
// how many do.
Services []string
ServiceCount int
// LastSeen is the newest data point in the catalog range; zero for a
// declared metric never seen.
LastSeen time.Time
SeriesEstimate int64
// Queryable is false for a kind the evaluator cannot run yet.
Queryable bool
Builtin bool
// Declared: the release's metrics schema lists it. Seen: it has data in
// the range.
Declared, Seen bool
// Stability is "stable", "experimental" or "deprecated"; empty when not
// declared.
Stability string
DeclaredAttributes []MetricAttributeSpec
}
MetricInfo is one catalog entry: a metric as one stored kind (a name stored as several kinds is listed once per kind).
type MetricMeta ¶
type MetricMeta struct {
Label string
Metric string
// Type is "gauge", "sum" or "histogram".
Type string
Monotonic bool
Temporality string
// Agg is the dashspec aggregation after defaulting: rate, increase, sum,
// avg, min, max, last, count or quantile.
Agg string
Quantile float64
ValueUnit string
}
MetricMeta says what one series label measures, after the metric was looked up and the aggregation resolved: everything a reader needs to format and label it.
type MetricPoint ¶
MetricPoint is one bucket of a series. Null is a gap (no value; Value is 0); Partial says the bucket was still filling when it was read.
type MetricSeries ¶
type MetricSeries struct {
Label string
Labels map[string]string
Points []MetricPoint
Reduced *float64
}
MetricSeries is one group of one panel series (Label), or of the panel's "formula" or "ratio". A number, table or bar panel fills Reduced (nil: the reduction is null).
type MetricsCompare ¶
type MetricsCompare struct {
Offset time.Duration
From, To time.Time
Series []MetricSeries
SeriesTotal int
}
MetricsCompare is the panel read over the range shifted back by Offset. Its points are moved forward by Offset so they overlay the current range; From and To are the window actually read.
type MetricsDescribeRequest ¶
MetricsDescribeRequest reads one metric's detail.
type MetricsDescribeResult ¶
type MetricsDescribeResult struct {
Info MetricInfo
// IntervalSeconds estimates the export interval: the floor of a useful
// step. 0 when it cannot be estimated.
IntervalSeconds int64
MixedTemporality bool
Attributes []MetricAttribute
// SuggestedBreakdowns are the attribute keys worth grouping by, best first.
SuggestedBreakdowns []string
Statements []Statement
}
MetricsDescribeResult is the metric detail the explorer's side pane shows.
type MetricsExemplarsRequest ¶
type MetricsExemplarsRequest struct {
Narrow
Name string
From, To time.Time
// Where narrows to series matching the predicates (panel vocabulary).
Where []obsquery.PanelPredicate
// Group narrows to one series group: group-by key to value.
Group map[string]string
MinValue *float64
Limit int
}
MetricsExemplarsRequest reads the exemplars of one metric. Narrow.Range is the scope; From and To (both zero: the scope) are the window the exemplars' own timestamps must fall in.
type MetricsExemplarsResult ¶
type MetricsExemplarsResult struct {
Exemplars []MetricExemplar
Statements []Statement
}
MetricsExemplarsResult is the exemplars, stored traces first.
type MetricsListRequest ¶
MetricsListRequest lists the metric names in range.
type MetricsListResult ¶
type MetricsListResult struct {
Metrics []MetricInfo
Truncated bool
Statements []Statement
}
MetricsListResult is the metrics in range.
type MetricsQueryRequest ¶
type MetricsQueryRequest struct {
Narrow
Panel obsquery.Panel
StepSeconds int64
// MaxSeries lowers the series cap (the most groups per series label).
MaxSeries int
// Compare, when positive, runs the panel a second time over the range
// shifted back by this much; Result.Compare carries it.
Compare time.Duration
}
MetricsQueryRequest runs one metrics panel: the explorer's query. The panel is the dashspec vocabulary (series A, B, ... each naming a metric, an aggregation and its own where; a formula; panel-level where and group-by).
type MetricsQueryResult ¶
type MetricsQueryResult struct {
Meta []MetricMeta
Series []MetricSeries
// SeriesTotal is how many groups matched before the series cap.
SeriesTotal int
Truncated bool
StepSeconds int64
// Warnings are stable codes: mixed_bounds, mixed_temporality,
// step_raised, metric_stored_as_n_kinds, metric_absent,
// metric_kind_mismatch.
Warnings []string
Compare *MetricsCompare
Statements []Statement
}
MetricsQueryResult is what a metrics panel evaluates to.
type MockAlertReader ¶
type MockAlertReader struct {
contractkit.Recorder
AlertsFunc func(context.Context) ([]Alert, error)
}
MockAlertReader is a test mock for the AlertReader interface.
The embedded contractkit.Recorder records every call so tests can assert call counts and captured arguments. Set XxxFunc fields to override per-method behaviour; unset methods return the canonical "MockAlertReader.<Method>Func not set" error.
type MockBackend ¶
type MockBackend struct {
contractkit.Recorder
InfoFunc func() Info
LogsFunc func(context.Context, LogsRequest) (LogsResult, error)
TracesFunc func(context.Context, TracesRequest) (TracesResult, error)
TraceFunc func(context.Context, TraceRequest) (TraceResult, error)
EndpointsFunc func(context.Context, EndpointsRequest) (EndpointsResult, error)
MetricsListFunc func(context.Context, MetricsListRequest) (MetricsListResult, error)
MetricsQueryFunc func(context.Context, MetricsQueryRequest) (MetricsQueryResult, error)
MetricsDescribeFunc func(context.Context, MetricsDescribeRequest) (MetricsDescribeResult, error)
MetricsExemplarsFunc func(context.Context, MetricsExemplarsRequest) (MetricsExemplarsResult, error)
QueryFunc func(context.Context, QueryRequest) (QueryResult, error)
}
MockBackend is a test mock for the Backend interface.
The embedded contractkit.Recorder records every call so tests can assert call counts and captured arguments. Set XxxFunc fields to override per-method behaviour; unset methods return the canonical "MockBackend.<Method>Func not set" error.
func (*MockBackend) Endpoints ¶
func (m *MockBackend) Endpoints(ctx context.Context, req EndpointsRequest) (EndpointsResult, error)
Endpoints records the call and delegates to EndpointsFunc when set.
func (*MockBackend) Info ¶
func (m *MockBackend) Info() Info
Info records the call and delegates to InfoFunc when set.
func (*MockBackend) Logs ¶
func (m *MockBackend) Logs(ctx context.Context, req LogsRequest) (LogsResult, error)
Logs records the call and delegates to LogsFunc when set.
func (*MockBackend) MetricsDescribe ¶
func (m *MockBackend) MetricsDescribe(ctx context.Context, req MetricsDescribeRequest) (MetricsDescribeResult, error)
MetricsDescribe records the call and delegates to MetricsDescribeFunc when set.
func (*MockBackend) MetricsExemplars ¶
func (m *MockBackend) MetricsExemplars(ctx context.Context, req MetricsExemplarsRequest) (MetricsExemplarsResult, error)
MetricsExemplars records the call and delegates to MetricsExemplarsFunc when set.
func (*MockBackend) MetricsList ¶
func (m *MockBackend) MetricsList(ctx context.Context, req MetricsListRequest) (MetricsListResult, error)
MetricsList records the call and delegates to MetricsListFunc when set.
func (*MockBackend) MetricsQuery ¶
func (m *MockBackend) MetricsQuery(ctx context.Context, req MetricsQueryRequest) (MetricsQueryResult, error)
MetricsQuery records the call and delegates to MetricsQueryFunc when set.
func (*MockBackend) Query ¶
func (m *MockBackend) Query(ctx context.Context, req QueryRequest) (QueryResult, error)
Query records the call and delegates to QueryFunc when set.
func (*MockBackend) Trace ¶
func (m *MockBackend) Trace(ctx context.Context, req TraceRequest) (TraceResult, error)
Trace records the call and delegates to TraceFunc when set.
func (*MockBackend) Traces ¶
func (m *MockBackend) Traces(ctx context.Context, req TracesRequest) (TracesResult, error)
Traces records the call and delegates to TracesFunc when set.
type MockChangesReader ¶
type MockChangesReader struct {
contractkit.Recorder
ChangesFunc func(context.Context, ChangesRequest) (ChangesResult, error)
}
MockChangesReader is a test mock for the ChangesReader interface.
The embedded contractkit.Recorder records every call so tests can assert call counts and captured arguments. Set XxxFunc fields to override per-method behaviour; unset methods return the canonical "MockChangesReader.<Method>Func not set" error.
func (*MockChangesReader) Changes ¶
func (m *MockChangesReader) Changes(ctx context.Context, req ChangesRequest) (ChangesResult, error)
Changes records the call and delegates to ChangesFunc when set.
type MockDeliveryReader ¶
type MockDeliveryReader struct {
contractkit.Recorder
TelemetryDeliveriesFunc func(context.Context) (DeliveriesResult, error)
}
MockDeliveryReader is a test mock for the DeliveryReader interface.
The embedded contractkit.Recorder records every call so tests can assert call counts and captured arguments. Set XxxFunc fields to override per-method behaviour; unset methods return the canonical "MockDeliveryReader.<Method>Func not set" error.
func (*MockDeliveryReader) TelemetryDeliveries ¶
func (m *MockDeliveryReader) TelemetryDeliveries(ctx context.Context) (DeliveriesResult, error)
TelemetryDeliveries records the call and delegates to TelemetryDeliveriesFunc when set.
type MockHealthReader ¶
type MockHealthReader struct {
contractkit.Recorder
ReleaseHealthFunc func(context.Context, HealthRequest) (HealthResult, error)
}
MockHealthReader is a test mock for the HealthReader interface.
The embedded contractkit.Recorder records every call so tests can assert call counts and captured arguments. Set XxxFunc fields to override per-method behaviour; unset methods return the canonical "MockHealthReader.<Method>Func not set" error.
func (*MockHealthReader) ReleaseHealth ¶
func (m *MockHealthReader) ReleaseHealth(ctx context.Context, req HealthRequest) (HealthResult, error)
ReleaseHealth records the call and delegates to ReleaseHealthFunc when set.
type MockIssueReader ¶
type MockIssueReader struct {
contractkit.Recorder
ListIssuesFunc func(context.Context, ListIssuesRequest) (ListIssuesResult, error)
GetIssueFunc func(context.Context, GetIssueRequest) (GetIssueResult, error)
ListIssueEventsFunc func(context.Context, ListIssueEventsRequest) (ListIssueEventsResult, error)
UpdateIssueStatusFunc func(context.Context, UpdateIssueStatusRequest) (UpdateIssueStatusResult, error)
ListIssueTimelineFunc func(context.Context, ListIssueTimelineRequest) (ListIssueTimelineResult, error)
AddIssueCommentFunc func(context.Context, AddIssueCommentRequest) (AddIssueCommentResult, error)
AssignIssueFunc func(context.Context, AssignIssueRequest) (AssignIssueResult, error)
}
MockIssueReader is a test mock for the IssueReader interface.
The embedded contractkit.Recorder records every call so tests can assert call counts and captured arguments. Set XxxFunc fields to override per-method behaviour; unset methods return the canonical "MockIssueReader.<Method>Func not set" error.
func (*MockIssueReader) AddIssueComment ¶
func (m *MockIssueReader) AddIssueComment(ctx context.Context, req AddIssueCommentRequest) (AddIssueCommentResult, error)
AddIssueComment records the call and delegates to AddIssueCommentFunc when set.
func (*MockIssueReader) AssignIssue ¶
func (m *MockIssueReader) AssignIssue(ctx context.Context, req AssignIssueRequest) (AssignIssueResult, error)
AssignIssue records the call and delegates to AssignIssueFunc when set.
func (*MockIssueReader) GetIssue ¶
func (m *MockIssueReader) GetIssue(ctx context.Context, req GetIssueRequest) (GetIssueResult, error)
GetIssue records the call and delegates to GetIssueFunc when set.
func (*MockIssueReader) ListIssueEvents ¶
func (m *MockIssueReader) ListIssueEvents(ctx context.Context, req ListIssueEventsRequest) (ListIssueEventsResult, error)
ListIssueEvents records the call and delegates to ListIssueEventsFunc when set.
func (*MockIssueReader) ListIssueTimeline ¶
func (m *MockIssueReader) ListIssueTimeline(ctx context.Context, req ListIssueTimelineRequest) (ListIssueTimelineResult, error)
ListIssueTimeline records the call and delegates to ListIssueTimelineFunc when set.
func (*MockIssueReader) ListIssues ¶
func (m *MockIssueReader) ListIssues(ctx context.Context, req ListIssuesRequest) (ListIssuesResult, error)
ListIssues records the call and delegates to ListIssuesFunc when set.
func (*MockIssueReader) UpdateIssueStatus ¶
func (m *MockIssueReader) UpdateIssueStatus(ctx context.Context, req UpdateIssueStatusRequest) (UpdateIssueStatusResult, error)
UpdateIssueStatus records the call and delegates to UpdateIssueStatusFunc when set.
type MockOverviewReader ¶
type MockOverviewReader struct {
contractkit.Recorder
OverviewFunc func(context.Context, OverviewRequest) (OverviewResult, error)
}
MockOverviewReader is a test mock for the OverviewReader interface.
The embedded contractkit.Recorder records every call so tests can assert call counts and captured arguments. Set XxxFunc fields to override per-method behaviour; unset methods return the canonical "MockOverviewReader.<Method>Func not set" error.
func (*MockOverviewReader) Overview ¶
func (m *MockOverviewReader) Overview(ctx context.Context, req OverviewRequest) (OverviewResult, error)
Overview records the call and delegates to OverviewFunc when set.
type MockSessionReader ¶
type MockSessionReader struct {
contractkit.Recorder
ListSessionsFunc func(context.Context, ListSessionsRequest) (ListSessionsResult, error)
GetSessionFunc func(context.Context, GetSessionRequest) (GetSessionResult, error)
}
MockSessionReader is a test mock for the SessionReader interface.
The embedded contractkit.Recorder records every call so tests can assert call counts and captured arguments. Set XxxFunc fields to override per-method behaviour; unset methods return the canonical "MockSessionReader.<Method>Func not set" error.
func (*MockSessionReader) GetSession ¶
func (m *MockSessionReader) GetSession(ctx context.Context, req GetSessionRequest) (GetSessionResult, error)
GetSession records the call and delegates to GetSessionFunc when set.
func (*MockSessionReader) ListSessions ¶
func (m *MockSessionReader) ListSessions(ctx context.Context, req ListSessionsRequest) (ListSessionsResult, error)
ListSessions records the call and delegates to ListSessionsFunc when set.
type Narrow ¶
type Narrow struct {
Range Range
Services []string
Filters []Filter
// Explain compiles the final statements without running them; the result
// carries them in Statements.
Explain bool
// Now is the clock a metrics read marks partial buckets against; zero is
// time.Now(). The CLI sets it so a golden is deterministic.
Now time.Time
}
Narrow is what every telemetry request is narrowed by.
type OverviewReader ¶
type OverviewReader interface {
Overview(ctx context.Context, req OverviewRequest) (OverviewResult, error)
}
OverviewReader reads the per-service request figures of a range: the first section of `forge obs status`. Both backends implement it; they compile with the same pkg/obsquery overview.
type OverviewRequest ¶
type OverviewRequest struct {
Narrow
}
OverviewRequest asks for the per-service request figures of the narrowed scope: server spans for rate, errors and duration, logs for the error-level record count.
type OverviewResult ¶
type OverviewResult struct {
Services []ServiceOverview
Statements []Statement
}
OverviewResult is every service seen in the range, busiest first.
type QueryRequest ¶
type QueryRequest struct {
Narrow
SQL string
Panel *obsquery.Panel
Params map[string]string
// StepSeconds is the {step} parameter and a panel's bucket width; 0 picks
// one for the range.
StepSeconds int64
// Limit is the most rows returned; the statement is cut one past it to
// detect truncation.
Limit int
}
QueryRequest runs raw SQL (SQL) or a dashboard panel (Panel) against the scope. Raw SQL has the scope bound as the dashspec.SQLParam* parameters; it may also bind Params of its own.
type QueryResult ¶
QueryResult is a table: the rows of a raw statement, or a panel flattened into rows.
type REDSummary ¶
type REDSummary struct {
Traces uint64
ErrorTraces uint64
P50Ms float64
P95Ms float64
P99Ms float64
}
REDSummary is the rate/errors/duration over every trace the filters match.
type Result ¶
Result is a statement's output: its columns and rows. Cell values are what ClickHouse's JSONCompact format decodes to — string, json.Number, bool, nil, []any, map[string]any — read through the As* helpers.
func DecodeJSONCompact ¶
DecodeJSONCompact parses clickhouse-client's JSONCompact output.
type Runner ¶
Runner runs one compiled statement against a ClickHouse. A seam so verbs are testable without docker: the local backend is the only consumer.
type ServiceOverview ¶
type ServiceOverview struct {
Service string `json:"service"`
Requests int64 `json:"requests"`
RatePerSecond float64 `json:"rate_per_second"`
Errors int64 `json:"errors"`
// ErrorRate is a fraction, 0..1.
ErrorRate float64 `json:"error_rate"`
P50Ms float64 `json:"p50_ms"`
P95Ms float64 `json:"p95_ms"`
P99Ms float64 `json:"p99_ms"`
// ErrorLogs counts the error-level log records in the range.
ErrorLogs int64 `json:"error_logs"`
}
ServiceOverview is one service's figures over the range, busiest first.
type SessionEntry ¶
type SessionEntry struct {
Time time.Time
// Kind is an obsquery.TimelineKind: navigation, click, request_failed,
// error or event.
Kind string
// Name is a navigation's span name, "click", a failed request's method, an
// error's span name or a custom event's name.
Name string
// Path is the page, or a failed request's path.
Path string
Method string
// Status is a failed request's HTTP status; 0 for a network failure.
Status int
Selector string
Element string
// ErrorType is an error's exception type, or a failed request's SDK error
// type. Message is the error's masked message.
ErrorType string
Message string
// Fingerprint is the issue fingerprint of an error; IssueID the issue it
// belongs to, which only the control plane assigns.
Fingerprint string
IssueID string
TraceID string
SpanID string
DurationMs float64
Props map[string]string
Service string
}
SessionEntry is one line of a session's timeline. It carries no raw URL, query string or element text: paths have their query and fragment cut and a click is its tag and xpath.
type SessionReader ¶
type SessionReader interface {
ListSessions(ctx context.Context, req ListSessionsRequest) (ListSessionsResult, error)
GetSession(ctx context.Context, req GetSessionRequest) (GetSessionResult, error)
}
SessionReader reads browser sessions: the list, and one session's summary with its timeline (`forge obs sessions|session`). Both backends implement it. A local ClickStack has no browser tables, so its reads answer "could not look"; the cloud one is the control plane's RumService.
type SessionSummary ¶
type SessionSummary struct {
ID string
Service string
// Version is the service.version of the frontend build the session ran.
Version string
// UserID is the userId the app identified the session with; "" when it
// never did.
UserID string
// EntryPath is the path of the first page, with no query or fragment.
EntryPath string
Started time.Time
Ended time.Time
PageViews int64
Interactions int64
Errors int64
HasReplay bool
}
SessionSummary is one browser session.
type Span ¶
type Span struct {
SpanID string
ParentID string
Name string
Kind string
Service string
Start time.Time
DurationNs int64
StatusCode string
StatusMessage string
Attributes map[string]string
Events []SpanEvent
}
Span is one span of a trace.
func ErrorSpans ¶
ErrorSpans are the failing spans of a trace, earliest first.
type Statement ¶
type Statement struct {
Purpose string `json:"purpose"`
SQL string `json:"sql"`
Params map[string]string `json:"params,omitempty"`
}
Statement is one compiled statement a request ran (or, under Explain, would run): the starting point for `forge obs query --sql`.
type StatusChange ¶
StatusChange is a status entry. From is "" for the issue's opening.
type TelemetryDelivery ¶
type TelemetryDelivery struct {
Cluster string `json:"cluster"`
Namespace string `json:"namespace"`
Name string `json:"name"`
State string `json:"state"`
// ExpiresAt is when the delivered token stops working.
ExpiresAt time.Time `json:"expires_at,omitzero"`
LastVerifiedAt time.Time `json:"last_verified_at,omitzero"`
LastError string `json:"last_error,omitempty"`
ConsecutiveFailures int `json:"consecutive_failures,omitempty"`
}
TelemetryDelivery is where one declared telemetry-token Secret stands: whether the control plane has written a working token into the cluster that ships the env's telemetry.
type TimelineEntry ¶
type TimelineEntry struct {
ID string
Time time.Time
Kind string
Actor IssueActor
// IssueID is the issue it happened on: the requested one, or one merged
// into it.
IssueID string
Status *StatusChange
Comment *IssueComment
Assignment *AssignmentChange
Chat *ChatLink
}
TimelineEntry is one thing that happened to an issue. Kind says which of Status, Comment, Assignment and Chat is set.
type TraceRequest ¶
type TraceRequest struct {
Narrow
TraceID string
// LogLimit bounds the correlated logs returned.
LogLimit int
}
TraceRequest reads one trace and the logs that carry its id.
type TraceResult ¶
type TraceResult struct {
TraceID string
Spans []Span
// SpansTruncated says the trace has more spans than the compiler returns.
SpansTruncated bool
Logs []LogRecord
LogsTruncated bool
Statements []Statement
}
TraceResult is every span of the trace (up to obsquery.MaxSpansPerTrace) and a page of its logs.
type TraceSummary ¶
type TraceSummary struct {
TraceID string
Start time.Time
DurationMs float64
RootService string
RootName string
RootDurationMs float64
Spans int
Errors int
// Weight is how many real traces this stored one stands for (tail
// sampling); 1 locally.
Weight float64
Services []string
}
TraceSummary is one trace in a list.
type TracesRequest ¶
type TracesRequest struct {
Narrow
ErrorsOnly bool
MinDurationMs float64
// Route narrows to traces whose root span name contains it.
Route string
// Slow orders by duration, slowest first. The compiler pages newest-first
// only, so the slowest are taken from the newest SlowWindow traces.
Slow bool
Limit int
PageToken string
}
TracesRequest lists traces, newest first.
type TracesResult ¶
type TracesResult struct {
Traces []TraceSummary
Summary *REDSummary
NextPageToken string
// SortedFrom is how many traces a Slow request sorted (SlowWindow at most).
SortedFrom int
Statements []Statement
}
TracesResult is a page of traces.
type Tree ¶
type Tree struct {
Roots []*TreeNode
// Spans is every span of the trace; Shown how many are rendered (a
// collapsed run counts once).
Spans, Shown int
// Duration is first start to last end.
Duration time.Duration
// Orphans counts spans whose parent is not in the trace (a dropped or
// not-yet-exported parent); they are rendered as extra roots.
Orphans int
// Capped reports that a cap hid something.
Capped bool
}
Tree is a rendered trace.
type TreeNode ¶
type TreeNode struct {
Span Span
// Count > 1 marks a collapsed run: Count identical sibling spans (same
// service, name and status) shown once, with Min/P50/P95/Max over their
// durations.
Count int
Min, Max time.Duration
P50, P95 time.Duration
// Error is true when this span (or, for a run, any span in it) failed.
Error bool
// Critical marks the spans on the critical path: from the root, the child
// that ends last at each level.
Critical bool
// Offset is the span's start relative to the trace's first span.
Offset time.Duration
Children []*TreeNode
// Hidden counts descendants not rendered because of a cap, so the output
// can say "… 12 more spans" instead of dropping them silently.
Hidden int
}
TreeNode is one rendered node of a trace: a span, or a collapsed run of identical siblings.
type UpdateIssueStatusRequest ¶
type UpdateIssueStatusRequest struct {
ID string
// Status is IssueResolved, IssueIgnored or IssueUnresolved.
Status string
// ResolveIn is ResolveNow (default), ResolveNextRelease or ResolveVersion;
// Version names it for ResolveVersion.
ResolveIn string
Version string
// IgnoredUntil un-ignores at this time; zero ignores until unignored.
IgnoredUntil time.Time
}
UpdateIssueStatusRequest triages an issue.
type UpdateIssueStatusResult ¶
type UpdateIssueStatusResult struct {
Issue Issue
}
UpdateIssueStatusResult is the issue after the write.
Source Files
¶
- cloud.go
- cloud_health.go
- cloud_issue_discussion.go
- cloud_issues.go
- cloud_sessions.go
- cloud_status.go
- cloud_telemetry.go
- contract.go
- errors.go
- health.go
- issues.go
- local.go
- local_changes.go
- local_health.go
- local_issues.go
- local_rows.go
- local_sessions.go
- local_status.go
- metrics.go
- mock_gen.go
- resolve.go
- runner.go
- sessions.go
- shape.go
- status.go
- tree.go
- types.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package obstest boots a throwaway ClickHouse holding the OpenTelemetry exporter's tables and seeds it with a known set of traces, logs and metrics, for the tests of the obs verbs (obsbackend's own, and the CLI's end to end).
|
Package obstest boots a throwaway ClickHouse holding the OpenTelemetry exporter's tables and seeds it with a known set of traces, logs and metrics, for the tests of the obs verbs (obsbackend's own, and the CLI's end to end). |