observability

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package observability provides observability service implementation for gorp framework. Includes metrics, tracing, logging, and error reporting components. Prometheus metrics, noop tracer by default, extensible to OpenTelemetry.

可观测性包提供可观测性服务实现,用于 gorp 框架。 包括指标、追踪、日志和错误上报组件。 Prometheus 指标、默认 noop tracer,可扩展到 OpenTelemetry。

Package observability provides observability provider for gorp framework. Registers unified observability service with metrics, tracing, logging, error reporting.

可观测性包提供可观测性 provider,用于 gorp 框架。 注册统一的可观测性服务,包括指标、追踪、日志、错误上报。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultObservability

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

DefaultObservability aggregates metrics, tracer, logger, and error reporter. Core logic: Provide unified access to all observability components.

DefaultObservability 聚合指标、追踪器、日志器和错误上报器。 核心逻辑:提供统一的可观测性组件访问入口。

func NewDefaultObservability

NewDefaultObservability creates observability with all components. Core logic: Store all components for unified access.

NewDefaultObservability 创建携带所有组件的可观测性实例。 核心逻辑:存储所有组件供统一访问。

func (*DefaultObservability) ErrorReporter

func (*DefaultObservability) Logger

func (*DefaultObservability) Metrics

func (*DefaultObservability) Tracer

type NoopSpan

type NoopSpan struct{}

func (*NoopSpan) AddEvent

func (s *NoopSpan) AddEvent(name string, attributes map[string]interface{})

func (*NoopSpan) Context

func (s *NoopSpan) Context() context.Context

func (*NoopSpan) End

func (s *NoopSpan) End(options ...observabilitycontract.SpanEndOption)

func (*NoopSpan) IsRecording

func (s *NoopSpan) IsRecording() bool

func (*NoopSpan) SetAttributes

func (s *NoopSpan) SetAttributes(attributes map[string]interface{})

func (*NoopSpan) SetError

func (s *NoopSpan) SetError(err error)

func (*NoopSpan) SetStatus

func (s *NoopSpan) SetStatus(code observabilitycontract.SpanStatusCode, description string)

func (*NoopSpan) SetTag

func (s *NoopSpan) SetTag(key string, value interface{})

func (*NoopSpan) SpanContext

func (s *NoopSpan) SpanContext() observabilitycontract.SpanContext

type NoopTracer

type NoopTracer struct{}

func NewNoopTracer

func NewNoopTracer() *NoopTracer

func (*NoopTracer) Extract

func (*NoopTracer) Inject

func (*NoopTracer) SpanFromContext

func (t *NoopTracer) SpanFromContext(ctx context.Context) observabilitycontract.Span

func (*NoopTracer) StartSpan

type PrometheusMetrics

type PrometheusMetrics struct{}

func NewPrometheusMetrics

func NewPrometheusMetrics() *PrometheusMetrics

func (*PrometheusMetrics) Counter

func (m *PrometheusMetrics) Counter(name string, labels map[string]string, delta float64)

func (*PrometheusMetrics) Gauge

func (m *PrometheusMetrics) Gauge(name string, labels map[string]string, value float64)

func (*PrometheusMetrics) Histogram

func (m *PrometheusMetrics) Histogram(name string, labels map[string]string, value float64)

func (*PrometheusMetrics) Timing

func (m *PrometheusMetrics) Timing(name string, labels map[string]string, duration time.Duration)

type PrometheusTracer

type PrometheusTracer struct{}

func NewPrometheusTracer

func NewPrometheusTracer() *PrometheusTracer

func (*PrometheusTracer) Extract

func (*PrometheusTracer) Inject

func (*PrometheusTracer) SpanFromContext

func (t *PrometheusTracer) SpanFromContext(ctx context.Context) observabilitycontract.Span

func (*PrometheusTracer) StartSpan

type Provider

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

Provider registers unified observability service. Core logic: Aggregate metrics, tracer, logger, error reporter into single service.

Provider 注册统一的可观测性服务。 核心逻辑:将指标、追踪器、日志器、错误上报器聚合为单一服务。

func NewProvider

NewProvider creates a new observability provider with configuration.

NewProvider 创建新的可观测性 provider,携带配置。

func (*Provider) Boot

Boot initializes the observability provider. No additional startup logic required.

Boot 初始化可观测性 provider。 无需额外启动逻辑。

func (*Provider) IsDefer

func (p *Provider) IsDefer() bool

IsDefer indicates observability should not defer loading. Must be available early for metrics and tracing.

IsDefer 表示可观测性不应延迟加载。 必须尽早可用以支持指标和追踪。

func (*Provider) Name

func (p *Provider) Name() string

Name returns provider name for identification.

Name 返回 provider 名称,用于标识。

func (*Provider) Provides

func (p *Provider) Provides() []string

Provides returns the capability keys this provider exposes. Exposes ObservabilityKey for unified observability service.

Provides 返回 provider 暴露的能力键。 暴露 ObservabilityKey 用于统一可观测性服务。

func (*Provider) Register

func (p *Provider) Register(c runtimecontract.Container) error

Register binds the observability factory to the container. Core logic: Aggregate all components, create DefaultObservability, bind to container.

Register 将可观测性工厂绑定到容器。 核心逻辑:聚合所有组件、创建 DefaultObservability、绑定到容器。

Jump to

Keyboard shortcuts

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