This plugin collects errors and performance tracing for your execution flow, and reports it to [Sentry](https://sentry.io).
npm install @envelop/sentry@envelop/sentryThis plugin collects errors and performance tracing for your execution flow, and reports it to
Sentry.
This is how it looks like in Sentry for error tracking:
> The operation name, document, variables are collected on errors, and the breadcrumbs that led to
> the error. You can also add any custom values that you need.
And for performance tracking:
> You can get information about each resolver (including field and type names), it's execution time
> and arguments. Also, in case of an error, the performance log and info are attached automatically
> to the reported Sentry error.
``sh`
yarn add @sentry/node @sentry/tracing @envelop/sentry
1. Start by creating an account and a project in https://sentry.io
2. Follow the instructions to setup your Sentry instance in your application.
3. Setup Sentry global instance configuration.
4. Setup the Envelop plugin.
`ts
import { execute, parse, specifiedRules, subscribe, validate } from 'graphql'
import { envelop, useEngine } from '@envelop/core'
import { useSentry } from '@envelop/sentry'
const getEnveloped = envelop({
plugins: [
useEngine({ parse, validate, specifiedRules, execute, subscribe }),
// ... other plugins ...
useSentry({
includeRawResult: false, // set to true in order to include the execution result in the metadata collectedtrue
includeResolverArgs: false, // set to in order to include the args passed to resolverstrue
includeExecuteVariables: false, // set to in order to include the operation variables values`
appendTags: args => {}, // if you wish to add custom "tags" to the Sentry transaction created per operation
configureScope: (args, scope) => {}, // if you wish to modify the Sentry scope
skip: executionArgs => {} // if you wish to modify the skip specific operations
})
]
})
- forceTransaction (default: true) - Force the creation of a new transaction for every GraphQL
Operation. By default, Sentry mange the creation of transactions automatically. By enabling this
option, you can ensure that the GraphQL execution pipeline is always wrapped in its own
transaction.
- renameTransaction (default: false) - Renames Transaction.includeRawResult
- (default: false) - Adds result of each resolver and operation to Span's dataincludeExecuteVariables
(available under "result")
- (default: false) - Adds operation's variables to a Scope (only in caseappendTags
of errors)
- - See example above. Allow you to manipulate the tags reports on the SentryconfigureScope
transaction.
- - See example above. Allow you to manipulate the tags reports on the SentrytransactionName
transaction.
- (default: operation name) - Produces a name of Transaction (only whentraceparentData
"renameTransaction" or "startTransaction" are enabled) and description of created Span.
- (default: {}) - Adds tracing data to be sent to Sentry - this includesoperationName
traceId, parentId and more.
- - Produces a "op" (operation) of created Span.skip
- (default: none) - Produces a "op" (operation) of created Span.skipError
- (default: ignored GraphQLError) - Indicates whether or not to skip Sentry exceptionGraphQLError
reporting for a given error. By default, this plugin skips all errors and does noteventIdKey
report it to Sentry.
- (default: 'sentryEventId') - The key in the error's extensions field used to exposenull` to disable.
the generated Sentry event id. Set to