From db703dfbfc56c82b47f46752fdd85b6ea3e49d9f Mon Sep 17 00:00:00 2001 From: gmbronco <83549293+gmbronco@users.noreply.github.com> Date: Tue, 10 Oct 2023 22:43:41 +0200 Subject: [PATCH] adding newRelic tracing to gql (#477) --- app.ts | 10 ++++++++++ package.json | 3 ++- yarn.lock | 5 +++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app.ts b/app.ts index fdc3805ce..65857658d 100644 --- a/app.ts +++ b/app.ts @@ -12,6 +12,8 @@ import { ApolloServerPluginLandingPageGraphQLPlayground, ApolloServerPluginUsageReporting, } from 'apollo-server-core'; +import { ApolloServerPlugin } from 'apollo-server-plugin-base'; +import createNewRelicPlugin from '@newrelic/apollo-server-plugin'; import { beethovenSchema } from './graphql_schema_generated_beethoven'; import { balancerSchema } from './graphql_schema_generated_balancer'; import { balancerResolvers, beethovenResolvers } from './app/gql/resolvers'; @@ -90,6 +92,14 @@ async function startServer() { }), sentryPlugin, ]; + + if (process.env.NODE_ENV !== 'local' && process.env.NEW_RELIC_APP_NAME) { + const newRelicPlugin = createNewRelicPlugin({}) + plugins.push( + newRelicPlugin, + ) + } + if (process.env.APOLLO_SCHEMA_REPORTING && process.env.APOLLO_SCHEMA_REPORTING === 'true') { plugins.push( ApolloServerPluginUsageReporting({ diff --git a/package.json b/package.json index c0ebfab63..46be68584 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "private": true, "scripts": { "start": "node -r newrelic dist/app.js", - "start:local": "ts-node -r dotenv/config app", + "start:local": "NEW_RELIC_ENABLED=false ts-node -r dotenv/config app", "watch": "concurrently \"nodemon app\" \"yarn generate --watch\"", "build": "tsc", "generate": "graphql-codegen --config codegen.yml -r dotenv/config", @@ -27,6 +27,7 @@ "@gnosis.pm/safe-core-sdk": "^1.2.0", "@graphql-tools/load-files": "^6.5.2", "@graphql-tools/merge": "^8.2.1", + "@newrelic/apollo-server-plugin": "^4.0.0", "@prisma/client": "^5.3.1", "@sanity/client": "^2.23.1", "@sentry/node": "^7.56.0", diff --git a/yarn.lock b/yarn.lock index 419bb486f..ff84e6362 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4128,6 +4128,11 @@ resolved "https://registry.yarnpkg.com/@n1ru4l/graphql-live-query/-/graphql-live-query-0.9.0.tgz#defaebdd31f625bee49e6745934f36312532b2bc" integrity sha512-BTpWy1e+FxN82RnLz4x1+JcEewVdfmUhV1C6/XYD5AjS7PQp9QFF7K8bCD6gzPTr2l+prvqOyVueQhFJxB1vfg== +"@newrelic/apollo-server-plugin@^4.0.0": + version "4.0.0" + resolved "https://registry.yarnpkg.com/@newrelic/apollo-server-plugin/-/apollo-server-plugin-4.0.0.tgz#32087e6a7939795cc0e7f55135420d977e9f7984" + integrity sha512-L3HMj+qnUs26QsEbLy4qDYEDYGKlJSaCDoZRrxiIj4rn6rs6hRAHw2mt6oEjwRdfUoF8diqiF6G/+yjhv57tWA== + "@newrelic/aws-sdk@^7.0.0": version "7.0.1" resolved "https://registry.yarnpkg.com/@newrelic/aws-sdk/-/aws-sdk-7.0.1.tgz#c4cc5ad8e33d79d3e8708d7908b66c06349329a4"