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

Enable Sentry Prisma integration #376

Merged
merged 17 commits into from
Jul 13, 2024
Merged
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
113 changes: 55 additions & 58 deletions .github/workflows/prod-docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,69 +15,66 @@ permissions:
packages: write

jobs:

server:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/ystv/badger/server
flavor: latest=true
tags: |
type=semver,pattern={{version}}
type=raw,value=${{ inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' }}
- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
file: Dockerfile.server

jobrunner:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/ystv/badger/server
flavor: latest=true
tags: |
type=semver,pattern={{version}}
type=raw,value=${{ inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' }}
- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
file: Dockerfile.server

jobrunner:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
id: jr_meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/ystv/badger/jobrunner
flavor: latest=true
tags: |
type=semver,pattern={{version}}
type=raw,value=${{ inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' }}
- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: ${{ steps.jr_meta.outputs.tags }}
labels: ${{ steps.jr_meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
file: Dockerfile.jobrunner
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
id: jr_meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/ystv/badger/jobrunner
flavor: latest=true
tags: |
type=semver,pattern={{version}}
type=raw,value=${{ inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' }}
- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: ${{ steps.jr_meta.outputs.tags }}
labels: ${{ steps.jr_meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
file: Dockerfile.jobrunner
2 changes: 2 additions & 0 deletions jobrunner/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ if (process.env.JOBRUNNER_SENTRY_DSN) {
tracesSampleRate: 1.0,

release: global.__SENTRY_RELEASE__,

integrations: [Sentry.prismaIntegration()],
});
console.log("[Jobrunner] Sentry enabled");
}
Expand Down
40 changes: 31 additions & 9 deletions server/instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,39 @@ export async function register() {
const { logFlagState } = await import("@badger/feature-flags");
logFlagState();

Sentry.init({
dsn: process.env.NEXT_PUBLIC_SERVER_SENTRY_DSN,
if (process.env.NEXT_RUNTIME === "nodejs") {
Sentry.init({
dsn: process.env.NEXT_PUBLIC_SERVER_SENTRY_DSN,

environment: process.env.ENVIRONMENT,
environment: process.env.ENVIRONMENT,

// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 1,
// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 1,

// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,
// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,

release: process.env.NEXT_PUBLIC_SENTRY_RELEASE,
});
release: process.env.NEXT_PUBLIC_SENTRY_RELEASE,

integrations: [Sentry.prismaIntegration()],
});
}

if (process.env.NEXT_RUNTIME === "edge") {
Sentry.init({
dsn: process.env.NEXT_PUBLIC_SERVER_SENTRY_DSN,

environment: process.env.ENVIRONMENT,

// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 1,

// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,

release: process.env.NEXT_PUBLIC_SENTRY_RELEASE,

// Prisma integration isn't supported on edge
});
}
}
2 changes: 1 addition & 1 deletion utility/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
generator client {
provider = "prisma-client-js"
output = "./client"
previewFeatures = ["views"]
previewFeatures = ["views", "tracing"]
}

generator zod {
Expand Down
Loading
Loading