Issues with OTLP exporter with None values
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- python
调研方向
从 exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/init.py 中的 OTLP encoder 开始,跟踪 CeleryInstrumentor() 如何导出 task results 和 log values。使用提供的 Celery task 复现值为 None 的 result,然后验证 exporter 能够在没有 warnings 或 errors 的情况下处理它,并确认 SDK/API 不兼容问题已得到解决或已明确分离。
由索引模型根据 Issue 内容生成。
描述
Describe your environment
OS: Ubuntu
Python version: 3.12
SDK version: opentelemetry-sdk==1.36.0
API version: opentelemetry-api==1.36.0
Celery: opentelemetry-instrumentation-celery==0.57b0
What happened?
I am using CeleryInstrumentor() to get logs of celery into Grafana/Loki
First of the issues I get is that I see an incompatibility with the latest opentelemetry-sdk (1.41) version with opentelemetry-api (it does not allow me to install).
Second issue is with None values in the celery results exported to Grafana. I am seeing a warning like:
Invalid type <class 'dict'> of value {'id': 'b2f12a15-b57d-4e9a-a439-345a323e7c1b', 'name': 'app.tasks.tasks.say_hello', 'args': '()', 'kwargs': '{}', 'eta': None}
I noticed that in opentelemetry 1.41 you already updated the encoder: https://github.com/open-telemetry/opentelemetry-python/blob/main/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/__init__.py
But I am uncapable of setting allow_null to True for CeleryInstrumentor().
Steps to Reproduce
Setup CeleryInstrumentor() and have a task that retuns None values somewhere.
In my case:
# API route to trigger the task
@bp.route('/long_task', methods=['GET'])
def trigger_task():
task = say_hello.delay()
return jsonify({"task_id": task.id, "status": "Task has been submitted"}), 202
@celery.task
def say_hello():
sleep(10)
logger.info(f"[HEALTHCHECK] say_hello config_class={type(Config).__name__} service_name={Config.SERVICE_NAME}")
return "Hello, World!"
I also have a custom logger setup, which might be the one causing None to get inserted over the values.
Expected Result
No errors or warning escalated to Loki/Grafana
Actual Result
I monkey patched _encode_key_value:
def _encode_key_value(key: str, value: _Any, allow_null: bool = False) -> _PB2KeyValue:
if value is None:
return _PB2KeyValue(key=key, value=_encode_value(value, allow_null=True))
return _PB2KeyValue(key=key, value=_encode_value(value, allow_null=allow_null))
Additional context
I am unsure if this is a proper solution, I guess not and that it should be configured and CeleryInstrumentor some setting that allows to pass the allow_none=True, but I do not know how to do it.
Would you like to implement a fix?
None
Tip
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.
- 主要语言
- Python
- 星标
- 2.7k
- 派生
- 1.1k
- 平均合并
- 3 天 12 小时
- 30 天内合并 PR
- 16
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
open-telemetry/opentelemetry-python 的其他 Issue
-
References to Archived open-telemetry/oteps可能已有人在做 @RjyavardhanSingh 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
open-telemetry/opentelemetry-python#5984 · 1 条评论 ·
维护者通常 2 天内回复
-
Autoconfiguration rejects OTEL_EXPORTER_OTLP_PROTOCOL=http/json可能已有人在做 @WendeelMarinho 于 2 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 82/100
open-telemetry/opentelemetry-python#5981 ·
维护者通常 2 天内回复
-
MeterProvider raises ValueError on empty or uppercase OTEL_METRICS_EXEMPLAR_FILTER可能已有人在做 @bishalde 于 8 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 83/100
open-telemetry/opentelemetry-python#5948 · 3 条评论 ·
维护者通常 2 天内回复
-
W3CBaggagePropagator drops a list-member over 4096 bytes that W3C Baggage requires it to propagate可能已有人在做 @codedbyadiiii 于 20 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
open-telemetry/opentelemetry-python#5913 ·
维护者通常 2 天内回复
-
otel.sdk.processor.{span,log}.queue.capacity uses synchronous UpDownCounter recorded once in __init__可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
open-telemetry/opentelemetry-python#5891 ·
维护者通常 2 天内回复
查看 open-telemetry/opentelemetry-python 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
bug improve content
难度 1/5 1 小时以内 新手友好度 92/100
opensafely/documentation#2102 ·
维护者通常 1 天内回复
-
difficulty:1 documentation
难度 2/5 1-3 小时 新手友好度 82/100
MakazhanAlpamys/Soup#3533 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
onyx-dot-app/onyx#18730 ·
维护者通常 1 天内回复