chore: Adding OTEL for New Relic tracing

refactor/available-slots
Keith Williams 2023-08-03 17:10:21 +01:00
parent 91af873db9
commit 7570a7bab2
5 changed files with 828 additions and 1809 deletions

View File

@ -137,6 +137,9 @@ const nextConfig = {
eslint: { eslint: {
ignoreDuringBuilds: !!process.env.CI, ignoreDuringBuilds: !!process.env.CI,
}, },
experimental: {
instrumentationHook: true,
},
transpilePackages: [ transpilePackages: [
"@calcom/app-store", "@calcom/app-store",
"@calcom/core", "@calcom/core",

View File

@ -92,6 +92,12 @@
"vitest-mock-extended": "^1.1.3" "vitest-mock-extended": "^1.1.3"
}, },
"dependencies": { "dependencies": {
"@opentelemetry/api": "^1.4.1",
"@opentelemetry/exporter-trace-otlp-grpc": "^0.38.0",
"@opentelemetry/resources": "^1.12.0",
"@opentelemetry/sdk-trace-base": "^1.12.0",
"@opentelemetry/semantic-conventions": "^1.12.0",
"@vercel/otel": "^0.2.0",
"city-timezones": "^1.2.1", "city-timezones": "^1.2.1",
"eslint": "^8.34.0", "eslint": "^8.34.0",
"lucide-react": "^0.171.0", "lucide-react": "^0.171.0",

View File

@ -0,0 +1,7 @@
import { trace, context } from "@opentelemetry/api";
import { registerOTel } from "@vercel/otel";
registerOTel("cal-app-" + process.env.VERCEL_ENV);
export const tracer = trace.getTracer("cal-app-tracer");
export { context };

View File

@ -1,10 +1,12 @@
import { tracer, context } from "../../../lib/server/OTEL-initializer";
import { middleware } from "../trpc"; import { middleware } from "../trpc";
const perfMiddleware = middleware(async ({ path, type, next }) => { const perfMiddleware = middleware(async ({ path, type, next }) => {
performance.mark("Start"); const span = tracer.startSpan("tRPC." + path, undefined, context.active());
const ms = Math.floor(Math.random() * 1000);
span.setAttribute(path, ms);
const result = await next(); const result = await next();
performance.mark("End"); span.end();
performance.measure(`[${result.ok ? "OK" : "ERROR"}][$1] ${type} '${path}'`, "Start", "End");
return result; return result;
}); });

2613
yarn.lock

File diff suppressed because it is too large Load Diff