sikanhe / apollo-tracing-elixir

Apollo Tracing middleware for Absinthe
114 stars 8 forks source link

Conditional Tracing #11

Open benwilson512 opened 6 years ago

benwilson512 commented 6 years ago

Because tracing shows up in the return value, there should probably be a good way to tracing on or off. If you're testing your API for example you don't want to have to be dropping the extensions key from the result all the time.

It may also be a valuable production flag if for some reason things are going weirdly and tracing is causing a performance issue. It may be enough to add a simple application environment variable.

stephenmoloney commented 6 years ago

Not sure how this would be tackled or exactly how it would work exactly but I was thinking:

Maybe it could be a plug option that would add a flag to the :absinthe context.... something like apollo_tracing: :on or apollo_tracing: :off.. Then maybe the ApolloTracing.Middleware.call/2 function could pick that up out of the resolution context.

stephenmoloney commented 6 years ago

Ok, it's just as easy to remove the line pipeline: {ApolloTracing.Pipeline, :plug}, but this will not work on version 0.2.0, only on master branch.

Only works on master because errors arise in the middleware which is expecting the apollo_tracing flag. This is fixed by @benwilson512 PR.

So long story short, simply removing the line pipeline: {ApolloTracing.Pipeline, :plug}, will deactivate tracing... which is pretty much good enough for me.. it would be easy to create a configuration in your own app to include or exclude that line.