telemetry

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package telemetry 隔离运行质量遥测与内部错误观测 provider。

Index

Constants

View Source
const (
	// DefaultFlushTimeout 是短命 Runtime 收口遥测时允许占用的最长时间。
	DefaultFlushTimeout = 500 * time.Millisecond
)

Variables

View Source
var BuildSentryDSN = ""

BuildSentryDSN 是发布构建可通过 -ldflags 注入的 Sentry DSN。 源码和默认开发构建保持为空,避免凭据进入版本库。

Functions

This section is empty.

Types

type Config

type Config struct {
	Enabled           bool
	Offline           bool
	SentryDSN         string
	SentryEnvironment string
	SentryRelease     string
	FlushTimeout      time.Duration
}

Config 是一次 Runtime 调用使用的遥测配置快照。

func LoadConfig

func LoadConfig() Config

LoadConfig 从当前进程环境读取遥测配置。

func LoadConfigFrom

func LoadConfigFrom(lookup func(string) (string, bool)) Config

LoadConfigFrom 使用调用方提供的环境读取函数构造配置,便于测试隔离进程环境。

type InternalObservation

type InternalObservation struct {
	Command         string
	Stage           string
	Code            string
	RuntimeVersion  string
	ProtocolVersion int
	Platform        string
	Panic           bool
	PanicFrames     []StackFrame
}

InternalObservation 是允许发送到 Sentry 的内部错误分类。

type Observer

type Observer struct {
	// contains filtered or unexported fields
}

Observer 汇总多个 provider,并把关闭生命周期线性化。

func (*Observer) CaptureInternal

func (o *Observer) CaptureInternal(ctx context.Context, observation InternalObservation)

CaptureInternal 记录允许上报的内部错误分类,不携带原始错误文本。

func (*Observer) Close

func (o *Observer) Close(ctx context.Context)

Close 在给定上下文截止前尽力收口全部 provider,重复调用安全。

type Recorder

type Recorder interface {
	CaptureInternal(context.Context, InternalObservation)
	Close(context.Context)
}

Recorder 是 CLI 消费的最小遥测接口;实现不得把错误返回给业务调用方。

func New

func New(config Config) Recorder

New 根据配置构造遥测观察器;禁用、离线或缺少凭据时不会创建 SDK client。

type StackFrame

type StackFrame struct {
	Function string
	Module   string
	Lineno   int
}

StackFrame 是允许附带到 panic 观测的最小栈帧;不包含源文件路径或局部变量。

Jump to

Keyboard shortcuts

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