Skip to content

Commit ae461ff

Browse files
authored
refactor: moved agent config types to collector (#2011)
refs #2010
1 parent 3d6a99b commit ae461ff

File tree

12 files changed

+51
-63
lines changed

12 files changed

+51
-63
lines changed

packages/collector/src/agent/opts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ exports.agentUuid = undefined;
1616
// @ts-ignore - Cannot redeclare exported variable
1717
exports.autoProfile = false;
1818

19-
/** @type {import('@instana/core/src/config').AgentConfig} config */
19+
/** @type {import('@instana/collector/src/types/collector').AgentConfig} config */
2020
exports.config = {};
2121

2222
/**

packages/collector/src/announceCycle/unannounced.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ const maxRetryDelay = 60 * 1000; // one minute
4343
* @typedef {Object} TracingConfig
4444
* @property {Array.<string>} [extra-http-headers]
4545
* @property {KafkaTracingConfig} [kafka]
46-
* @property {import('@instana/core/src/tracing').IgnoreEndpoints} [ignore-endpoints]
46+
* @property {import('@instana/core/src/config/types').IgnoreEndpoints} [ignore-endpoints]
4747
* @property {boolean} [span-batching-enabled]
48-
* @property {import('@instana/core/src/tracing').Disable} [disable]
48+
* @property {import('@instana/core/src/config/types').Disable} [disable]
4949
*/
5050

5151
/**

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11
import { GenericLogger } from '@instana/core/src/core';
2+
import { IgnoreEndpoints, Disable } from '@instana/core/src/config/types';
3+
4+
export interface AgentConfig {
5+
tracing?: {
6+
http?: {
7+
extraHttpHeadersToCapture?: string[];
8+
};
9+
kafka?: {
10+
traceCorrelation?: boolean;
11+
};
12+
spanBatchingEnabled?: boolean | string;
13+
ignoreEndpoints?: IgnoreEndpoints;
14+
disable?: Disable;
15+
[key: string]: any;
16+
};
17+
[key: string]: any;
18+
}
219

320
export interface CollectorConfig {
421
agentPort?: number;

packages/core/src/config/configNormalizers/disable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ exports.normalizeExternalConfig = function normalizeExternalConfig(config) {
104104
* 3. INSTANA_TRACING_DISABLE=list
105105
* 4. INSTANA_DISABLED_TRACERS (deprecated)
106106
*
107-
* @returns {import('../../tracing').Disable}
107+
* @returns {import('../../config/types').Disable}
108108
*/
109109
function getDisableFromEnv() {
110110
const disable = {};

packages/core/src/config/configNormalizers/ignoreEndpoints.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ exports.init = function init(config) {
2525
* Normalized internal structure:
2626
* - { [serviceName: string]: [{ methods: string[], endpoints: string[] }] }
2727
*
28-
* @param {import('../../tracing').IgnoreEndpoints} ignoreEndpointConfig
29-
* @returns {import('../../tracing').IgnoreEndpoints}
28+
* @param {import('../../config/types').IgnoreEndpoints} ignoreEndpointConfig
29+
* @returns {import('../../config/types').IgnoreEndpoints}
3030
*/
3131

3232
exports.normalizeConfig = function normalizeConfig(ignoreEndpointConfig) {

packages/core/src/config/index.js

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ const deepMerge = require('../util/deepMerge');
2323
* @property {number} [transmissionDelay]
2424
* @property {number} [stackTraceLength]
2525
* @property {HTTPTracingOptions} [http]
26-
* @property {import('../tracing').Disable} [disable]
26+
* @property {import('../config/types').Disable} [disable]
2727
* @property {Array<string>} [disabledTracers]
2828
* @property {boolean} [spanBatchingEnabled]
2929
* @property {boolean} [disableW3cTraceCorrelation]
3030
* @property {KafkaTracingOptions} [kafka]
3131
* @property {boolean} [allowRootExitSpan]
32-
* @property {import('../tracing').IgnoreEndpoints} [ignoreEndpoints]
32+
* @property {import('../config/types').IgnoreEndpoints} [ignoreEndpoints]
3333
* @property {boolean} [ignoreEndpointsDisableSuppression]
3434
* @property {boolean} [disableEOLEvents]
3535
*/
@@ -74,30 +74,6 @@ const allowedSecretMatchers = ['equals', 'equals-ignore-case', 'contains', 'cont
7474
* @property {number} [timeBetweenHealthcheckCalls]
7575
*/
7676

77-
/**
78-
* @typedef {Object} AgentConfig
79-
* @property {AgentTracingConfig} [tracing]
80-
*/
81-
82-
/**
83-
* @typedef {Object} AgentTracingConfig
84-
* @property {AgentTracingHttpConfig} [http]
85-
* @property {AgentTracingKafkaConfig} [kafka]
86-
* @property {boolean|string} [spanBatchingEnabled]
87-
* @property {import('../tracing').IgnoreEndpoints} [ignoreEndpoints]
88-
* @property {import('../tracing').Disable} [disable]
89-
*/
90-
91-
/**
92-
* @typedef {Object} AgentTracingHttpConfig
93-
* @property {Array.<string>} [extraHttpHeadersToCapture]
94-
*/
95-
96-
/**
97-
* @typedef {Object} AgentTracingKafkaConfig
98-
* @property {boolean} [traceCorrelation]
99-
*/
100-
10177
/** @type {import('../core').GenericLogger} */
10278
let logger;
10379

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export interface IgnoreEndpoints {
2+
[key: string]: IgnoreEndpointsFields[];
3+
}
4+
5+
export interface IgnoreEndpointsFields {
6+
methods?: string[];
7+
endpoints?: string[];
8+
connections?: string[];
9+
}
10+
11+
export interface TracingDisableOptions {
12+
instrumentations?: string[];
13+
groups?: string[];
14+
}
15+
16+
export type Disable = TracingDisableOptions | boolean;

packages/core/src/tracing/index.js

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -118,27 +118,6 @@ if (customInstrumentations.length > 0) {
118118
* @property {boolean} [traceCorrelation]
119119
*/
120120

121-
/**
122-
* @typedef {Object.<string,IgnoreEndpointsFields[]>} IgnoreEndpoints
123-
*/
124-
125-
/**
126-
* @typedef {Object} IgnoreEndpointsFields
127-
* @property {string[]} [methods]
128-
* @property {string[]} [endpoints]
129-
* @property {string[]} [connections]
130-
*/
131-
132-
/**
133-
* @typedef {TracingDisableOptions|boolean} Disable
134-
*/
135-
136-
/**
137-
* @typedef {Object} TracingDisableOptions
138-
* @property {string[]} [instrumentations]
139-
* @property {string[]} [groups]
140-
*/
141-
142121
/** @type {Array.<InstanaInstrumentedModule>} */
143122
let additionalInstrumentationModules = [];
144123
/** @type {Object.<string, InstanaInstrumentedModule>} */

packages/core/src/tracing/spanBuffer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ exports.init = function init(config, _downstreamConnection) {
103103
};
104104

105105
/**
106-
* @param {import('../config').AgentConfig} extraConfig
106+
* @param {import('@instana/collector/src/types/collector').AgentConfig} extraConfig
107107
*/
108108
exports.activate = function activate(extraConfig) {
109109
if (!downstreamConnection) {

packages/core/src/util/disableInstrumentation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const { DISABLABLE_INSTRUMENTATION_GROUPS } = require('../tracing/constants');
99
/** @type {import('../config').InstanaConfig} */
1010
let config;
1111

12-
/** @type {import('../config').AgentConfig} */
12+
/** @type {import('@instana/collector/src/types/collector').AgentConfig} */
1313
let agentConfig;
1414

1515
/**
@@ -20,7 +20,7 @@ function init(_config) {
2020
}
2121

2222
/**
23-
* @param {import('../config').AgentConfig} _agentConfig
23+
* @param {import('@instana/collector/src/types/collector').AgentConfig} _agentConfig
2424
*/
2525
function activate(_agentConfig) {
2626
agentConfig = _agentConfig;

0 commit comments

Comments
 (0)