Skip to content

Commit

Permalink
adding newRelic tracing to gql
Browse files Browse the repository at this point in the history
  • Loading branch information
gmbronco committed Oct 10, 2023
1 parent 0fa01dd commit c7b47bd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -90,6 +92,14 @@ async function startServer() {
}),
sentryPlugin,
];

if (process.env.NODE_ENV !== 'local' && process.env.NEW_RELIC_APP_NAME) {
const newRelicPlugin = createNewRelicPlugin<ApolloServerPlugin>({})
plugins.push(
newRelicPlugin,
)
}

if (process.env.APOLLO_SCHEMA_REPORTING && process.env.APOLLO_SCHEMA_REPORTING === 'true') {
plugins.push(
ApolloServerPluginUsageReporting({
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit c7b47bd

Please sign in to comment.