Skip to content

Commit

Permalink
add sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
Lms24 committed Oct 17, 2024
1 parent 011f05c commit 78c9d0f
Show file tree
Hide file tree
Showing 6 changed files with 657 additions and 13 deletions.
9 changes: 6 additions & 3 deletions api-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"private": true,
"license": "UNLICENSED",
"scripts": {
"build": "nest build",
"build": "nest build && yarn sentry:sourcemaps",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
Expand All @@ -20,12 +20,15 @@
"test:e2e": "jest --config ./test/jest-e2e.json",
"python-api:build": "docker build -t registry-api-server ../",
"python-api:start": "docker run -d -p 5031:5030 registry-api-server",
"python-api:stop": "docker stop $(docker ps -q --filter ancestor=registry-api-server)"
"python-api:stop": "docker stop $(docker ps -q --filter ancestor=registry-api-server)",
"sentry:sourcemaps": "sentry-cli sourcemaps inject --org sentry --project release-registry-nestjs ./dist && sentry-cli sourcemaps upload --org sentry --project release-registry-nestjs ./dist"
},
"dependencies": {
"@nestjs/common": "^10.0.0",
"@nestjs/core": "^10.0.0",
"@nestjs/platform-express": "^10.0.0",
"@sentry/cli": "^2.37.0",
"@sentry/nestjs": "^8.34.0",
"reflect-metadata": "^0.2.0",
"rxjs": "^7.8.1"
},
Expand Down Expand Up @@ -69,4 +72,4 @@
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
}
10 changes: 7 additions & 3 deletions api-node/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import { AppsController } from './apps/apps.controller';
import { SdksController } from './sdks/sdks.controller';
import { AwsLambdaLayersController } from './aws-lambda-layers/aws-lambda-layers.controller';
import { RegistryService } from './common/registry.service';

import { SentryGlobalFilter, SentryModule } from '@sentry/nestjs/setup';
import { APP_FILTER } from '@nestjs/core';
@Module({
imports: [],
imports: [SentryModule.forRoot()],
controllers: [
HealthCheckController,
PackagesController,
Expand All @@ -17,6 +18,9 @@ import { RegistryService } from './common/registry.service';
SdksController,
AwsLambdaLayersController,
],
providers: [RegistryService],
providers: [
RegistryService,
{ provide: APP_FILTER, useClass: SentryGlobalFilter },
],
})
export class AppModule {}
12 changes: 12 additions & 0 deletions api-node/src/instrument.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as Sentry from '@sentry/nestjs';

// eslint-disable-next-line @typescript-eslint/no-require-imports
const packageJson = require('../package.json');

Sentry.init({
dsn: process.env.SENTRY_DSN,
release: packageJson.version,
environment: process.env.NODE_ENV || 'development',
tracesSampleRate: 1.0,
debug: true,
});
2 changes: 2 additions & 0 deletions api-node/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import './instrument';

import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';

Expand Down
4 changes: 3 additions & 1 deletion api-node/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"noImplicitAny": false,
"strictBindCallApply": false,
"forceConsistentCasingInFileNames": false,
"noFallthroughCasesInSwitch": false
"noFallthroughCasesInSwitch": false,
"inlineSources": true,
"sourceRoot": "/"
}
}
Loading

0 comments on commit 78c9d0f

Please sign in to comment.