Add graphql_client_name tag and drop calls from Hive Client (sentry) (#415)

This commit is contained in:
Kamil Kisiela 2022-09-28 15:14:45 +02:00 committed by GitHub
parent 005c012cfd
commit 784f0c0251
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 11 deletions

View file

@ -104,12 +104,12 @@ export const graphqlHandler = (options: GraphQLHandlerOptions): RouteHandlerMeth
// Reduce the number of transactions to avoid overloading Sentry
const ctx = args.contextValue as Context;
const graphqlClientName = Array.isArray(ctx.headers['graphql-client-name'])
? ctx.headers['graphql-client-name'][0]
: ctx.headers['graphql-client-name'];
const clientNameHeaderValue = ctx.req.headers['graphql-client-name'];
const clientName = Array.isArray(clientNameHeaderValue) ? clientNameHeaderValue[0] : clientNameHeaderValue;
if (transaction && graphqlClientName !== 'Hive CLI' && graphqlClientName !== 'Hive App') {
transaction.sampled = false;
if (transaction) {
transaction.setTag('graphql_client_name', clientName);
transaction.sampled = clientName !== 'Hive Client';
}
scope.setContext('Extra Info', {
@ -117,15 +117,17 @@ export const graphqlHandler = (options: GraphQLHandlerOptions): RouteHandlerMeth
operationName: args.operationName,
operation: print(args.document),
userId: extractUserId(args.contextValue as any),
graphqlClientName,
});
},
trackResolvers: false,
appendTags: ({ contextValue }) => {
const supertokens_user_id = extractUserId(contextValue as any);
const request_id = cleanRequestId((contextValue as any).req.headers['x-request-id']);
const request_id = cleanRequestId((contextValue as Context).req.headers['x-request-id']);
return { supertokens_user_id, request_id };
return {
supertokens_user_id,
request_id,
};
},
skip(args) {
// It's the readiness check

View file

@ -36,9 +36,6 @@ export async function main() {
environment: process.env.ENVIRONMENT,
dsn: process.env.SENTRY_DSN,
tracesSampleRate: 1,
tracesSampler() {
return 1;
},
release: process.env.RELEASE || 'local',
integrations: [
new Sentry.Integrations.Http({ tracing: true }),