mirumee/ariadne

Make it possible to exempt some resolvers from tracing

开放

#859 创建于 2022年5月3日

 (5 条评论) (1 个反应) (0 位负责人)Python (195 个派生)batch import
enhancementhelp wantedto do

仓库指标

星标
 (2,342 个星标)
PR 合并指标
 (平均合并 12天) (30 天内合并 3 个 PR)

描述

The default behavior of only tracing custom resolvers is great 95% of the time, however there is a case for not to trace certain custom resolvers as well.

We have a few simple custom resolvers that can be called up to a couple thousand times per request where the tracing overhead becomes significant. Also, in our case they don't do meaningful work that would warrant tracing them.

Right now I see two ways to implement a workaround in our code-base without touching ariadne itself:

  1. Monkey-patch ariadne.contrib.tracing.should_trace function
  2. Add _ariadne_alias_resolver attribute to our own resolvers, disguising them as alias resolvers which are already exempt fro tracing.
  3. Extend the tracing extensions in our code to do the filtering.

The first two approaches are brittle and can break upon any update to ariadne. We can go forward using the third approach but we think it'd make sense to add this functionality in ariadne itself.

I'd like to contribute support for this functionality in ariadne if you accept my reasoning for the need of it. My plan is to add a filter callable to the tracing extensions that can look-up the field in a block-list or perform any other custom logic. An even less intrusive change could also be just adding a should_trace method in the tracing extensions that can be overridden in a subclass, instead of using a non-member function.

贡献者指南