Documentation
¶
Index ¶
- func GetGlobalLogger(component string) zerolog.Logger
- type Config
- type LogFormat
- type Options
- type Telemetry
- func (t *Telemetry) CaptureEvent(ctx context.Context, event string, properties map[string]any)
- func (t *Telemetry) CaptureException(ctx context.Context, err error)
- func (t *Telemetry) GetLogger(component string) zerolog.Logger
- func (t *Telemetry) GetLoggerWithTrace(ctx context.Context, component string) zerolog.Logger
- func (t *Telemetry) MaxCommandLinks() int
- func (t *Telemetry) RecoverAndFlush(repanic bool)
- func (t *Telemetry) Shutdown(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetGlobalLogger ¶
GetGlobalLogger returns a component-specific logger using the global console logger.
Types ¶
type Config ¶
type Config struct {
// Endpoint is the OTLP gRPC collector endpoint, either a bare host:port or a URL with a scheme.
// The default targets the groundcover sensor inside a Kubernetes cluster. A bare host:port is
// sent in plaintext unless OTEL_EXPORTER_OTLP_INSECURE says otherwise; an https:// URL enables
// TLS with the host's root CAs, which is what groundcover's BYOC ingestion endpoint needs.
// Auth headers such as groundcover's ingestion key come from the standard
// OTEL_EXPORTER_OTLP_HEADERS variable (for example "apikey=<ingestion-key>"). Setting the
// variable to an empty string disables tracing; the default is applied in loadConfig because
// the env parser would otherwise substitute it for an explicitly empty value.
Endpoint string `env:"OTEL_EXPORTER_OTLP_ENDPOINT"`
// TracesEndpoint is the signal-specific OTLP endpoint; when set it takes precedence over Endpoint.
TracesEndpoint string `env:"OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"`
// Insecure selects plaintext gRPC for a bare host:port endpoint. Ignored for URL endpoints,
// where the scheme decides. Unset keeps the plaintext default.
Insecure *bool `env:"OTEL_EXPORTER_OTLP_INSECURE"`
// TracesInsecure is the signal-specific form of Insecure; when set it takes precedence.
TracesInsecure *bool `env:"OTEL_EXPORTER_OTLP_TRACES_INSECURE"`
// MetricsEndpoint is the OTLP gRPC endpoint for metrics, in the same forms as Endpoint. Metrics
// are exported only when it is set. Unlike traces they never fall back to Endpoint: the cardinal
// operator points Endpoint at a collector that accepts traces only, so falling back would fail
// every export from operator-managed shards.
MetricsEndpoint string `env:"OTEL_EXPORTER_OTLP_METRICS_ENDPOINT"`
// MetricsInsecure is the metrics form of TracesInsecure; when set it takes precedence over Insecure.
MetricsInsecure *bool `env:"OTEL_EXPORTER_OTLP_METRICS_INSECURE"`
// TraceSampleRate is the sampling rate for traces (0.0 to 1.0).
TraceSampleRate float64 `env:"OTEL_TRACE_SAMPLE_RATE" envDefault:"1.0"`
// Log level configuration ("debug", "info", "warn", "error").
LogLevel string `env:"LOG_LEVEL" envDefault:"info"`
// Log format configuration ("json", "pretty").
LogFormat string `env:"LOG_FORMAT" envDefault:"json"`
// SentryDsn is the Sentry DSN.
SentryDsn string `env:"SENTRY_DSN"`
// SentryEnvironment is to determine if shard is running in development or production (DEV/PROD).
SentryEnvironment string `env:"SENTRY_ENVIRONMENT"`
// PosthogAPIKey is the PostHog API key.
PosthogAPIKey string `env:"POSTHOG_API_KEY"`
}
type LogFormat ¶
type LogFormat uint8
LogFormat represents the log output format.
func ParseLogFormat ¶
ParseLogFormat converts a string to LogFormat enum.
type Options ¶
type Options struct {
ServiceName string // Name of the service for telemetry
Endpoint string // OTLP trace endpoint, a bare host:port or a URL with a scheme
Insecure bool // Plaintext gRPC for a bare host:port endpoint; ignored for URLs
MetricsEndpoint string // OTLP metric endpoint in the same forms; empty disables metrics
MetricsInsecure bool // Insecure for MetricsEndpoint
LogLevel string
LogFormat LogFormat // Log output format
TraceSampleRate float64
SentryOptions sentry.Options
PosthogOptions posthog.Options
}
type Telemetry ¶
func (*Telemetry) CaptureEvent ¶ added in v0.0.5
CaptureEvent captures an event and sends it to PostHog.
func (*Telemetry) CaptureException ¶ added in v0.0.5
CaptureException captures an exception and sends it to Sentry.
func (*Telemetry) GetLoggerWithTrace ¶
GetLoggerWithTrace returns a component-specific logger enriched with trace context.
func (*Telemetry) MaxCommandLinks ¶ added in v0.20.0
MaxCommandLinks returns the resolved span link limit the tracer provider enforces (OTEL_SPAN_LINK_COUNT_LIMIT, default 128). Callers that pre-cap span links should cap at this value so they never build links the SDK would drop.
func (*Telemetry) RecoverAndFlush ¶ added in v0.0.5
RecoverAndFlush recovers from a panic and flushes buffered events to Sentry.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package trace is a light wrapper over the OpenTelemetry tracing API, modeled on Sourcegraph's internal/trace: one constructor bound to the global tracer provider and a Trace type that adds error helpers to the span.
|
Package trace is a light wrapper over the OpenTelemetry tracing API, modeled on Sourcegraph's internal/trace: one constructor bound to the global tracer provider and a Trace type that adds error helpers to the span. |