Documentation
¶
Overview ¶
Package obs 提供 bootstrap 的可观测性接入组件(独立嵌套 module)。
以 BootstrapperOption 函数的形式注入 Prometheus 指标(oekit/metrics) 与 OpenTelemetry 追踪(oekit/tracing),使根包 github.com/oekit/bootstrap 保持零 prometheus/otel 依赖。
用法 ¶
b, _ := bootstrap.New(
bootstrap.WithServiceName("my-service"),
obs.WithMetrics(),
obs.WithTracing(tracing.Config{Endpoint: "otel:4317"}),
)
err := b.Run(userFn)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithMetrics ¶
func WithMetrics() bootstrap.BootstrapperOption
WithMetrics 添加 Prometheus 指标注册组件。 serviceName 由 bootstrap.New 经 ServiceNameAware 统一回填,与 WithServiceName 的调用顺序无关。
func WithTracing ¶
func WithTracing(cfg tracing.Config) bootstrap.BootstrapperOption
WithTracing 添加 OpenTelemetry 追踪组件。
Types ¶
type MetricsComponent ¶
type MetricsComponent struct {
// ServiceName 用于 Prometheus 指标中的 service 标签。
// 由 bootstrap.New 在应用完全部选项后经 ServiceNameAware 接口统一回填。
ServiceName string
}
MetricsComponent Prometheus 指标注册组件。
func (*MetricsComponent) SetServiceName ¶
func (c *MetricsComponent) SetServiceName(name string)
SetServiceName 实现 bootstrap.ServiceNameAware,由 New 统一回填。
type TracingComponent ¶
TracingComponent OpenTelemetry 追踪初始化组件。
Click to show internal directories.
Click to hide internal directories.