[Enh]: Support OpenTelemetry logs export (OTLP)
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 52/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- csharp
- 领域
- cli, observability-sre
调研方向
从 src/Service/Program.cs 开始,跟踪现有的 runtime.telemetry.open-telemetry 配置和 dab add-telemetry 命令。检查相关 schema 和选项映射,然后验证 logs-enabled 默认关闭,CLI flag 复用现有的 endpoint、headers 和 protocol,并且现有的 trace、metric 和 logger 行为保持不变。
由索引模型根据 Issue 内容生成。
描述
Summary
Add an optional path for DAB's ILogger output to flow through the .NET OpenTelemetry SDK's logs pipeline and ship via OTLP, alongside the existing application-insights, azure-log-analytics, file, and console destinations.
Context
Per #2397, runtime.telemetry.open-telemetry was intentionally scoped to traces (ActivitySource) and metrics (Meter). The issue's framing "Serilog handles logging, while OpenTelemetry focuses on tracing and metrics" was accurate at the time: the .NET OpenTelemetry Logs API was experimental.
That's no longer the case. OpenTelemetry.Extensions.Logging and the OtlpLogExporter are stable in the .NET OpenTelemetry SDK (graduated in 1.5+). The ILoggingBuilder.AddOpenTelemetry() extension method is production-ready and is the canonical way modern .NET services emit logs to OTLP collectors. ASP.NET Core's own host builder supports it out of the box.
The result is a gap: DAB users who self-host on Kubernetes with a Grafana / Loki / Alloy / Tempo stack (or any non-Azure OTLP collector) have no first-class log destination. Stdout scraping by an external collector works but loses the structured ILogger scope / category metadata that flows naturally through the OTel logs pipeline.
Proposal
Add a logs-enabled sub-flag under the existing open-telemetry block:
{
"runtime": {
"telemetry": {
"open-telemetry": {
"enabled": true,
"endpoint": "http://otel-collector:4317",
"service-name": "dab",
"exporter-protocol": "grpc",
"logs-enabled": true // new, defaults to false
}
}
}
}
When logs-enabled: true, register an OpenTelemetry logs provider on builder.Logging that reuses the existing endpoint, headers, and exporter-protocol values. No new config fields, no schema disruption, no behavior change for existing users (default off).
Pseudocode in src/Service/Program.cs:
if (otelConfig.Enabled && otelConfig.LogsEnabled)
{
builder.Logging.AddOpenTelemetry(options =>
{
options.SetResourceBuilder(sharedResourceBuilder);
options.IncludeFormattedMessage = true;
options.IncludeScopes = true;
options.AddOtlpExporter(opt =>
{
opt.Endpoint = new Uri(otelConfig.Endpoint);
opt.Protocol = otelConfig.ExporterProtocol == "grpc"
? OtlpExportProtocol.Grpc
: OtlpExportProtocol.HttpProtobuf;
opt.Headers = otelConfig.Headers;
});
});
}
CLI flag in dab add-telemetry:
--otel-logs-enabled true|false
Why this is low-risk
- Additive. No change to traces / metrics / existing logger providers. Existing users see no behavior difference.
- Default off. Zero impact on the install-base until explicitly opted in.
- Reuses existing config surface. No new endpoint / headers / protocol fields — same connection params, three pipelines.
- Small footprint. ~30 lines of production code plus schema update plus a CLI option.
- Mirrors a pattern .NET teams ship in production today. The OTel SDK exposes traces / metrics / logs as a coherent three-signal builder; the missing logs piece is the only deviation here.
Validation
I run DAB on AKS behind a Grafana Alloy DaemonSet. I'm happy to test against a real OTLP gRPC receiver and post screenshots of DAB logs landing in Loki with full structured fields (scope_name, category, trace_id correlation with the existing OTel traces).
Offer
Happy to PR this if the team is open to the addition!
Closes the gap noted (implicitly) by the increasing number of users self-hosting DAB on non-Azure observability stacks; explicit framing of "Serilog vs OpenTelemetry" in #2397 predates the .NET Logs API going stable.
- 主要语言
- C#
- 星标
- 1.5k
- 派生
- 372
- 平均合并
- 9 天 1 小时
- 30 天内合并 PR
- 13
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Azure/data-api-builder 的其他 Issue
-
pgsql
难度 2/5 1-3 小时 新手友好度 68/100
Azure/data-api-builder#3598 ·
-
2.x cli mcp-server
难度 2/5 1-3 小时 新手友好度 68/100
Azure/data-api-builder#3576 ·
-
2.x health-endpoint
难度 2/5 1-3 小时 新手友好度 68/100
Azure/data-api-builder#3570 ·
-
2.x telemetry
难度 2/5 1-3 小时 新手友好度 68/100
Azure/data-api-builder#3564 ·
-
2.x telemetry
难度 2/5 1-3 小时 新手友好度 70/100
Azure/data-api-builder#3562 ·
查看 Azure/data-api-builder 的全部 Issue
相似的 Issue
-
bug needs response
难度 2/5 1-3 小时 新手友好度 82/100
Adyen/adyen-dotnet-api-library#1869 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
-
difficulty/starter 🚀 good first issue kind/bug platform/ios 🍎 project/non-ui ⚙️ triage/untriaged
难度 2/5 1-3 小时 新手友好度 88/100
unoplatform/uno#24650 ·
-
area-ai untriaged
难度 2/5 1-3 小时 新手友好度 78/100
dotnet/extensions#7783 ·
-
untriaged
难度 1/5 1 小时以内 新手友好度 88/100
dotnet/dotnet-api-docs#13095 ·