elastic / apm-agent-python

https://www.elastic.co/guide/en/apm/agent/python/current/index.html
BSD 3-Clause "New" or "Revised" License
409 stars 214 forks source link

Refactor serialization mechanism to be extendable #182

Open beniwohli opened 6 years ago

beniwohli commented 6 years ago

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:

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

beniwohli commented 4 years ago

As reported in https://github.com/elastic/apm-agent-python/issues/691, if local variable collection is enabled for transactions, evaluating a Django queryset can lead to an infinite recursion.

kalemas commented 2 years ago

python agent fallback to repr() at moment, that is relevant for runtime environment but not useful much whenever you inspect local stack in apm kibana app, for some classes str() would tell more relevant information for post inspection. str() may be ambiguous but supposed to be human readable, and used for printing by default. I know there would be many questionable cases so i do not know how to resolve this without custom serializer.

added later: so point is that neither str() or repr() supposed to be used for post inspection in apm solutions.