elastic / elastic/apm-agent-python

Refactor serialization mechanism to be extendable

未关闭
#182 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
agent-python
主要语言
Python
星标
431
派生
239
平均合并
5 天 10 小时
30 天内合并 PR
7

描述

At the moment, our serialization code is just a really long `if-elif-elif-...` block: https://github.com/elastic/apm-agent-python/blob/ee45d21ff43be495089a005863b7f6af0707fe34/elasticapm/utils/encoding.py#L85-L138.

This has several drawbacks:
* it's not extendable (we e.g. might want to serialize Django `QuerySet` objects in a sane way that doesn't evaluate the queryset unnecessarily, but only if Django is installed)
* it's brittle
* it's hard to read
* ideally, serialization would also include shortening of values, which is hard to do in its current state

One option could be to have a registry, to which transformers can register themselves, together with a list of supported types for that transformer.

贡献指南

打开贡献指南

调研方向

首先阅读 elasticapm/utils/encoding.py 中第 85-138 行附近的内容,目前序列化是在那里以一长串条件链的形式实现的。将提议的 registry 方案与可选处理 Django QuerySet 以及缩短值的需求进行比较。当序列化机制具备可扩展性、更加稳健,并且在安装 Django 时避免不必要地对 QuerySet 求值,即可视为完成。

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

评估

技术栈
django, python
领域
backend
Issue 类型
重构
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
基本清楚
新手友好度
30/100

把新 issue 发到你的邮箱

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