Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TM-1526] Integrate Sentry reporting. #28

Open
wants to merge 1 commit into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ and main branches.
* Set up the new `main.ts` similarly to existing services.
* Make sure swagger docs and the `/health` endpoint are implemented
* Pick a default local port that is unique from other services
* Make sure the top of `main.ts` has these two lines:
```
// eslint-disable-next-line @nx/enforce-module-boundaries
import "../../../instrument-sentry";
```
* Add the `SentryModule` and `SentryGlobalFilter` to your main `app.module.ts`. See an existing service for an example.
* In your `.env` and `.env.local.sample`, add `_PORT` for the new service
* In `api-gateway-stack.ts`, add the new service and namespace to `V3_SERVICES`
* In your local web repo, follow directions in `README.md` for setting up a new service.
Expand Down
12 changes: 10 additions & 2 deletions apps/entity-service/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ import { CommonModule } from "@terramatch-microservices/common";
import { HealthModule } from "./health/health.module";
import { TreesController } from "./trees/trees.controller";
import { TreeService } from "./trees/tree.service";
import { SentryGlobalFilter, SentryModule } from "@sentry/nestjs/setup";
import { APP_FILTER } from "@nestjs/core";

@Module({
imports: [DatabaseModule, CommonModule, HealthModule],
imports: [SentryModule.forRoot(), DatabaseModule, CommonModule, HealthModule],
controllers: [TreesController],
providers: [TreeService]
providers: [
{
provide: APP_FILTER,
useClass: SentryGlobalFilter
},
TreeService
]
})
export class AppModule {}
3 changes: 3 additions & 0 deletions apps/entity-service/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// eslint-disable-next-line @nx/enforce-module-boundaries
import "../../../instrument-sentry";

import { Logger, ValidationPipe } from "@nestjs/common";
import { NestFactory } from "@nestjs/core";
import { AppModule } from "./app.module";
Expand Down
21 changes: 14 additions & 7 deletions apps/job-service/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import { Module } from '@nestjs/common';
import { DatabaseModule } from '@terramatch-microservices/database';
import { CommonModule } from '@terramatch-microservices/common';
import { DelayedJobsController } from './jobs/delayed-jobs.controller';
import { HealthModule } from './health/health.module';
import { Module } from "@nestjs/common";
import { DatabaseModule } from "@terramatch-microservices/database";
import { CommonModule } from "@terramatch-microservices/common";
import { DelayedJobsController } from "./jobs/delayed-jobs.controller";
import { HealthModule } from "./health/health.module";
import { SentryGlobalFilter, SentryModule } from "@sentry/nestjs/setup";
import { APP_FILTER } from "@nestjs/core";

@Module({
imports: [DatabaseModule, CommonModule, HealthModule],
imports: [SentryModule.forRoot(), DatabaseModule, CommonModule, HealthModule],
controllers: [DelayedJobsController],
providers: [],
providers: [
{
provide: APP_FILTER,
useClass: SentryGlobalFilter
}
]
})
export class AppModule {}
3 changes: 3 additions & 0 deletions apps/job-service/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// eslint-disable-next-line @nx/enforce-module-boundaries
import "../../../instrument-sentry";

import { Logger, ValidationPipe } from "@nestjs/common";
import { NestFactory } from "@nestjs/core";

Expand Down
24 changes: 16 additions & 8 deletions apps/research-service/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import { Module } from '@nestjs/common';
import { DatabaseModule } from '@terramatch-microservices/database';
import { CommonModule } from '@terramatch-microservices/common';
import { HealthModule } from './health/health.module';
import { SitePolygonsController } from './site-polygons/site-polygons.controller';
import { SitePolygonsService } from './site-polygons/site-polygons.service';
import { Module } from "@nestjs/common";
import { DatabaseModule } from "@terramatch-microservices/database";
import { CommonModule } from "@terramatch-microservices/common";
import { HealthModule } from "./health/health.module";
import { SitePolygonsController } from "./site-polygons/site-polygons.controller";
import { SitePolygonsService } from "./site-polygons/site-polygons.service";
import { APP_FILTER } from "@nestjs/core";
import { SentryGlobalFilter, SentryModule } from "@sentry/nestjs/setup";

@Module({
imports: [DatabaseModule, CommonModule, HealthModule],
imports: [SentryModule.forRoot(), DatabaseModule, CommonModule, HealthModule],
controllers: [SitePolygonsController],
providers: [SitePolygonsService],
providers: [
{
provide: APP_FILTER,
useClass: SentryGlobalFilter
},
SitePolygonsService
]
})
export class AppModule {}
3 changes: 3 additions & 0 deletions apps/research-service/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// eslint-disable-next-line @nx/enforce-module-boundaries
import "../../../instrument-sentry";

import { Logger, ValidationPipe } from "@nestjs/common";
import { NestFactory } from "@nestjs/core";

Expand Down
13 changes: 11 additions & 2 deletions apps/unified-database-service/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@ import { Module } from "@nestjs/common";
import { HealthModule } from "./health/health.module";
import { WebhookController } from "./webhook/webhook.controller";
import { AirtableModule } from "./airtable/airtable.module";
import { SentryGlobalFilter, SentryModule } from "@sentry/nestjs/setup";
import { DatabaseModule } from "@terramatch-microservices/database";
import { APP_FILTER } from "@nestjs/core";

@Module({
imports: [HealthModule, AirtableModule],
controllers: [WebhookController]
imports: [SentryModule.forRoot(), DatabaseModule, HealthModule, AirtableModule],
controllers: [WebhookController],
providers: [
{
provide: APP_FILTER,
useClass: SentryGlobalFilter
}
]
})
export class AppModule {}
3 changes: 3 additions & 0 deletions apps/unified-database-service/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// eslint-disable-next-line @nx/enforce-module-boundaries
import "../../../instrument-sentry";

import { Logger, ValidationPipe } from "@nestjs/common";
import { NestFactory } from "@nestjs/core";

Expand Down
26 changes: 17 additions & 9 deletions apps/user-service/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import { Module } from '@nestjs/common';
import { LoginController } from './auth/login.controller';
import { AuthService } from './auth/auth.service';
import { DatabaseModule } from '@terramatch-microservices/database';
import { UsersController } from './users/users.controller';
import { CommonModule } from '@terramatch-microservices/common';
import { HealthModule } from './health/health.module';
import { Module } from "@nestjs/common";
import { LoginController } from "./auth/login.controller";
import { AuthService } from "./auth/auth.service";
import { DatabaseModule } from "@terramatch-microservices/database";
import { UsersController } from "./users/users.controller";
import { CommonModule } from "@terramatch-microservices/common";
import { HealthModule } from "./health/health.module";
import { SentryGlobalFilter, SentryModule } from "@sentry/nestjs/setup";
import { APP_FILTER } from "@nestjs/core";

@Module({
imports: [DatabaseModule, CommonModule, HealthModule],
imports: [SentryModule.forRoot(), DatabaseModule, CommonModule, HealthModule],
controllers: [LoginController, UsersController],
providers: [AuthService],
providers: [
{
provide: APP_FILTER,
useClass: SentryGlobalFilter
},
AuthService
]
})
export class AppModule {}
3 changes: 3 additions & 0 deletions apps/user-service/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// eslint-disable-next-line @nx/enforce-module-boundaries
import "../../../instrument-sentry";

import { Logger, ValidationPipe } from "@nestjs/common";
import { NestFactory } from "@nestjs/core";

Expand Down
11 changes: 11 additions & 0 deletions instrument-sentry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import * as Sentry from "@sentry/nestjs";
import { nodeProfilingIntegration } from "@sentry/profiling-node";

if (process.env.SENTRY_DSN != null) {
Sentry.init({
dsn: process.env.SENTRY_DSN,
integrations: [nodeProfilingIntegration()],
tracesSampleRate: 1.0,
profilesSampleRate: 1.0
});
}
Loading
Loading