From bd84290b9e9dd9456eb02f119c9bf09f5f00d110 Mon Sep 17 00:00:00 2001 From: Gergo Moricz Date: Thu, 11 Jul 2024 23:20:51 +0200 Subject: [PATCH] fix: reenable hyperdx --- apps/api/src/controllers/auth.ts | 24 ++++++++++++------------ apps/api/src/index.ts | 8 ++++---- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/apps/api/src/controllers/auth.ts b/apps/api/src/controllers/auth.ts index fe3a5e1b..56a5ec61 100644 --- a/apps/api/src/controllers/auth.ts +++ b/apps/api/src/controllers/auth.ts @@ -4,23 +4,23 @@ import { AuthResponse, NotificationType, RateLimiterMode } from "../../src/types import { supabase_service } from "../../src/services/supabase"; import { withAuth } from "../../src/lib/withAuth"; import { RateLimiterRedis } from "rate-limiter-flexible"; -// import { setTraceAttributes } from '@hyperdx/node-opentelemetry'; +import { setTraceAttributes } from '@hyperdx/node-opentelemetry'; import { sendNotification } from "../services/notification/email_notification"; export async function authenticateUser(req, res, mode?: RateLimiterMode): Promise { return withAuth(supaAuthenticateUser)(req, res, mode); } -// function setTrace(team_id: string, api_key: string) { -// try { -// setTraceAttributes({ -// team_id, -// api_key -// }); -// } catch (error) { -// console.error('Error setting trace attributes:', error); -// } +function setTrace(team_id: string, api_key: string) { + try { + setTraceAttributes({ + team_id, + api_key + }); + } catch (error) { + console.error('Error setting trace attributes:', error); + } -// } +} export async function supaAuthenticateUser( req, res, @@ -99,7 +99,7 @@ export async function supaAuthenticateUser( const plan = getPlanByPriceId(data[0].price_id); // HyperDX Logging - // setTrace(team_id, normalizedApi); + setTrace(team_id, normalizedApi); subscriptionData = { team_id: team_id, plan: plan diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts index 3091870a..ba494d83 100644 --- a/apps/api/src/index.ts +++ b/apps/api/src/index.ts @@ -5,7 +5,7 @@ import "dotenv/config"; import { getWebScraperQueue } from "./services/queue-service"; import { redisClient } from "./services/rate-limiter"; import { v0Router } from "./routes/v0"; -// import { initSDK } from "@hyperdx/node-opentelemetry"; +import { initSDK } from "@hyperdx/node-opentelemetry"; import cluster from "cluster"; import os from "os"; import { Job } from "bull"; @@ -72,9 +72,9 @@ if (cluster.isMaster) { redisClient.connect(); // HyperDX OpenTelemetry - // if (process.env.ENV === "production") { - // initSDK({ consoleCapture: true, additionalInstrumentations: [] }); - // } + if (process.env.ENV === "production") { + initSDK({ consoleCapture: true, additionalInstrumentations: [] }); + } function startServer(port = DEFAULT_PORT) { const server = app.listen(Number(port), HOST, () => {