obsbackend

package
v1.0.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Code generated by forge. DO NOT EDIT. forge:hash=a7f7021728de3f8c744f1e6b7acf744494dab8fb3a0cf0f6eb6c9b3b3805cb80 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

View Source
const (
	WorkloadHealthy      = "healthy"
	WorkloadDegraded     = "degraded"
	WorkloadCrashLooping = "crash_looping"
	WorkloadPending      = "pending"
	WorkloadSuspended    = "suspended"
	WorkloadUnknown      = "unknown"
)

Workload health verdicts, the control plane's WorkloadHealth names lower case and unprefixed.

View Source
const (
	JobRunning   = "running"
	JobSucceeded = "succeeded"
	JobFailed    = "failed"
)

Job results, the control plane's WorkloadJobResult names lower case and unprefixed.

View Source
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.

View Source
const (
	ChangePromotion    = "promotion"
	ChangeFailedDeploy = "failed_deploy"
	ChangeActivity     = "activity"
	ChangeSession      = "session"
)

Change kinds.

View Source
const (
	IssueNew        = "new"
	IssueUnresolved = "unresolved"
	IssueResolved   = "resolved"
	IssueRegressed  = "regressed"
	IssueIgnored    = "ignored"
)

Issue statuses (DESIGN §5.5). A local issue is always IssueUnresolved.

View Source
const (
	PlatformServer  = "server"
	PlatformBrowser = "browser"
)

Issue platforms.

View Source
const (
	ResolveNow         = "now"
	ResolveNextRelease = "next"
	ResolveVersion     = "version"
)

Resolve-in kinds of a resolve.

View Source
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.

View Source
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.

View Source
const (
	MaxTreeDepth = 8
	MaxTreeSpans = 100
)

Trace-tree caps (DESIGN §8.1, Sentry's overview discipline). --full lifts them.

View Source
const (
	GapMinDuration = 50 * time.Millisecond
	GapMinShare    = 0.2
)

Thresholds for reporting a span's uninstrumented time: at least GapMinDuration, and at least GapMinShare of the span. Smaller gaps are the ordinary cost of code between calls.

View Source
const (
	BackendLocal = "local"
	BackendCloud = "cloud"
)

Backend names, as they appear in every document's scope.

View Source
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.

View Source
const AlertFiring = "firing"

AlertFiring is the state of an alert that fired; the other state the control plane reports is "pending".

View Source
const SlowWindow = obsquery.MaxTraceLimit

SlowWindow is how many of the newest matching traces a Slow request sorts.

Variables

IssueStatuses are the statuses a request may filter on, in lifecycle order.

Functions

func AggOf

func AggOf(a obsquery.Agg, quantile float64) (string, float64)

AggOf is the dashspec aggregation an evaluator aggregation resolves to, and its quantile level (0 unless the aggregation is a quantile).

func AsAny

func AsAny(v any) []any

AsAny returns the elements of an Array cell.

func AsFloat

func AsFloat(v any) float64

AsFloat reads a numeric cell; NaN and Inf arrive as null and read as 0.

func AsFloats

func AsFloats(v any) []float64

AsFloats reads an Array(Float64) cell.

func AsInt

func AsInt(v any) int64

AsInt reads an integer cell.

func AsString

func AsString(v any) string

AsString reads a String cell.

func AsStringMap

func AsStringMap(v any) map[string]string

AsStringMap reads a Map(String, String) cell.

func AsStrings

func AsStrings(v any) []string

AsStrings reads an Array(String) cell.

func AsTime

func AsTime(v any) time.Time

AsTime reads a DateTime / DateTime64 cell (rendered in UTC: the client runs with session_timezone=UTC).

func AsUint

func AsUint(v any) uint64

AsUint reads an unsigned integer cell.

func Cmd

func Cmd(argv ...string) string

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 FormatKVs added in v1.0.2

func FormatKVs(kvs []KV) string

FormatKVs renders kvs as `k=v` pairs, quoting values with spaces.

func IsGap added in v1.0.2

func IsGap(gap, dur time.Duration) bool

IsGap reports whether uninstrumented time gap in a span of duration dur is worth pointing at.

func LocalScope

func LocalScope(n Narrow, env string) obsquery.Scope

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 LogAttributes added in v1.0.2

func LogAttributes(attrs map[string]string) map[string]string

LogAttributes are a record's attributes without the shipper's noise; nil when nothing is left.

func MapCloudError

func MapCloudError(err error) error

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

func ParamArgs(params map[string]string) []string

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

func RowsOf(r Result) obsquery.Rows

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

func SQLShape(sql string) string

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 SpanMessage added in v1.0.2

func SpanMessage(s Span) string

SpanMessage is why a failed span failed: its exception ("type: message"), else its status message. "" when it says nothing.

func SuggestedOf

func SuggestedOf(err error) []string

SuggestedOf returns the remedy commands of the first *Error in err's chain.

func WithTrace

func WithTrace(query, traceID string) string

WithTrace narrows a log query to one trace. The query is parenthesised so an OR in it cannot escape the trace id (AND binds tighter than OR).

Types

type AddIssueCommentRequest

type AddIssueCommentRequest struct {
	ID   string
	Body string
}

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

type AlertReader interface {
	Alerts(ctx context.Context) ([]Alert, error)
}

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

type AssignIssueRequest struct {
	ID       string
	Assignee string
}

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

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

type Caller interface {
	Call(ctx context.Context, procedure string, req, out any) error
}

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 ChatLink struct {
	ChatID    string
	ChatTitle string
	LinkedBy  *IssueUser
	LinkedAt  time.Time
}

ChatLink is a chat started from the issue.

type Cloud

type Cloud struct {
	Env   string
	EnvID string
	OrgID string
	// ProjectID is the control plane's own id for the project, when the
	// checkout is bound to it; "" leaves ResolveProjectID to ask.
	ProjectID string
	Caller    Caller
}

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

func (c Cloud) Alerts(ctx context.Context) ([]Alert, error)

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) GetDashboard added in v1.0.9

func (c Cloud) GetDashboard(ctx context.Context, ref DashboardRef) (DashboardDocument, error)

GetDashboard reads one dashboard's current spec.

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) Info

func (c Cloud) Info() Info

Info implements Backend.

func (Cloud) ListDashboards added in v1.0.9

func (c Cloud) ListDashboards(ctx context.Context, project string) ([]DashboardInfo, error)

ListDashboards is the index the console shows for this env: the release dashboards its current release carries, and the workspace dashboards scoped to it or to every env. project narrows to one forge project; "" asks for the whole organization (the console does the same when it knows no project).

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

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) QueryPanelReadout added in v1.0.9

func (c Cloud) QueryPanelReadout(ctx context.Context, req PanelReadoutRequest) (PanelReadout, error)

QueryPanelReadout runs a panel the way the console does and reads the answer back as counts. The step is left to the control plane (the console sends 0 too), and the answer echoes what it chose.

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) ResolveProjectID added in v1.0.9

func (c Cloud) ResolveProjectID(ctx context.Context, name string) (string, error)

ResolveProjectID is the control plane's id for the forge project named name, which a dashboard listing and a panel's scope name (the project's local name need not be its id): the bound id when there is one, else the control plane's answer for the name.

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

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.

func (Cloud) Workloads added in v1.0.2

func (c Cloud) Workloads(ctx context.Context, n Narrow) (WorkloadsResult, error)

Workloads reads ListWorkloads for the env over n.Range (at most 7 days). n.Services narrows by workload name.

type Column

type Column struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

Column is one result column.

type ComposeFunc

type ComposeFunc func(ctx context.Context, projectDir string, args ...string) ([]byte, error)

ComposeFunc is the project's `docker compose` runner (internal/doctor's ComposeRunner, which has this shape).

type DashboardDocument added in v1.0.9

type DashboardDocument struct {
	Info    DashboardInfo
	Spec    json.RawMessage
	Version int
}

DashboardDocument is one dashboard's spec as the control plane stores it: a forge.dashboards/v1 dashboard object.

type DashboardInfo added in v1.0.9

type DashboardInfo struct {
	Ref DashboardRef
	// Title is the dashboard's title.
	Title string
	// Source is "generated", "repo", "workspace", "template" or "builtin".
	Source     string
	PanelCount int
	// ReleaseVersion is the release that shipped a release dashboard.
	ReleaseVersion string
	// Typed marks a server-owned view (organization costs) that has no panel
	// spec to run.
	Typed bool
}

DashboardInfo is one row of the console's dashboard index.

type DashboardReader added in v1.0.9

type DashboardReader interface {
	ListDashboards(ctx context.Context, project string) ([]DashboardInfo, error)
	GetDashboard(ctx context.Context, ref DashboardRef) (DashboardDocument, error)
	QueryPanelReadout(ctx context.Context, req PanelReadoutRequest) (PanelReadout, error)
}

DashboardReader replays the console's dashboards: the index it lists for an env, a dashboard's spec, and one panel run the way the console runs it, read back as counts (`forge obs dashboards audit`). Only the cloud backend implements it: a local ClickStack stores no dashboards.

type DashboardRef added in v1.0.9

type DashboardRef struct {
	Source    string
	ProjectID string
	Key       string
}

DashboardRef addresses one dashboard. Source is the wire enum name (DASHBOARD_SOURCE_GENERATED), kept verbatim so a ref read from the index is sent back unchanged.

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.

func Resolve

func Resolve(f Facts, override string) (Decision, error)

Resolve applies the §4.2 table. override is --backend: "", "local" or "cloud". An override skips the table's refusals (the caller said which backend), but "cloud" still needs a control plane to talk to.

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=).

func (DockerRunner) Run

func (d DockerRunner) Run(ctx context.Context, st obsquery.Stmt, lim Limits) (Result, error)

Run implements Runner.

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

func Undetermined(format string, a ...any) *Error

Undetermined is a failure to look: the stack is down, the backend is unreachable.

func Wrong

func Wrong(format string, a ...any) *Error

Wrong is a failure of the request: the statement was refused, the thing asked for does not exist.

func (*Error) Cause

func (e *Error) Cause(err error) *Error

Cause records the underlying error.

func (*Error) Error

func (e *Error) Error() string

func (*Error) ExitCode

func (e *Error) ExitCode() int

ExitCode is the process status this error produces.

func (*Error) Unwrap

func (e *Error) Unwrap() error

func (*Error) With

func (e *Error) With(cmds ...string) *Error

With attaches the commands that remedy the error.

type ExecFunc

type ExecFunc func(ctx context.Context, script string, args []string) ([]byte, error)

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 Failure added in v1.0.9

type Failure struct {
	Class FailureClass
	// Code is the Connect code's wire name; Reason the control plane's
	// domain reason. Either may be empty.
	Code   string
	Reason string
	// HTTPStatus is the response status (0: none came back).
	HTTPStatus int
	// Message is the control plane's own text.
	Message string
	// MissingScope names the scope a 403 says the credential lacks.
	MissingScope string
	// RetryAfter is how long the control plane asked to wait; ResetsAt when a
	// spent quota refills. Zero when it said neither.
	RetryAfter time.Duration
	ResetsAt   time.Time
}

Failure is a failed control-plane read, classified.

func FailureOf added in v1.0.9

func FailureOf(err error) Failure

FailureOf classifies err, a read's failure.

func (Failure) Transient added in v1.0.9

func (f Failure) Transient() bool

Transient says waiting RetryAfter and asking again is the right response.

type FailureClass added in v1.0.9

type FailureClass string

FailureClass says what kind of refusal or fault a failed read was, so a reader can tell "the credential may not look" from "the store is down" from "the panel is wrong". None of them is "no data".

const (
	// ClassAuth: the credential was refused (HTTP 401/403, missing scope).
	ClassAuth FailureClass = "auth"
	// ClassQuota: the org's hourly query allowance is spent.
	ClassQuota FailureClass = "quota"
	// ClassRateLimited: this credential's own request budget is spent.
	ClassRateLimited FailureClass = "rate_limited"
	// ClassInFlight: too many concurrent reads for this caller.
	ClassInFlight FailureClass = "in_flight"
	// ClassTimeout: the query ran too long.
	ClassTimeout FailureClass = "timeout"
	// ClassTooMuchData: the query touched more rows or bytes than a read may.
	ClassTooMuchData FailureClass = "too_much_data"
	// ClassStorage: the telemetry store is unavailable or not set up.
	ClassStorage FailureClass = "storage"
	// ClassInvalid: the control plane refused the request as malformed.
	ClassInvalid FailureClass = "invalid"
	// ClassNotFound: the thing asked for does not exist.
	ClassNotFound FailureClass = "not_found"
	// ClassUnsupported: an older control plane that does not serve the call.
	ClassUnsupported FailureClass = "unsupported"
	// ClassUnreachable: no answer came back at all.
	ClassUnreachable FailureClass = "unreachable"
	// ClassServer: the control plane failed internally.
	ClassServer FailureClass = "server"
	// ClassUnknown: none of the above.
	ClassUnknown FailureClass = "unknown"
)

The failure classes.

type Filter

type Filter struct {
	Key   string
	Value string
	Not   bool
}

Filter is a --filter key=value (or key!=value) predicate over the server's attribute allowlist (obsquery.AllowedKeys).

func ParseFilter

func ParseFilter(s string) (Filter, error)

ParseFilter reads a --filter value: key=value or key!=value.

type GetIssueRequest

type GetIssueRequest struct {
	Narrow
	ID string
}

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

type IssueActor struct {
	Kind string
	ID   string
	Name string
}

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

type IssueFrame struct {
	Function string
	File     string
	Line     int
	InApp    bool
}

IssueFrame is one stack frame, innermost first.

type IssueReader

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 IssueUser

type IssueUser struct {
	ID   string
	Name string
}

IssueUser is a person as an issue shows them: an assignee, an author.

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 Job added in v1.0.2

type Job struct {
	EnvName    string    `json:"env_name,omitempty"`
	Name       string    `json:"name"`
	Workload   string    `json:"workload,omitempty"`
	Result     string    `json:"result"`
	Reason     string    `json:"reason,omitempty"`
	Release    string    `json:"release,omitempty"`
	StartedAt  time.Time `json:"started_at,omitzero"`
	FinishedAt time.Time `json:"finished_at,omitzero"`
	Seconds    int64     `json:"duration_seconds,omitempty"`
}

Job is one Kubernetes Job run.

type KV added in v1.0.2

type KV struct{ Key, Value string }

KV is one attribute picked for a one-line summary.

func LogReason added in v1.0.2

func LogReason(attrs map[string]string) []KV

LogReason is what a log record says about a failure beyond its body: the error, its cause, the exception and the code, the attributes forge's logging interceptor and svcerr write. A body like "rpc failed" says that something failed; these say what.

func SpanKeyAttributes added in v1.0.2

func SpanKeyAttributes(s Span) []KV

SpanKeyAttributes are the attributes that say what a span did and how it ended, in the order a reader wants them: the RPC or HTTP outcome, the error class, then what a database statement was and how much it read. Attributes that only repeat the span's name are left out. Empty when the span carries none of them.

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

type ListIssueEventsRequest struct {
	Narrow
	ID    string
	Limit int
}

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

type ListIssueTimelineRequest struct {
	ID    string
	Limit int
}

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

AddIssueComment implements IssueReader: local issues carry no state.

func (Local) AssignIssue

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) Info

func (l Local) Info() Info

Info implements Backend.

func (Local) ListIssueEvents

func (l Local) ListIssueEvents(ctx context.Context, req ListIssueEventsRequest) (ListIssueEventsResult, error)

ListIssueEvents implements IssueReader.

func (Local) ListIssueTimeline

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

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

type LogsResult struct {
	Logs          []LogRecord
	NextPageToken string
	Statements    []Statement
}

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

type MetricAttributeSpec struct {
	Key    string
	Values []string
}

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

type MetricPoint struct {
	Time          time.Time
	Value         float64
	Null, Partial bool
}

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

type MetricsDescribeRequest struct {
	Narrow
	Name string
}

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

type MetricsListRequest struct {
	Narrow
	NameContains string
	Limit        int
}

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.

func (*MockAlertReader) Alerts

func (m *MockAlertReader) Alerts(ctx context.Context) ([]Alert, error)

Alerts records the call and delegates to AlertsFunc when set.

type MockBackend

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

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

MetricsDescribe records the call and delegates to MetricsDescribeFunc when set.

func (*MockBackend) MetricsExemplars

MetricsExemplars records the call and delegates to MetricsExemplarsFunc when set.

func (*MockBackend) MetricsList

MetricsList records the call and delegates to MetricsListFunc when set.

func (*MockBackend) MetricsQuery

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

Changes records the call and delegates to ChangesFunc when set.

type MockDashboardReader added in v1.0.9

type MockDashboardReader struct {
	contractkit.Recorder
	ListDashboardsFunc    func(context.Context, string) ([]DashboardInfo, error)
	GetDashboardFunc      func(context.Context, DashboardRef) (DashboardDocument, error)
	QueryPanelReadoutFunc func(context.Context, PanelReadoutRequest) (PanelReadout, error)
}

MockDashboardReader is a test mock for the DashboardReader 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 "MockDashboardReader.<Method>Func not set" error.

func (*MockDashboardReader) GetDashboard added in v1.0.9

GetDashboard records the call and delegates to GetDashboardFunc when set.

func (*MockDashboardReader) ListDashboards added in v1.0.9

func (m *MockDashboardReader) ListDashboards(ctx context.Context, project string) ([]DashboardInfo, error)

ListDashboards records the call and delegates to ListDashboardsFunc when set.

func (*MockDashboardReader) QueryPanelReadout added in v1.0.9

func (m *MockDashboardReader) QueryPanelReadout(ctx context.Context, req PanelReadoutRequest) (PanelReadout, error)

QueryPanelReadout records the call and delegates to QueryPanelReadoutFunc 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

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

AddIssueComment records the call and delegates to AddIssueCommentFunc when set.

func (*MockIssueReader) AssignIssue

AssignIssue records the call and delegates to AssignIssueFunc when set.

func (*MockIssueReader) GetIssue

GetIssue records the call and delegates to GetIssueFunc when set.

func (*MockIssueReader) ListIssueEvents

ListIssueEvents records the call and delegates to ListIssueEventsFunc when set.

func (*MockIssueReader) ListIssueTimeline

ListIssueTimeline records the call and delegates to ListIssueTimelineFunc when set.

func (*MockIssueReader) ListIssues

ListIssues records the call and delegates to ListIssuesFunc when set.

func (*MockIssueReader) UpdateIssueStatus

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

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

GetSession records the call and delegates to GetSessionFunc when set.

func (*MockSessionReader) ListSessions

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 PanelReadout added in v1.0.9

type PanelReadout struct {
	// Kind echoes the panel kind the control plane ran.
	Kind string
	// StepSeconds is the bucket width the control plane used (0: the kind has
	// no time axis).
	StepSeconds int64
	// Series and Rows are how many entries the answer carries; Points is the
	// points across all series, NonNull those that hold a value, NonZero those
	// (and table cells, and number figures) that are not zero.
	Series, Rows, Points, NonNull, NonZero int
	// Buckets is how many distinct bucket times hold a drawable (non-null)
	// point: null formula results and gaps draw nothing, so a line of one
	// valued point among nulls is one bucket.
	Buckets int
	// SeriesBuckets is, per series that holds a drawable point, how many
	// distinct bucket times it holds: a line is drawn per series, so a series
	// of one bucket draws nothing whatever the others hold.
	SeriesBuckets []int
	// LastDataAt is the newest bucket holding a non-zero value; zero when the
	// answer has no time axis or nothing non-zero.
	LastDataAt time.Time
	// Items counts funnel steps entered, issues, sessions or heatmap cells.
	Items int
	// HasData is true when the console would draw something rather than its
	// empty state.
	HasData bool
	// BucketSeconds and BucketTimezone are the bucket width and zone a sql
	// time series reports; zero and empty when the control plane sends none
	// (older ones do not, and nothing here depends on them).
	BucketSeconds  int64
	BucketTimezone string
	// Truncated says a cap cut the answer; SeriesTotal is how many series
	// matched before the cap (0: unknown).
	Truncated   bool
	SeriesTotal int
	// Warnings are the control plane's non-fatal notes, verbatim
	// ("metric_absent: rpc.server.calls").
	Warnings []string
	// SQLColumns are a sql panel's result columns, in order.
	SQLColumns []Column
}

PanelReadout is what one QueryPanel answer holds, as counts: enough to say whether the console has anything to draw and why not, without carrying the data itself.

type PanelReadoutRequest added in v1.0.9

type PanelReadoutRequest struct {
	// Narrow carries the range and services; its filters and Explain are the
	// audit's to leave empty (the console sends none for a dashboard panel).
	Narrow
	Panel obsquery.Panel
	// ProjectID is the forge project, sent beside the env as the console does
	// (empty: no project narrowing).
	ProjectID string
	// AllEnvs lifts the env bound: the same panel over every environment of
	// ProjectID, the question "does this data exist in another env?".
	AllEnvs bool
	// NoEnv drops the env predicate as a platform-scoped dashboard does: its
	// telemetry belongs to no environment and carries no env id. Unlike
	// AllEnvs it is the dashboard's own read, not a widening, so it needs no
	// project to bound it (who may read which org's data is unchanged).
	NoEnv bool
}

PanelReadoutRequest is one panel run.

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

type QueryResult struct {
	Columns    []Column
	Rows       [][]any
	Truncated  bool
	Statements []Statement
}

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 Range

type Range struct{ From, To time.Time }

Range is the half-open time range of a query, in UTC.

type Result

type Result struct {
	Columns []Column
	Rows    [][]any
}

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

func DecodeJSONCompact(out []byte) (Result, error)

DecodeJSONCompact parses clickhouse-client's JSONCompact output.

func (Result) Col

func (r Result) Col(name string) int

Col is the index of the column called name, or -1.

type Runner

type Runner interface {
	Run(ctx context.Context, st obsquery.Stmt, lim Limits) (Result, error)
}

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

func ErrorSpans(spans []Span) []Span

ErrorSpans are the failing spans of a trace, earliest first.

type SpanEvent

type SpanEvent struct {
	Name       string
	Time       time.Time
	Attributes map[string]string
}

SpanEvent is an event recorded on a span (exceptions are events).

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

type StatusChange struct {
	From, To     string
	Version      string
	IgnoredUntil time.Time
}

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.

func BuildTree

func BuildTree(spans []Span, full bool) Tree

BuildTree arranges spans into a tree under the caps. full lifts them.

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
	// Uninstrumented is how much of the span no child span covers, when that
	// is enough to be where the time went (see [IsGap]); zero otherwise. A
	// handler that took 10s with 15ms of children spent the rest in code that
	// emitted no span, and the reader should look there, not at the children.
	// Gap is the largest such stretch, as offsets from the span's start.
	Uninstrumented time.Duration
	Gap            [2]time.Duration
}

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.

type Workload added in v1.0.2

type Workload struct {
	EnvID     string `json:"env_id,omitempty"`
	EnvName   string `json:"env_name,omitempty"`
	Workload  string `json:"workload"`
	Namespace string `json:"namespace,omitempty"`
	Kind      string `json:"kind,omitempty"`
	Health    string `json:"health"`
	// Cause says whose side a fault is on: workload, platform, undetermined.
	Cause         string              `json:"cause,omitempty"`
	Reason        string              `json:"reason,omitempty"`
	Detail        string              `json:"detail,omitempty"`
	Since         time.Time           `json:"since,omitzero"`
	SinceKnown    bool                `json:"since_known,omitempty"`
	Ready         *int32              `json:"ready,omitempty"`
	Desired       *int32              `json:"desired,omitempty"`
	Restarts      int64               `json:"restarts"`
	LastExit      string              `json:"last_exit_reason,omitempty"`
	LastExitAt    time.Time           `json:"last_exit_at,omitzero"`
	Release       string              `json:"release,omitempty"`
	Version       string              `json:"service_version,omitempty"`
	Containers    []WorkloadContainer `json:"containers,omitempty"`
	LatestWarning *WorkloadEvent      `json:"latest_warning,omitempty"`
}

Workload is one workload's health over the range.

func (Workload) Unhealthy added in v1.0.2

func (w Workload) Unhealthy() bool

Unhealthy reports whether the workload needs a look: any verdict but healthy or suspended, or a restart in the range.

type WorkloadContainer added in v1.0.2

type WorkloadContainer struct {
	Container        string    `json:"container"`
	Image            string    `json:"image,omitempty"`
	Restarts         int64     `json:"restarts"`
	LastExitReason   string    `json:"last_exit_reason,omitempty"`
	LastExitAt       time.Time `json:"last_exit_at,omitzero"`
	MemoryLimitRatio *float64  `json:"memory_limit_ratio,omitempty"`
}

WorkloadContainer is one container's restarts and last termination.

type WorkloadEvent added in v1.0.2

type WorkloadEvent struct {
	At         time.Time `json:"at,omitzero"`
	Type       string    `json:"type,omitempty"`
	Reason     string    `json:"reason,omitempty"`
	Plain      string    `json:"plain_reason,omitempty"`
	Message    string    `json:"message,omitempty"`
	Count      int64     `json:"count,omitempty"`
	ObjectKind string    `json:"object_kind,omitempty"`
	ObjectName string    `json:"object_name,omitempty"`
}

WorkloadEvent is a Kubernetes event about a workload.

type WorkloadsResult added in v1.0.2

type WorkloadsResult struct {
	Workloads     []Workload
	Truncated     bool
	Jobs          []Job
	JobsTruncated bool
}

WorkloadsResult is the env's workloads, worst first, and its Job runs, newest first.

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).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL