OTel: add trace_flags to JSON log records so unsampled trace ids are recognizable
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 82/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- python
调研方向
先阅读 otel.trace_fields() 以及测试 test_trace_fields_inside_span 和 test_json_mode_adds_trace_ids;issue 还提到了 docs/api-reference/observability.md。检查 span context 如何提供 trace flags,然后运行相关测试。完成标准是:JSON 日志记录包含两位小写的 W3C flag,ALWAYS_OFF 测试期望 "00",并且 Logs 文档解释该值。
由索引模型根据 Issue 内容生成。
描述
Follow-up to #7668 (fixes #6903).
Problem
#7668 adds trace_id and span_id to JSON log records written inside an OpenTelemetry span. It does not add trace_flags.
A span that is not sampled still has a valid span context. So its log records get ids, but the tracing backend never stores that trace. A reader then searches for a trace that does not exist, and the log line gives no sign of why.
This case is normal in Reflex. The event span uses a parent-based sampler by default, so a client traceparent with the sampled flag off gives an unsampled span. A ratio sampler (OTEL_TRACES_SAMPLER=traceidratio) does the same for most spans.
Repro
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.sampling import ALWAYS_OFF
from reflex_base import otel
otel.enable(tracer_provider=TracerProvider(sampler=ALWAYS_OFF))
with otel._tracer.start_as_current_span("x") as span:
print(span.is_recording()) # False
print(otel.trace_fields()) # {'trace_id': '...', 'span_id': '...'}, no sampled flag
Proposed change
Add trace_flags to otel.trace_fields(), as the OpenTelemetry spec "Trace Context in Non-OTLP Log Formats" recommends. Use the W3C format: two lowercase hex digits, "01" when sampled, "00" when not.
"trace_flags": f"{span_context.trace_flags:02x}",
- Extend
test_trace_fields_inside_spanandtest_json_mode_adds_trace_idsto check the field. - Add a test with an
ALWAYS_OFFsampler that expects"trace_flags": "00". - Add the field to the "Logs" section of
docs/api-reference/observability.md, with one sentence on what"00"means.
- 主要语言
- Python
- 星标
- 29k
- 派生
- 1.8k
- 平均合并
- 2 天 22 小时
- 30 天内合并 PR
- 143
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
reflex-dev/reflex 的其他 Issue
-
Operations on a list[T] | None var throw when the value is None可能已有人在做 @masenf 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
reflex-dev/reflex#7826 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
reflex-dev/reflex#7825 · 1 条评论 ·
维护者通常 1 天内回复
-
PropsBase nested serialization applies parent include/exclude filters to child fields可能已有人在做 @harsh21234i 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
reflex-dev/reflex#7787 · 1 条评论 ·
维护者通常 1 天内回复
-
0.9.12 changelog follow-ups: the #7132 "_get_was_touched" entry describes unreachable behaviour, #7115's hasattr/getattr change is undocumented, #7131's wording可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
reflex-dev/reflex#7260 · 2 条评论 ·
维护者通常 1 天内回复
-
ClientStateVar: a component that mounts while the value is non-default never re-renders on the push back to the default可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
reflex-dev/reflex#6823 · 1 条评论 ·
维护者通常 1 天内回复
查看 reflex-dev/reflex 的全部 Issue
相似的 Issue
-
[Bug]: graphify query loads every language extractor just for _file_stem (about 34 ms per call)可能已有人在做 @rohit-jsfreaky 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
Graphify-Labs/graphify#5160 · 1 条评论 ·
维护者通常 2 天内回复
-
Variable declared without a value suppresses ${VAR:-default} expansion可能已有人在做 @Omarinho12345 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 85/100
theskumar/python-dotenv#750 ·
维护者通常 12 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 2/5 1-3 小时 新手友好度 78/100
UKGovernmentBEIS/control-arena#947 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
jasonacox/Powerwall-Dashboard#897 · 1 条评论 ·
维护者通常 1 天内回复