Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/collector/src/agent/opts.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ exports.agentUuid = undefined;
// @ts-ignore - Cannot redeclare exported variable
exports.autoProfile = false;

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

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/collector/src/announceCycle/unannounced.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ const maxRetryDelay = 60 * 1000; // one minute
* @typedef {Object} TracingConfig
* @property {Array.<string>} [extra-http-headers]
* @property {KafkaTracingConfig} [kafka]
* @property {import('@instana/core/src/tracing').IgnoreEndpoints} [ignore-endpoints]
* @property {import('@instana/core/src/config/types').IgnoreEndpoints} [ignore-endpoints]
* @property {boolean} [span-batching-enabled]
* @property {import('@instana/core/src/tracing').Disable} [disable]
* @property {import('@instana/core/src/config/types').Disable} [disable]
*/

/**
Expand Down
17 changes: 17 additions & 0 deletions packages/collector/src/types/collector.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
import { GenericLogger } from '@instana/core/src/core';
import { IgnoreEndpoints, Disable } from '@instana/core/src/config/types';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving AgentConfig into a ts declaration file requires to move its dependencies to other types too. But its so much better to use the types files anyway.


export interface AgentConfig {
tracing?: {
http?: {
extraHttpHeadersToCapture?: string[];
};
kafka?: {
traceCorrelation?: boolean;
};
spanBatchingEnabled?: boolean | string;
ignoreEndpoints?: IgnoreEndpoints;
disable?: Disable;
[key: string]: any;
};
[key: string]: any;
}

export interface CollectorConfig {
agentPort?: number;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/config/configNormalizers/disable.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ exports.normalizeExternalConfig = function normalizeExternalConfig(config) {
* 3. INSTANA_TRACING_DISABLE=list
* 4. INSTANA_DISABLED_TRACERS (deprecated)
*
* @returns {import('../../tracing').Disable}
* @returns {import('../../config/types').Disable}
*/
function getDisableFromEnv() {
const disable = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ exports.init = function init(config) {
* Normalized internal structure:
* - { [serviceName: string]: [{ methods: string[], endpoints: string[] }] }
*
* @param {import('../../tracing').IgnoreEndpoints} ignoreEndpointConfig
* @returns {import('../../tracing').IgnoreEndpoints}
* @param {import('../../config/types').IgnoreEndpoints} ignoreEndpointConfig
* @returns {import('../../config/types').IgnoreEndpoints}
*/

exports.normalizeConfig = function normalizeConfig(ignoreEndpointConfig) {
Expand Down
28 changes: 2 additions & 26 deletions packages/core/src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ const deepMerge = require('../util/deepMerge');
* @property {number} [transmissionDelay]
* @property {number} [stackTraceLength]
* @property {HTTPTracingOptions} [http]
* @property {import('../tracing').Disable} [disable]
* @property {import('../config/types').Disable} [disable]
* @property {Array<string>} [disabledTracers]
* @property {boolean} [spanBatchingEnabled]
* @property {boolean} [disableW3cTraceCorrelation]
* @property {KafkaTracingOptions} [kafka]
* @property {boolean} [allowRootExitSpan]
* @property {import('../tracing').IgnoreEndpoints} [ignoreEndpoints]
* @property {import('../config/types').IgnoreEndpoints} [ignoreEndpoints]
* @property {boolean} [ignoreEndpointsDisableSuppression]
* @property {boolean} [disableEOLEvents]
*/
Expand Down Expand Up @@ -74,30 +74,6 @@ const allowedSecretMatchers = ['equals', 'equals-ignore-case', 'contains', 'cont
* @property {number} [timeBetweenHealthcheckCalls]
*/

/**
* @typedef {Object} AgentConfig
* @property {AgentTracingConfig} [tracing]
*/

/**
* @typedef {Object} AgentTracingConfig
* @property {AgentTracingHttpConfig} [http]
* @property {AgentTracingKafkaConfig} [kafka]
* @property {boolean|string} [spanBatchingEnabled]
* @property {import('../tracing').IgnoreEndpoints} [ignoreEndpoints]
* @property {import('../tracing').Disable} [disable]
*/

/**
* @typedef {Object} AgentTracingHttpConfig
* @property {Array.<string>} [extraHttpHeadersToCapture]
*/

/**
* @typedef {Object} AgentTracingKafkaConfig
* @property {boolean} [traceCorrelation]
*/

/** @type {import('../core').GenericLogger} */
let logger;

Expand Down
16 changes: 16 additions & 0 deletions packages/core/src/config/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export interface IgnoreEndpoints {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is our new config types file. A good beginning for a better config module

[key: string]: IgnoreEndpointsFields[];
}

export interface IgnoreEndpointsFields {
methods?: string[];
endpoints?: string[];
connections?: string[];
}

export interface TracingDisableOptions {
instrumentations?: string[];
groups?: string[];
}

export type Disable = TracingDisableOptions | boolean;
21 changes: 0 additions & 21 deletions packages/core/src/tracing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,27 +118,6 @@ if (customInstrumentations.length > 0) {
* @property {boolean} [traceCorrelation]
*/

/**
* @typedef {Object.<string,IgnoreEndpointsFields[]>} IgnoreEndpoints
*/

/**
* @typedef {Object} IgnoreEndpointsFields
* @property {string[]} [methods]
* @property {string[]} [endpoints]
* @property {string[]} [connections]
*/

/**
* @typedef {TracingDisableOptions|boolean} Disable
*/

/**
* @typedef {Object} TracingDisableOptions
* @property {string[]} [instrumentations]
* @property {string[]} [groups]
*/

/** @type {Array.<InstanaInstrumentedModule>} */
let additionalInstrumentationModules = [];
/** @type {Object.<string, InstanaInstrumentedModule>} */
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/tracing/spanBuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ exports.init = function init(config, _downstreamConnection) {
};

/**
* @param {import('../config').AgentConfig} extraConfig
* @param {import('@instana/collector/src/types/collector').AgentConfig} extraConfig
*/
exports.activate = function activate(extraConfig) {
if (!downstreamConnection) {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/util/disableInstrumentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { DISABLABLE_INSTRUMENTATION_GROUPS } = require('../tracing/constants');
/** @type {import('../config').InstanaConfig} */
let config;

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

/**
Expand All @@ -20,7 +20,7 @@ function init(_config) {
}

/**
* @param {import('../config').AgentConfig} _agentConfig
* @param {import('@instana/collector/src/types/collector').AgentConfig} _agentConfig
*/
function activate(_agentConfig) {
agentConfig = _agentConfig;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ exports.init = function init(config) {
};

/**
* @param {import('../config').AgentConfig} extraConfig
* @param {import('@instana/collector/src/types/collector').AgentConfig} extraConfig
*/
exports.activate = function activate(extraConfig) {
disableInstrumentation.activate(extraConfig);
Expand Down
12 changes: 6 additions & 6 deletions packages/core/src/util/spanFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'use strict';

/**
* @type {import('../tracing').IgnoreEndpoints}
* @type {import('../config/types').IgnoreEndpoints}
*/
let ignoreEndpoints;

Expand All @@ -19,7 +19,7 @@ function init(config) {
}

/**
* @param {import('../config').AgentConfig} extraConfig
* @param {import('@instana/collector/src/types/collector').AgentConfig} extraConfig
*/
function activate(extraConfig) {
/**
Expand Down Expand Up @@ -48,7 +48,7 @@ const IGNORABLE_SPAN_TYPES = ['redis', 'dynamodb', 'kafka', 'node.http.server'];
/**
* @param {import('../core').InstanaBaseSpan} span
* @param {string} spanTypeKey
* @param {import('../tracing').IgnoreEndpointsFields} ignoreconfig
* @param {import('../config/types').IgnoreEndpointsFields} ignoreconfig
* @returns {boolean}
*/
function matchEndpoints(span, spanTypeKey, ignoreconfig) {
Expand Down Expand Up @@ -87,7 +87,7 @@ function matchEndpoints(span, spanTypeKey, ignoreconfig) {
/**
* @param {import("../core").InstanaBaseSpan} span
* @param {string} spanTypeKey
* @param {import('../tracing').IgnoreEndpointsFields} ignoreconfig
* @param {import('../config/types').IgnoreEndpointsFields} ignoreconfig
* @returns {boolean}
*/
function matchMethods(span, spanTypeKey, ignoreconfig) {
Expand All @@ -107,7 +107,7 @@ function matchMethods(span, spanTypeKey, ignoreconfig) {
/**
* @param {import("../core").InstanaBaseSpan} span
* @param {string} spanTypeKey
* @param {import('../tracing').IgnoreEndpointsFields} ignoreconfig
* @param {import('../config/types').IgnoreEndpointsFields} ignoreconfig
* @returns {boolean}
*/
function matchConnections(span, spanTypeKey, ignoreconfig) {
Expand All @@ -127,7 +127,7 @@ function matchConnections(span, spanTypeKey, ignoreconfig) {

/**
* @param {import("../core").InstanaBaseSpan} span
* @param {import('../tracing').IgnoreEndpoints} ignoreEndpointsConfig
* @param {import('../config/types').IgnoreEndpoints} ignoreEndpointsConfig
* @returns {boolean}
*/
function shouldIgnore(span, ignoreEndpointsConfig) {
Expand Down