Skip to content

Commit 5642b36

Browse files
fix: disabled collector init process events (#2517)
Sending 'instana.collector.initialized' event is disabled by default. - This prevents interference with application-level communication channels. - The event is primarily used for testing purposes now. ref https://jsw.ibm.com/browse/INSTA-85329 --------- Co-authored-by: kirrg001 <katharina.irrgang@ibm.com>
1 parent 50b4dc7 commit 5642b36

6 files changed

Lines changed: 25 additions & 4 deletions

File tree

packages/collector/src/agent/opts.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ exports.agentUuid = undefined;
1717
// @ts-ignore - Cannot redeclare exported variable
1818
exports.autoProfile = false;
1919

20+
exports.disableCollectorInitEvent = true;
21+
2022
/** @type {import('@instana/collector/src/types/collector').AgentConfig} config */
2123
exports.config = {};
2224

@@ -34,4 +36,6 @@ exports.init = function init(config) {
3436
exports.autoProfile = config.autoProfile;
3537

3638
exports.requestTimeout = config.agentRequestTimeout;
39+
40+
exports.disableCollectorInitEvent = config.disableCollectorInitEvent;
3741
};

packages/collector/src/announceCycle/agentready.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,13 @@ function enter(_ctx) {
156156
if (!isMainThread) {
157157
const { parentPort } = require('worker_threads');
158158

159-
if (parentPort) {
160-
// CASE: This is for the worker thread if available.
159+
/**
160+
* Sending 'instana.collector.initialized' event is disabled by default.
161+
* This prevents interference with application-level communication channels.
162+
* The event is primarily used for testing purposes now.
163+
*/
164+
165+
if (parentPort && agentOpts.disableCollectorInitEvent === false) {
161166
parentPort.postMessage('instana.collector.initialized');
162167
}
163168
}

packages/collector/src/types/collector.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@ export interface CollectorConfig {
3333
reportUnhandledPromiseRejections?: boolean;
3434
logger?: GenericLogger;
3535
level?: string | number;
36+
disableCollectorInitEvent?: boolean;
3637
}

packages/collector/src/util/normalizeConfig.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ const defaults = {
1111
agentHost: '127.0.0.1',
1212
agentPort: 42699,
1313
agentRequestTimeout: 5000,
14-
autoProfile: false
14+
autoProfile: false,
15+
disableCollectorInitEvent: true
1516
};
1617

1718
/**
@@ -33,6 +34,11 @@ module.exports = function normalizeConfig(config = {}) {
3334
config.reportUnhandledPromiseRejections = false;
3435
}
3536

37+
if (config.disableCollectorInitEvent == null) {
38+
const envValue = process.env.INSTANA_DISABLE_COLLECTOR_INIT_EVENT;
39+
config.disableCollectorInitEvent = envValue === 'true' ? true : defaults.disableCollectorInitEvent;
40+
}
41+
3642
return config;
3743
};
3844

packages/collector/test/integration/misc/logger_spans/worker.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ const { workerData } = require('worker_threads');
1111
console.log('Worker thread: Starting', workerData);
1212

1313
const instana = require('@instana/collector')({
14-
agentPort: workerData.agentPort
14+
agentPort: workerData.agentPort,
15+
disableCollectorInitEvent: false
1516
});
1617

1718
(async () => {

packages/collector/test/test_util/ProcessControls.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ class ProcessControls {
164164
opts.env
165165
);
166166

167+
if (!this.env.INSTANA_DISABLE_COLLECTOR_INIT_EVENT) {
168+
this.env.INSTANA_DISABLE_COLLECTOR_INIT_EVENT = 'false';
169+
}
170+
167171
if (this.usePreInit) {
168172
this.env.INSTANA_EARLY_INSTRUMENTATION = 'true';
169173
}

0 commit comments

Comments
 (0)