mirror of
https://github.com/graphql-hive/console
synced 2026-05-23 17:18:23 +00:00
Collect transactions for Hive CLI and Hive App
This commit is contained in:
parent
3e3bb87ff9
commit
9b6a6aed5e
1 changed files with 5 additions and 13 deletions
|
|
@ -75,13 +75,6 @@ function useNoIntrospection(params: { signature: string }): Plugin<{ req: Fastif
|
|||
};
|
||||
}
|
||||
|
||||
const sampleRatePerOperationName: {
|
||||
[key: string]: number;
|
||||
} = {
|
||||
myTokenInfo: 0.1, // collect ~10% of requests
|
||||
schemaPublish: 0.1,
|
||||
};
|
||||
|
||||
export const graphqlHandler = (options: GraphQLHandlerOptions): RouteHandlerMethod => {
|
||||
const server = createServer<Context>({
|
||||
plugins: [
|
||||
|
|
@ -109,13 +102,12 @@ export const graphqlHandler = (options: GraphQLHandlerOptions): RouteHandlerMeth
|
|||
configureScope(args, scope) {
|
||||
const transaction = scope.getTransaction();
|
||||
|
||||
// Reduce the number of transactions to avoid overloading the Sentry
|
||||
if (transaction && args.operationName && sampleRatePerOperationName[args.operationName]) {
|
||||
const shouldBeDropped = Math.random() > sampleRatePerOperationName[args.operationName];
|
||||
// Reduce the number of transactions to avoid overloading Sentry
|
||||
const ctx = args.contextValue as Context;
|
||||
const graphqlClientName = ctx.headers['graphql-client-name'];
|
||||
|
||||
if (shouldBeDropped) {
|
||||
transaction.sampled = false;
|
||||
}
|
||||
if (transaction && graphqlClientName !== 'Hive CLI' && graphqlClientName !== 'Hive App') {
|
||||
transaction.sampled = false;
|
||||
}
|
||||
|
||||
scope.setContext('Extra Info', {
|
||||
|
|
|
|||
Loading…
Reference in a new issue