Skip to content

Commit

Permalink
update sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
swantzter committed Jul 2, 2024
1 parent 35d6b0f commit faa8824
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 90 deletions.
16 changes: 1 addition & 15 deletions src/apollo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as Sentry from '@sentry/node'
import { ApolloServer, type BaseContext } from '@apollo/server'
import { ApolloServerPluginDrainHttpServer } from '@apollo/server/plugin/drainHttpServer'
import { expressMiddleware, type ExpressContextFunctionArgument } from '@apollo/server/express4'
Expand All @@ -9,10 +8,9 @@ import { makeExecutableSchema } from '@graphql-tools/schema'
import type { Logger } from 'pino'
import type { Server } from 'http'

import { GCP_PROJECT, SENTRY_DSN } from './config'
import { GCP_PROJECT } from './config'
import typeDefs from './schema'
import { rootResolver as resolvers } from './resolvers/rootResolver'
import sentryPlugin from './plugins/sentry'
import loggingPlugin from './plugins/logging'
import {
type CategoryDataSource,
Expand Down Expand Up @@ -49,18 +47,6 @@ export async function initApollo (httpServer: Server) {
loggingPlugin
]

if (SENTRY_DSN) {
logger.info('Sentry enabled')
Sentry.init({
dsn: SENTRY_DSN,
integrations: [
new Sentry.Integrations.Http({ tracing: true })
],
tracesSampleRate: 1.0
})
plugins.push(sentryPlugin)
}

const schema = makeExecutableSchema({ typeDefs, resolvers })
const cache = new InMemoryLRUCache()

Expand Down
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import './instrument'
import { PORT } from './config'
import { initApollo } from './apollo'
import { logger } from './services/logger'
import express from 'express'
import cors from 'cors'
import http from 'http'
import bodyParser from 'body-parser'
import { setupExpressErrorHandler } from '@sentry/node'

const app = express()
const httpServer = http.createServer(app)
Expand All @@ -29,6 +31,8 @@ initApollo(httpServer).then(async middleware => {
app.use('/graphql', bodyParser.json(), middleware)
app.use('/.well-known/apollo/server-health', (req, res) => { res.status(200).json({ status: 'pass' }) })

setupExpressErrorHandler(app)

await new Promise<void>(resolve => httpServer.listen({ port: PORT }, resolve))
logger.info(`Server ready at http://localhost:${PORT}`)
})
Expand Down
75 changes: 0 additions & 75 deletions src/plugins/sentry.ts

This file was deleted.

0 comments on commit faa8824

Please sign in to comment.