GQL
GQL GraphQL client integration
The GQL integration allows you to monitor all GraphQL requests that your Python application makes using the gql library. Specifically, this integration reports every TransportQueryError to Sentry and provides additional context including:
- The URL the request was made to
- The GraphQL query which caused the error
- The errorsinformation that the GraphQL server returns
Make sure you have the latest version of the Sentry SDK installed:
pip install "sentry-sdk"
If you have the gql package in your dependencies, the GQL integration will be enabled automatically when you initialize the Sentry SDK.
import sentry_sdk
sentry_sdk.init(
    dsn="https://examplePublicKey@o0.ingest.sentry.io/0example-org / example-project",
    # Add data like request headers and IP for users, if applicable;
    # see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
    send_default_pii=True,
    #  performance
    # Set traces_sample_rate to 1.0 to capture 100%
    # of transactions for tracing.
    traces_sample_rate=1.0,
    #  performance
    #  profiling
    # To collect profiles for all profile sessions,
    # set `profile_session_sample_rate` to 1.0.
    profile_session_sample_rate=1.0,
    # Profiles will be automatically collected while
    # there is an active span.
    profile_lifecycle="trace",
    #  profiling
    #  logs
    # Enable logs to be sent to Sentry
    enable_logs=True,
    #  logs
)
To ensure data privacy, the SDK avoids sending any information that may potentially contain personally identifiable information (PII) by default. See the docs for the send_default_pii flag for more information.
For the GQL integration, this policy means that the SDK doesn't send the GraphQL queries and the errors information that the GraphQL server returns, unless you override the default configuration via the send_default_pii flag.
Before enabling the send_default_pii flag, ensure you've configured Sentry's sensitive data scrubbing tools to scrub all PII.
To have Sentry record the GraphQL queries and the errors information returned by the GraphQL server, add the following to your SDK init:
sentry_sdk.init(
    # ...
    # Add data like request headers and IP for users, if applicable;
    # see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
    send_default_pii=True,
)
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").