Help us shape the future of Go! Take the 2026 Go Developer Survey

otel

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

README

HTTPServer OTel Observability 包

httpserver/observability/otel 提供 OpenTelemetry tracing 中间件,负责请求上下文中的 span 创建与传播。

设计约束

  • 不在包内初始化 exporter
  • 不修改 httpserver core 的默认行为
  • 优先从请求上下文和 Header 中传播 trace 上下文

快速开始

srv.Use(otel.Middleware(otel.Config{
	TracerName: "user-service",
}))

Documentation

Overview

Package otel 提供 HTTP tracing 中间件。

该包只负责 span 创建、上下文传播和错误状态记录,不负责 exporter 或 provider 初始化,后者应由应用装配层显式提供。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware(config Config) gin.HandlerFunc

Middleware 创建 tracing 中间件。

Types

type Config

type Config struct {
	TracerProvider  oteltrace.TracerProvider
	TracerName      string
	Propagator      propagation.TextMapPropagator
	SpanNameBuilder func(*gin.Context) string
}

Config 描述 tracing 中间件配置。

Jump to

Keyboard shortcuts

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