VBT.Absinthe.Instrumentation (vbt v0.1.0) View Source

Instrumentation of absinthe queries.

This module is responsible for logging longer running GraphQL operations (queries and mutations). By default, each operation that takes longer than 100ms is logged, together with all of the resolvers that were invoked:

[warn]  spent 200ms in query { object1: object(id: 1) {id children {id children {id}}} object2: object(id: 2) {id children {id children {id}}} }
  -> 10ms in object1
  -> 20ms in object1.children
  -> 30ms in object1.children.0.children
  -> 40ms in object2
  -> 50ms in object2.children
  -> 60ms in object2.children.0.children
  -> 70ms in object2.children.1.children

You can change this threshold via set_long_operation_threshold/0. To avoid the noise in tests, add the following to your test_helper.exs:

VBT.Absinthe.Instrumentation.set_long_operation_threshold(:infinity)

In addition to logging, a telemetry event [:vbt, :graphql, :operation, :stop] is emitted for each query. You can attach to this event with :telemetry.attach/4. The event's measurement will contain the field :total for the total running time of the operation, and additional entries with keys representing field paths, and values representing corresponding times. All times are in microseconds. The metadata argument will contain the string representation of the query.

Link to this section Summary

Functions

Sets the threshold for long running operations.

Link to this section Functions

Link to this function

set_long_operation_threshold(duration_ms)

View Source

Specs

set_long_operation_threshold(non_neg_integer() | :infinity) :: :ok

Sets the threshold for long running operations.