Golang 上下文配置
- 作者仓库星标 0
- 作者仓库 skills-registry
Skill: golang-echo-otel-middleware
Use this skill when adding or configuring github.com/adlandh/echo-otel-middleware/v2 in a Go Echo application, or when writing examples for this middleware.
Essentials
- Import path must include
/v2:github.com/adlandh/echo-otel-middleware/v2. - Alias examples as
echootelmiddlewareto match the package name and README. - This middleware targets Echo v5: use
github.com/labstack/echo/v5and handler signatures with*echo.Context. Middleware()uses global OpenTelemetry tracer provider and propagator; useMiddlewareWithConfigwhen the app owns explicit OTel setup.
Basic Usage
app := echo.New()
app.Use(echootelmiddleware.Middleware())
Use explicit config when a tracer provider or propagator is constructed by the application:
app.Use(echootelmiddleware.MiddlewareWithConfig(echootelmiddleware.OtelConfig{
TracerProvider: tp,
Propagator: otel.GetTextMapPropagator(),
}))
Config Defaults
TracerProvider:otel.GetTracerProvider().Propagator:otel.GetTextMapPropagator().Skipper: Echomiddleware.DefaultSkipper.BodySkipper: no-op, returnsfalse, false.AreHeadersDump:true.IsBodyDump:false.RemoveNewLines:false.LimitNameSizeandLimitValueSize:0, meaning unlimited.
Safe Body Dumping
- Body dumping is opt-in with
IsBodyDump: truebecause it can capture PII, tokens, and secrets. - Prefer
BodySkipperto exclude sensitive endpoints, compressed bodies, uploads, auth payloads, or large responses. BodySkipperonly runs whenIsBodyDumpis true and returns(skipReqBody, skipRespBody).
BodySkipper: func(c *echo.Context) (bool, bool) {
if c.Request().Header.Get("Content-Encoding") == "gzip" {
return true, true
}
return false, false
},
Attribute Limits
LimitNameSizeandLimitValueSizeare byte-based, not rune-based.- Truncation preserves valid UTF-8; values over a limit greater than 10 get a trailing
.... RemoveNewLinesreplaces\nwith spaces in string attributes, useful for backends such as Sentry.
Do Not Assume
- Metrics are not implemented in this middleware; do not add or document metrics unless explicitly requested.
- Echo v4 examples are wrong for this package because context types and imports differ.
<!-- tomevault:4.0:skill_md:2026-05-23 -->Source: adlandh/echo-otel-middleware — distributed by TomeVault.
- 流狐分类
- 写作
- 作者声明 Agent
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 作者 / 版本 / 许可
- @tomevault-io · 未声明 license
- 流狐 Token 估算
- 低消耗
- 流狐接入估算
- 即装即用
- 是否需要外部 API Key
- 未发现要求
- 检测到的系统要求
- 未声明
- 底层运行要求
- 未声明
- 检测到的文件与系统行为
-
- 只读
- 检测到的网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
作者没有在当前 SKILL.md 中定义固定输出样例。 Import path must include /v2: github.com/adlandh/echo-otel-middleware/v2. Alias examples as echootelmiddleware to match the package name and README. This middleware targets Echo v5: use github.com/labstack/echo/v5 and handler signatures with echo.Context.
Use explicit config when a tracer provider or propagator is constructed by the application:
TracerProvider: otel.GetTracerProvider(). Propagator: otel.GetTextMapPropagator(). Skipper: Echo middleware.DefaultSkipper.
Body dumping is opt-in with IsBodyDump: true because it can capture PII, tokens, and secrets. Prefer BodySkipper to exclude sensitive endpoints, compressed bodies, uploads, auth payloads, or large responses. BodySkipper only runs when IsBodyDump is true and…
LimitNameSize and LimitValueSize are byte-based, not rune-based. Truncation preserves valid UTF-8; values over a limit greater than 10 get a trailing .... RemoveNewLines replaces \n with spaces in string attributes, useful for backends such as Sentry.
Metrics are not implemented in this middleware; do not add or document metrics unless explicitly requested. Echo v4 examples are wrong for this package because context types and imports differ. Source: adlandh/echo-otel-middleware — distributed by TomeVault.
# Skill: golang-echo-otel-middleware
Use this skill when adding or configuring `github.com/adlandh/echo-otel-middleware/v2` in a Go Echo application, or when writing examples for this middleware.
## Essentials
- Import path must include `/v2`: `github.com/adlandh/echo-otel-middleware/v2`.
- Alias examples as `echootelmiddleware` to match the package name and README.
- This middleware targets Echo v5: use `github.com/labstack/echo/v5` and handler signatures with `*echo.Context`.
- `Middleware()` uses global OpenTelemetry tracer provider and propagator; use `MiddlewareWithConfig` when the app owns explicit OTel setup.
## Basic Usage
```go
app := echo.New()
app.Use(echootelmiddleware.Middleware())
```
Use explicit config when a tracer provider or propagator is constructed by the application:
```go
app.Use(echootelmiddleware.MiddlewareWithConfig(echootelmiddleware.OtelConfig{
TracerProvider: tp,
Propagator: otel.GetTextMapPropagator(),
}))
```
## Config Defaults
- `TracerProvider`: `otel.GetTracerProvider()`.
- `Propagator`: `otel.GetTextMapPropagator()`.
- `Skipper`: Echo `middleware.DefaultSkipper`.
- `BodySkipper`: no-op, returns `false, false`.
- `AreHeadersDump`: `true`.
- `IsBodyDump`: `false`.
- `RemoveNewLines`: `false`.
- `LimitNameSize` and `LimitValueSize`: `0`, meaning unlimited.
## Safe Body Dumping
- Body dumping is opt-in with `IsBodyDump: true` because it can capture PII, tokens, and secrets.
- Prefer `BodySkipper` to exclude sensitive endpoints, compressed bodies, uploads, auth payloads, or large responses.
- `BodySkipper` only runs when `IsBodyDump` is true and returns `(skipReqBody, skipRespBody)`.
```go
BodySkipper: func(c *echo.Context) (bool, bool) {
if c.Request().Header.Get("Content-Encoding") == "gzip" {
return true, true
}
… 作者原文负责流程事实;流狐只索引当前章节、要点、文件与命令。
章节 -> Essentials → Basic Usage → Config Defaults → Safe Body Dumping → Attribute Limits → Do Not Assume
要点 -> - Import path must include /v2: github.com/adlandh/echo-otel-middleware/v2. · - TracerProvider: otel.GetTracerProvider(). · - Body dumping is opt-in with IsBodyDump: true because it can capture PII, tokens, and secrets. · - LimitNameSize and LimitValueSize are byte-based, not rune-based. · - Metrics are not implemented in this middleware; do not add or document metrics unless explicitly requested.
文件/命令 -> github.com/adlandh/echo-otel-middleware/v2 · /v2 · echootelmiddleware · github.com/labstack/echo/v5 · echo.Context · Middleware() · MiddlewareWithConfig · TracerProvider
内容 SHA-256 -> ebb54b593f29
原文结构
适用与边界
原文中的明确线索
github.com/adlandh/echo-otel-middleware/v2、/v2、echootelmiddleware、github.com/labstack/echo/v5、echo.Context、Middleware()、MiddlewareWithConfig、TracerProvider