Documentation
¶
Overview ¶
Package devtelemetry records where a local env's telemetry goes, as `forge env up` decided it, so `forge obs` reads the decision instead of re-deriving it from ambient login state.
Index ¶
- func BrowserHeadersPath(projectDir string) string
- func ClearCredentials(projectDir, env string) error
- func HeadersPath(projectDir string) string
- func MarkNoticeShown(projectDir string, at time.Time) error
- func NoticePath(projectDir string) string
- func NoticeShown(projectDir string) bool
- func Path(projectDir, env string) string
- func StatePath(projectDir, env string) string
- func Write(projectDir string, rec Record) error
- func WriteHeaders(projectDir, processToken, browserToken string) error
- func WriteState(projectDir string, st State) error
- type Record
- type Retention
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BrowserHeadersPath ¶
BrowserHeadersPath is the browser token's headers file, read by the frontend dev server's /_otel proxy (FORGE_OTEL_HEADERS_FILE).
func ClearCredentials ¶
ClearCredentials removes env's token state, and the headers files unless another env of this project is recorded as shipping to the hosted store (the headers files are per project). Called whenever env's telemetry is decided local, so a local stack never keeps a usable hosted token on disk and `forge env status` never reads a stale grant. A missing file is not an error.
func HeadersPath ¶
HeadersPath is the process token's headers file, in the `authorization=Bearer <token>` form OTEL_EXPORTER_OTLP_HEADERS_FILE names.
func MarkNoticeShown ¶
MarkNoticeShown records that the first-run notice was shown.
func NoticePath ¶
NoticePath records that the first-run notice of hosted dev telemetry was shown in this project.
func NoticeShown ¶
NoticeShown reports whether the first-run notice was already shown.
func StatePath ¶
StatePath is env's token state: when the current tokens expire, the retention the control plane granted, and why the last renewal failed.
func WriteHeaders ¶
WriteHeaders replaces both headers files with the two tokens.
func WriteState ¶
WriteState replaces env's token state atomically.
Types ¶
type Record ¶
type Record struct {
Env string `json:"env"`
Backend string `json:"backend"` // "cloud" or "local"
Reason string `json:"reason"`
OrgID string `json:"org_id,omitempty"`
EnvironmentID string `json:"environment_id,omitempty"`
InstanceID string `json:"instance_id,omitempty"`
InstanceLabel string `json:"instance_label,omitempty"`
InstanceUser string `json:"instance_user,omitempty"`
Endpoint string `json:"endpoint,omitempty"`
DecidedAt time.Time `json:"decided_at"`
}
Record is .forge/obs/backend-<env>.json.
type Retention ¶
type Retention struct {
TracesDays int `json:"traces_days,omitempty"`
MetricsDays int `json:"metrics_days,omitempty"`
LogsDays int `json:"logs_days,omitempty"`
BrowserDays int `json:"browser_days,omitempty"`
}
Retention is the effective retention the control plane granted, in days.
type State ¶
type State struct {
Env string `json:"env"`
ExpiresAt time.Time `json:"expires_at"`
RenewedAt time.Time `json:"renewed_at"`
Retention Retention `json:"retention"`
// RenewError is why the last renewal failed; empty after a success.
RenewError string `json:"renew_error,omitempty"`
}
State is .forge/obs/telemetry-<env>.json.