d09bce7267
* Moves speckle-server, webhook-service, fileimport-service, monitoring-deployment, and test-deployment images to Distroless. Partially addresses https://github.com/specklesystems/speckle-server/issues/883 * preview-service uses similar image for building and production stages * explicitly include chromium-common dependency to prevent error in preview service * Bump chromium packages due to package versions not being found * Handle machine-id in distroless - distroless has no shell, so node-machine-id will result in an error - this commit introduces error handling and defaults to a uuid v4 in the case of an error * Update binary location for readiness and liveness checks to match the binary location in Distroless * Allow node binary path to be set as environment variable in fileimport service
45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
/* istanbul ignore file */
|
|
const Sentry = require('@sentry/node')
|
|
const Tracing = require('@sentry/tracing')
|
|
const { getMachineId } = require('./machineId')
|
|
const prometheusClient = require('prom-client')
|
|
|
|
const { createRequestDurationMiddleware } = require('./expressMonitoring')
|
|
const { initKnexPrometheusMetrics } = require('./knexMonitoring')
|
|
|
|
let prometheusInitialized = false
|
|
|
|
module.exports = function (app) {
|
|
const id = getMachineId()
|
|
|
|
if (!prometheusInitialized) {
|
|
prometheusInitialized = true
|
|
prometheusClient.register.clear()
|
|
prometheusClient.register.setDefaultLabels({
|
|
project: 'speckle-server',
|
|
app: 'server'
|
|
})
|
|
prometheusClient.collectDefaultMetrics()
|
|
|
|
initKnexPrometheusMetrics()
|
|
}
|
|
|
|
app.use(createRequestDurationMiddleware())
|
|
|
|
if (process.env.DISABLE_TRACING !== 'true' && process.env.SENTRY_DSN) {
|
|
Sentry.setUser({ id })
|
|
|
|
Sentry.init({
|
|
dsn: process.env.SENTRY_DSN,
|
|
integrations: [
|
|
new Sentry.Integrations.Http({ tracing: true }),
|
|
new Tracing.Integrations.Express({ app })
|
|
],
|
|
tracesSampleRate: 0.1
|
|
})
|
|
|
|
app.use(Sentry.Handlers.requestHandler())
|
|
app.use(Sentry.Handlers.tracingHandler())
|
|
}
|
|
}
|