Missing parent trace activities (spans) when switching context between SDK and CLI

未关闭
#2,803 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
csharp
领域
observability

调研方向

Start in dotnet/src/Telemetry.cs at RestoreTraceContext and trace how the created Activity becomes the parent for tool activities. Compare that behavior with the ActivitySource and github.copilot source details mentioned in the issue, then verify that the resulting trace tree preserves the external_tool parent and sampled child spans when switching between SDK and CLI.

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

描述

bug

We are using Copilot SDK for .NET and it seems like the thinking behind RestoreTraceContext (this) is not entirely correct. It creates a new Activity without the ActivitySource, which, indeed, prevents it from being sampled, but it still carries its own id (span id), which is then used as a parent span id for all children activities. So in the trace tree (In Grafana, for example) we see unparented spans from the tool implementations, which I think should be parented under external_tool spans from the Copilot CLI:

Image

the GET span (id d2c10abb001cb97a) has parent span id set to cabcf362cbf15a7a (which is nowhere to be found), where as external_tool span has an id of 2cd84acd8fb4e994. So, I think, the tree is:

external_tool (2cd84acd8fb4e994, from CLI)
 \ copilot.tool_handler (cabcf362cbf15a7a, from SDK) <--- "invisible activity"
    \ GET (d2c10abb001cb97a, from our tool code)

Why don't we just emit this span properly from ActivitySource (maybe matching SourceName/default github.copilot)?

I also think a similar problem exists in the CLI itself, because transitioning from SDK to CLI also leaves all "top-level" CLI spans unparented. CLI code doesn't seem to be open source, so I can't confirm, but my gut feeling is that a similar approach was used there in CLI, where it creates one span and doesn't attach it to a source that is being sampled/exported, so it never gets collected, leaving all other CLI spans unparented. 😞

主要语言
Java
星标
10.7k
派生
1.5k
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

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

github/copilot-sdk 的其他 Issue

查看 github/copilot-sdk 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

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