Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Enh]: Support OpenTelemetry logs export (OTLP)

未关闭
#3,643 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
52/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
冷清
技术栈
csharp

调研方向

从 src/Service/Program.cs 开始,跟踪现有的 runtime.telemetry.open-telemetry 配置和 dab add-telemetry 命令。检查相关 schema 和选项映射,然后验证 logs-enabled 默认关闭,CLI flag 复用现有的 endpoint、headers 和 protocol,并且现有的 trace、metric 和 logger 行为保持不变。

由索引模型根据 Issue 内容生成。

描述

cri needs discussion telemetry

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Azure/data-api-builder 的其他 Issue

查看 Azure/data-api-builder 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。