Skip to content

Commit

Permalink
Add opentelemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusab committed May 12, 2024
1 parent 490a745 commit 264e370
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
5 changes: 4 additions & 1 deletion apps/dashboard/.env-example
Expand Up @@ -46,4 +46,7 @@ UNSUBSCRIBE_JWT_SECRET=
UNSUBSCRIBE_JWT_ISSUER=

# Plain
PLAIN_API_KEY=
PLAIN_API_KEY=

# Baselime
BASELIME_SERVICE=
3 changes: 3 additions & 0 deletions apps/dashboard/next.config.mjs
Expand Up @@ -18,6 +18,9 @@ const config = {
typescript: {
ignoreBuildErrors: true,
},
experimental: {
instrumentationHook: true,
},
webpack: (config) => {
/**
* Critical: prevents " ⨯ ./node_modules/canvas/build/Release/canvas.node
Expand Down
2 changes: 2 additions & 0 deletions apps/dashboard/src/env.mjs
Expand Up @@ -40,6 +40,7 @@ export const env = createEnv({
GOCARDLESS_SECRET_KEY: z.string(),
NOVU_API_KEY: z.string(),
RESEND_API_KEY: z.string(),
BASELIME_SERVICE: z.string(),
},
/**
* Specify your client-side environment variables schema here.
Expand Down Expand Up @@ -92,6 +93,7 @@ export const env = createEnv({
GOOGLE_APPLICATION_INVOICE_PROCESSOR_ID: process.env.PLAIN_API_KEY,
GOOGLE_APPLICATION_EXPENSE_PROCESSOR_ID:
process.env.GOOGLE_APPLICATION_EXPENSE_PROCESSOR_ID,
BASELIME_SERVICE: process.env.BASELIME_SERVICE,
},
skipValidation: !!process.env.CI || !!process.env.SKIP_ENV_VALIDATION,
});
18 changes: 18 additions & 0 deletions apps/dashboard/src/instrumentation.ts
@@ -0,0 +1,18 @@
export async function register() {
if (process.env.NEXT_RUNTIME === "nodejs") {
const { BaselimeSDK, VercelPlugin, BetterHttpInstrumentation } =
await import("@baselime/node-opentelemetry");

const sdk = new BaselimeSDK({
serverless: true,
service: process.env.BASELIME_SERVICE,
instrumentations: [
new BetterHttpInstrumentation({
plugins: [new VercelPlugin()],
}),
],
});

sdk.start();
}
}

0 comments on commit 264e370

Please sign in to comment.