`JSON` attributes do not show up as valid json in event attributes
还没有人认领这个 Issue。
评估
调研方向
先从报告中展示的 handler 的 emit 方法和 HTTPLogItem 构造开始,然后跟踪 log_ctx 如何通过 LogsApi.submit_log 进行序列化。使用 x_request_body 重现 logger.debug 示例,并验证已提交事件的属性保留有效的 JSON 对象值,而不是显示为字符串。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
A clear and concise description of what the bug is.
When a valid json is passed as value of a custom event atrribute, In logs it is show as a string and not a json object
To Reproduce
# in the handler
def emit(self, record):
env = os.getenv("APP_ENV", "local")
log_ctx: LogCtxDict = record.__dict__.get("log_ctx", {})
tags_dict = log_ctx.pop('tags', {})
tags = [f"{k}:{v}" for k, v in tags_dict.items()]
tags.append("env:{}".format(env))
tags_merged = ",".join(tags)
body = HTTPLog(
[
HTTPLogItem(
ddsource="python",
ddtags=tags_merged,
hostname="vv-anyscale-ray-aps1",
message=self.format(record),
service="vv-ap-thumbnails-v1-{}-service".format(env),
timestamp=str(datetime.fromtimestamp(record.created).astimezone().timestamp()),
level=record.levelname.lower(),
**record.__dict__.get("log_ctx", {})
)
]
)
try:
with ApiClient(self.dd_configuration) as api_client:
resp = LogsApi(api_client).submit_log(content_encoding=ContentEncoding.GZIP, body=body)
if "errors" in resp:
self.handleError(record)
except (Exception, ):
self.handleError(record)
logger.debug(
"Test debug log",
log_ctx={
"x_request_body": json.dumps({"clip_id": "66abc57369bbe0000782ef42"}),
}
)
Expected behavior
A clear and concise description of what you expected to happen.
The object should be consumed and shown as json,
Screenshots
If applicable, add screenshots to help explain your problem.
Environment and Versions (please complete the following information):
A clear and precise description of your setup:
$ poetry show datadog-api-client
name : datadog-api-client
version : 2.27.0
description : Collection of all Datadog Public endpoints
dependencies
- certifi *
- python-dateutil *
- typing-extensions >=4.0.0
- urllib3 >=1.15
for logs parsing default python pipleline is used
- 主要语言
- Python
- 星标
- 166
- 派生
- 55
- 平均合并
- 2 天 17 小时
- 30 天内合并 PR
- 73
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
DataDog/datadog-api-client-python 的其他 Issue
-
stale
难度 1/5 1-3 小时 新手友好度 72/100
DataDog/datadog-api-client-python#3535 · 1 条评论 ·
-
kind/bug stale
难度 3/5 1-2 天 新手友好度 66/100
DataDog/datadog-api-client-python#3717 · 3 条评论 ·
-
kind/bug stale
难度 3/5 1-2 天 新手友好度 75/100
DataDog/datadog-api-client-python#3656 · 1 条评论 ·
-
kind/bug stale
难度 3/5 1-2 天 新手友好度 38/100
DataDog/datadog-api-client-python#3120 · 1 条评论 ·
-
stale
难度 3/5 1-2 天 新手友好度 45/100
DataDog/datadog-api-client-python#2986 · 1 条评论 ·
查看 DataDog/datadog-api-client-python 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
anthropics/skills#1811 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
speaches-ai/speaches#678 ·
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
datalayer/mcp-compose#42 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
conda-forge/spacy-feedstock#177 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
UKGovernmentBEIS/inspect_evals#2523 ·