Skip to content

DOL-23: add optional OTLP log export - #6337

Open
Imccccc wants to merge 1 commit into
Wei-Shaw:mainfrom
Imccccc:feat/dol-23-otel-logs
Open

DOL-23: add optional OTLP log export#6337
Imccccc wants to merge 1 commit into
Wei-Shaw:mainfrom
Imccccc:feat/dol-23-otel-logs

Conversation

@Imccccc

@Imccccc Imccccc commented Aug 28, 2026

Copy link
Copy Markdown

Summary

  • 增加 multiSink,在保留现有 Postgres OpsSystemLogSink 的同时 tee 到可选的 OTLP logs sink;没有配置 endpoint 时返回原始单 sink,默认部署无额外日志路径和性能开销。
  • 使用 OpenTelemetry SDK 的异步 BatchProcessor 导出 LogRecord,支持 http/protobufgrpc,并把 request_id 等结构化字段保留为 attributes;Component / LoggerName 写入 instrumentation scope。
  • 在导出边界脱敏代理配置和账号邮箱,同时增强现有公共日志脱敏器,避免敏感信息进入 OTLP/OpenObserve、GCS 或 Postgres 日志索引。
  • 增加 Wire 生命周期管理,进程退出时 flush/shutdown exporter,并补充部署环境变量文档。

Configuration

设置 OTEL_EXPORTER_OTLP_ENDPOINTOTEL_EXPORTER_OTLP_LOGS_ENDPOINT 即启用;两者都为空时完全关闭。支持标准变量:

  • OTEL_EXPORTER_OTLP_PROTOCOL / OTEL_EXPORTER_OTLP_LOGS_PROTOCOLhttp/protobuf,默认;或 grpc
  • OTEL_EXPORTER_OTLP_HEADERS / OTEL_EXPORTER_OTLP_LOGS_HEADERS
  • OTEL_SERVICE_NAME(默认 sub2api
  • OTEL_RESOURCE_ATTRIBUTES 及 exporter 的 timeout、compression、TLS 等标准变量

本次只实现 logs,不包含 traces 或 metrics。

Verification

  • go test -tags=unit ./...
  • go test -tags=integration ./...
  • golangci-lint run --timeout=30m ./...(v2.13.0)
  • CGO_ENABLED=0 go build ./cmd/server

Related to #985 and #3904.

Closes DOL-23

@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA. ✅
Posted by the CLA Assistant Lite bot.

@Imccccc

Imccccc commented Aug 28, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant