From 4748ff8b6ceef1f67659edfe3273cc25120e2a08 Mon Sep 17 00:00:00 2001 From: Thomas Flament Date: Tue, 13 Oct 2026 14:40:23 +0200 Subject: [PATCH] Fix OTEL init order so auto-instrumentation patches mongodb and ioredis The guard previously required ./lib/Config to decide whether to skip tracing.init() on the cluster primary. Config top-level-requires arsenal, which eagerly loads mongodb and ioredis clients. By the time tracing.init() ran, those modules were already in require.cache, so require-in-the-middle hooks installed by MongoDBInstrumentation and IORedisInstrumentation never patched them and spans silently never emerged (HTTP spans worked because HttpInstrumentation patches the Node core modules directly). Drop the primary-skip entirely and initialize unconditionally when ENABLE_OTEL=true. The cluster primary now boots a BatchSpanProcessor that has nothing to export; the fixed, bounded cost is accepted in exchange for correct auto-instrumentation on workers. Issue: CLDSRV-1023 --- index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/index.js b/index.js index fe68a8a1b1..57ea591713 100644 --- a/index.js +++ b/index.js @@ -9,8 +9,7 @@ require('werelogs').stderrUtils.catchAndTimestampStderr( const tracing = require('arsenal/build/lib/tracing'); -// Gated on isEnabled() so the OTEL-off path doesn't load Config early. -if (tracing.isEnabled() && !(require('./lib/Config').config.isCluster && require('cluster').isPrimary)) { +if (tracing.isEnabled()) { tracing.init({ serviceName: 'cloudserver', serviceVersion: require('./package.json').version,