telemetry

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: LGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetGlobalLogger

func GetGlobalLogger(component string) zerolog.Logger

GetGlobalLogger returns a component-specific logger using the global console logger.

Types

type Config

type Config struct {
	// Endpoint is the OTLP collector endpoint.
	Endpoint string `env:"OTEL_EXPORTER_OTLP_ENDPOINT" envDefault:"jaeger:4317"`

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

const (
	LogFormatUndefined LogFormat = iota // Used as the zero value
	LogFormatJSON                       // Outputs structured JSON logs
	LogFormatPretty                     // Outputs human-readable console logs
)

func ParseLogFormat

func ParseLogFormat(s string) LogFormat

ParseLogFormat converts a string to LogFormat enum.

func (LogFormat) String

func (f LogFormat) String() string

type Options

type Options struct {
	ServiceName     string // Name of the service for telemetry
	Endpoint        string
	LogLevel        string
	LogFormat       LogFormat // Log output format
	TraceSampleRate float64

	SentryOptions  sentry.Options
	PosthogOptions posthog.Options
}

type Telemetry

type Telemetry struct {
	Logger zerolog.Logger
	Tracer trace.Tracer
	// contains filtered or unexported fields
}

func New

func New(opts Options) (Telemetry, error)

func (*Telemetry) CaptureEvent added in v0.0.5

func (t *Telemetry) CaptureEvent(ctx context.Context, event string, properties map[string]any)

CaptureEvent captures an event and sends it to PostHog.

func (*Telemetry) CaptureException added in v0.0.5

func (t *Telemetry) CaptureException(ctx context.Context, err error)

CaptureException captures an exception and sends it to Sentry.

func (*Telemetry) GetLogger

func (t *Telemetry) GetLogger(component string) zerolog.Logger

GetLogger returns a component-specific logger.

func (*Telemetry) GetLoggerWithTrace

func (t *Telemetry) GetLoggerWithTrace(ctx context.Context, component string) zerolog.Logger

GetLoggerWithTrace returns a component-specific logger enriched with trace context.

func (*Telemetry) RecoverAndFlush added in v0.0.5

func (t *Telemetry) RecoverAndFlush(repanic bool)

RecoverAndFlush recovers from a panic and flushes buffered events to Sentry.

func (*Telemetry) Shutdown

func (t *Telemetry) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the telemetry system.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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