Browse Source

add instrumentation hook(currently not workking)

Syunsuke Komma 2 years ago
parent
commit
96a984214a
2 changed files with 14 additions and 0 deletions
  1. 3 0
      apps/app/next.config.js
  2. 11 0
      apps/app/src/instrumentation.ts

+ 3 - 0
apps/app/next.config.js

@@ -70,6 +70,9 @@ module.exports = async(phase, { defaultConfig }) => {
   /** @type {import('next').NextConfig} */
   const nextConfig = {
 
+    // for OpenTelemetry
+    // https://nextjs.org/docs/app/building-your-application/optimizing/open-telemetry
+    experimental: { instrumentationHook: true },
     reactStrictMode: true,
     poweredByHeader: false,
     pageExtensions: ['page.tsx', 'page.ts', 'page.jsx', 'page.js'],

+ 11 - 0
apps/app/src/instrumentation.ts

@@ -0,0 +1,11 @@
+import { registerOTel } from '@vercel/otel';
+
+import loggerFactory from '~/utils/logger';
+
+const logger = loggerFactory('growi:instrumentation');
+
+logger.info('HOGEhoge');
+
+export function register(): void {
+  registerOTel({ serviceName: 'growi' });
+}