@instana/core
Advanced tools
Comparing version 1.115.0 to 1.115.1
{ | ||
"name": "@instana/core", | ||
"version": "1.115.0", | ||
"version": "1.115.1", | ||
"description": "Core library for Instana's Node.js packages", | ||
@@ -136,3 +136,3 @@ "main": "src/index.js", | ||
}, | ||
"gitHead": "51462a6b2630d502012233d699046b9ca8910113" | ||
"gitHead": "10e54f421de2b19d1f916533e072d04b57361bc1" | ||
} |
@@ -8,5 +8,16 @@ /* | ||
/** @type {*} */ | ||
let parentLogger = null; | ||
/** @type {*} */ | ||
const registry = {}; | ||
/** | ||
* @typedef {Object} GenericLogger | ||
* @property {(...args: *) => void} debug | ||
* @property {(...args: *) => void} info | ||
* @property {(...args: *) => void} warn | ||
* @property {(...args: *) => void} error | ||
*/ | ||
/** @type {GenericLogger} */ | ||
const consoleLogger = { | ||
@@ -18,4 +29,13 @@ /* eslint-disable no-console */ | ||
error: console.error | ||
/* eslint-enable no-console */ | ||
}; | ||
/** | ||
* @typedef {Object} LoggerConfig | ||
* @property {*} [logger] | ||
*/ | ||
/** | ||
* @param {LoggerConfig} config | ||
*/ | ||
exports.init = function init(config = {}) { | ||
@@ -52,2 +72,7 @@ if ( | ||
/** | ||
* @param {string} loggerName | ||
* @param {(arg: *) => *} [reInitFn] | ||
* @returns {GenericLogger} | ||
*/ | ||
exports.getLogger = function getLogger(loggerName, reInitFn) { | ||
@@ -77,2 +102,6 @@ if (!parentLogger) { | ||
/** | ||
* @param {GenericLogger} logger | ||
* @returns {boolean} | ||
*/ | ||
function hasLoggingFunctions(logger) { | ||
@@ -79,0 +108,0 @@ return ( |
@@ -8,2 +8,3 @@ /* | ||
/** @type {import('./logger').GenericLogger} */ | ||
let logger; | ||
@@ -17,3 +18,18 @@ logger = require('./logger').getLogger('secrets', newLogger => { | ||
/** | ||
* @typedef {Object} SecretMatchers | ||
* @property {(secrets: Array<string>) => (key: string) => boolean} equals-ignore-case | ||
* @property {(secrets: Array<string>) => (key: string) => boolean} equals | ||
* @property {(secrets: Array<string>) => (key: string) => boolean} contains-ignore-case | ||
* @property {(secrets: Array<string>) => (key: string) => boolean} contains | ||
* @property {(secrets: Array<string>) => (key: string) => boolean} regex | ||
* @property {() => () => boolean} none | ||
*/ | ||
/** @type {SecretMatchers} */ | ||
exports.matchers = { | ||
/** | ||
* @param {Array<string>} secrets | ||
* @returns {(key: string) => boolean} | ||
*/ | ||
'equals-ignore-case': function createEqualsIgnoreCaseMatcher(secrets) { | ||
@@ -34,2 +50,6 @@ secrets = toLowerCase(secrets); | ||
/** | ||
* @param {Array<string>} secrets | ||
* @returns {(key: string) => boolean} | ||
*/ | ||
equals: function createEqualsMatcher(secrets) { | ||
@@ -50,2 +70,6 @@ secrets = checkSecrets(secrets); | ||
/** | ||
* @param {Array<string>} secrets | ||
* @returns {(key: string) => boolean} | ||
*/ | ||
'contains-ignore-case': function createContainsIgnoreCaseMatcher(secrets) { | ||
@@ -66,2 +90,6 @@ secrets = toLowerCase(secrets); | ||
/** | ||
* @param {Array<string>} secrets | ||
* @returns {(key: string) => boolean} | ||
*/ | ||
contains: function createContainsMatcher(secrets) { | ||
@@ -82,4 +110,9 @@ secrets = checkSecrets(secrets); | ||
/** | ||
* @param {Array<string>} secrets | ||
* @returns {(key: string) => boolean} | ||
*/ | ||
regex: function createRegexMatcher(secrets) { | ||
secrets = checkSecrets(secrets); | ||
/** @type {Array<RegExp>} */ | ||
const regexes = []; | ||
@@ -125,2 +158,6 @@ secrets.forEach(regexString => { | ||
/** | ||
* @param {Array<string>} configuredSecrets | ||
* @returns {Array<string>} | ||
*/ | ||
function checkSecrets(configuredSecrets) { | ||
@@ -130,2 +167,3 @@ if (!Array.isArray(configuredSecrets)) { | ||
} | ||
/** @type {Array<string>} */ | ||
const secrets = []; | ||
@@ -142,2 +180,5 @@ configuredSecrets.forEach(s => { | ||
/** | ||
* @param {Array<string>} configuredSecrets | ||
*/ | ||
function toLowerCase(configuredSecrets) { | ||
@@ -147,2 +188,3 @@ if (!Array.isArray(configuredSecrets)) { | ||
} | ||
/** @type {Array<string>} */ | ||
const secrets = []; | ||
@@ -159,9 +201,34 @@ configuredSecrets.forEach(s => { | ||
/** | ||
* @typedef {'contains' | 'equals-ignore-case' | 'equals' | 'contains-ignore-case' | 'regex'} MatchingOptions | ||
*/ | ||
// We should fix this properly. exports cannot be redefined. | ||
// @ts-expect-error | ||
exports.isSecret = exports.matchers[defaultMatcherMode](defaultSecrets); | ||
/** | ||
* @typedef {Object} Secrets | ||
* @property {*} keywords | ||
* @property {MatchingOptions} matcherMode | ||
*/ | ||
/** | ||
* @typedef {Object} SecretOption | ||
* @property {Secrets} secrets | ||
*/ | ||
/** | ||
* @param {SecretOption} config | ||
*/ | ||
exports.init = function init(config) { | ||
// Init from config/env vars. Might be overwritten from agent response later (via setMatcher); | ||
// @ts-expect-error | ||
exports.isSecret = exports.matchers[config.secrets.matcherMode](config.secrets.keywords); | ||
}; | ||
/** | ||
* @param {MatchingOptions} matcherId | ||
* @param {Array<*>} secretsList | ||
*/ | ||
exports.setMatcher = function setMatcher(matcherId, secretsList) { | ||
@@ -175,4 +242,5 @@ if (!(typeof matcherId === 'string')) { | ||
} else { | ||
// @ts-expect-error | ||
exports.isSecret = exports.matchers[matcherId](secretsList); | ||
} | ||
}; |
@@ -353,3 +353,2 @@ /* | ||
} | ||
process.namespaces = process.namespaces || {}; |
@@ -31,2 +31,3 @@ /* | ||
'./instrumentation/cloud/aws/s3', | ||
'./instrumentation/cloud/aws/dynamodb', | ||
'./instrumentation/cloud/gcp/pubsub', | ||
@@ -33,0 +34,0 @@ './instrumentation/cloud/gcp/storage', |
@@ -351,5 +351,2 @@ /* | ||
* Flattens the AWS SQS MessageAttribute format into a basic object structure. | ||
* | ||
* @param sqsAttributes {Object.<string, {DataType: string, StringValue: string}} The AWS SQS MessageAttribute object | ||
* @returns {Object.<string, string>} The flattened object | ||
*/ | ||
@@ -356,0 +353,0 @@ function convertAttributesFromSQS(sqsAttributes) { |
@@ -10,4 +10,5 @@ /* | ||
/** @type {(version: string) => boolean} */ | ||
module.exports = exports = function supportedVersion(version) { | ||
return semver.satisfies(version, '^6 || ^7 || ^8.2.1 || ^9.1.0 || ^10.4.0 || ^11 || >=12.0.0'); | ||
}; |
@@ -11,2 +11,3 @@ /* | ||
/** @type {import('../logger').GenericLogger} */ | ||
let logger; | ||
@@ -19,4 +20,7 @@ logger = require('../logger').getLogger('util/atMostOnce', newLogger => { | ||
// and identification of these values is expensive. | ||
/** @type {*} */ | ||
let parsedMainPackageJson; | ||
/** @type {*} */ | ||
let mainPackageJsonPath; | ||
/** @type {*} */ | ||
let nodeModulesPath; | ||
@@ -29,2 +33,6 @@ let appInstalledIntoNodeModules = false; | ||
/** | ||
* @param {string} startDirectory | ||
* @param {Function} cb | ||
*/ | ||
exports.getMainPackageJson = function getMainPackageJson(startDirectory, cb) { | ||
@@ -66,2 +74,6 @@ if (typeof startDirectory === 'function') { | ||
/** | ||
* @param {string} startDirectory | ||
* @param {(err: Error, packageJsonPath: string) => void} cb | ||
*/ | ||
exports.getMainPackageJsonPath = function getMainPackageJsonPath(startDirectory, cb) { | ||
@@ -106,2 +118,6 @@ if (typeof startDirectory === 'function') { | ||
/** | ||
* @param {string} dir | ||
* @param {(err: Error, main: *) => void} cb | ||
*/ | ||
function searchForPackageJsonInDirectoryTreeUpwards(dir, cb) { | ||
@@ -164,2 +180,5 @@ const pathToCheck = path.join(dir, 'package.json'); | ||
/** | ||
* @param {Function} cb | ||
*/ | ||
exports.findNodeModulesFolder = function findNodeModulesFolder(cb) { | ||
@@ -186,2 +205,6 @@ if (nodeModulesPath !== undefined) { | ||
/** | ||
* @param {string} dir | ||
* @param {(err: Error, nodeModulesPath: *) => void} cb | ||
*/ | ||
function searchForNodeModulesInDirectoryTreeUpwards(dir, cb) { | ||
@@ -209,2 +232,7 @@ const pathToCheck = path.join(dir, 'node_modules'); | ||
/** | ||
* @param {string} dir | ||
* @param {(parentDir: string, cb: Function) => void} onParentDir | ||
* @param {Function} cb | ||
*/ | ||
function searchInParentDir(dir, onParentDir, cb) { | ||
@@ -211,0 +239,0 @@ const parentDir = path.resolve(dir, '..'); |
@@ -10,3 +10,5 @@ /* | ||
/** @type {import('../logger').GenericLogger} */ | ||
let logger; | ||
logger = require('../logger').getLogger('util/atMostOnce', newLogger => { | ||
@@ -13,0 +15,0 @@ logger = newLogger; |
@@ -17,2 +17,6 @@ /* | ||
/** | ||
* @param {string} str | ||
* @param {BufferEncoding} [encoding] | ||
*/ | ||
exports.fromString = function fromString(str, encoding = 'utf8') { | ||
@@ -19,0 +23,0 @@ if (suppotsBufferFrom) { |
@@ -8,3 +8,8 @@ /* | ||
/** | ||
* @param {Object<string, *>|Array<Object>} x | ||
* @returns {Object} | ||
*/ | ||
module.exports = function clone(x) { | ||
/** @type {Object<string, *>} */ | ||
let r; | ||
@@ -32,3 +37,3 @@ if (x === null || x === undefined) { | ||
if (x.hasOwnProperty(key)) { | ||
r[key] = clone(x[key]); | ||
r[key] = clone(/** @type {Object<string, *>} */ (x)[key]); | ||
} | ||
@@ -35,0 +40,0 @@ } |
@@ -8,2 +8,8 @@ /* | ||
/** | ||
* @type {Function} | ||
* @param {Object<string, *>} prev | ||
* @param {Object<string, *>} next | ||
* @param {Array<*>} excludeList | ||
*/ | ||
module.exports = exports = function applyCompressionRoot(prev, next, excludeList) { | ||
@@ -19,2 +25,8 @@ const result = applyCompression([], prev, next, excludeList); | ||
/** | ||
* @param {Array<*>} path | ||
* @param {*} prev | ||
* @param {*} next | ||
* @param {*} excludeList | ||
*/ | ||
function applyCompression(path, prev, next, excludeList) { | ||
@@ -47,3 +59,10 @@ if (isExcluded(path, excludeList)) { | ||
/** | ||
* @param {Array<*>} path | ||
* @param {Object<string, *>} prev | ||
* @param {Object<string, *>} next | ||
* @param {Array<*>} excludeList | ||
*/ | ||
function applyCompressionToObject(path, prev, next, excludeList) { | ||
/** @type {Object<string, *>} */ | ||
const result = {}; | ||
@@ -74,2 +93,6 @@ let addedProps = 0; | ||
/** | ||
* @param {Object<string, *>} prev | ||
* @param {Object<string, *>} next | ||
*/ | ||
function applyCompressionToArray(prev, next) { | ||
@@ -92,2 +115,6 @@ if (next.length !== prev.length) { | ||
/** | ||
* @param {Array<*>} path | ||
* @param {Array<*>} excludeList | ||
*/ | ||
function isExcluded(path, excludeList) { | ||
@@ -94,0 +121,0 @@ if (excludeList == null) { |
@@ -18,2 +18,7 @@ /* | ||
*/ | ||
/** | ||
* @param {*} target | ||
* @param {*} source | ||
*/ | ||
module.exports = function deepMerge(target, source) { | ||
@@ -42,4 +47,7 @@ if (target == null && source != null) { | ||
/** | ||
* @param {*} value | ||
*/ | ||
function isObject(value) { | ||
return value && typeof value === 'object' && !Array.isArray(value); | ||
} |
@@ -16,2 +16,6 @@ /* | ||
/** | ||
* @type {Function} | ||
* @returns {boolean} | ||
*/ | ||
module.exports = exports = function isExcludedFromInstrumentation() { | ||
@@ -18,0 +22,0 @@ const mainModule = process.argv[1]; |
@@ -8,2 +8,3 @@ /* | ||
/** @type {*} */ | ||
module.exports = exports = { | ||
@@ -10,0 +11,0 @@ applicationUnderMonitoring: require('./applicationUnderMonitoring'), |
@@ -8,2 +8,3 @@ /* | ||
/** @type {import('../logger').GenericLogger} */ | ||
let logger; | ||
@@ -61,2 +62,6 @@ logger = require('../logger').getLogger('util/initializedTooLateHeuristic', newLogger => { | ||
/** | ||
* @type {Function} | ||
* @returns {boolean} | ||
*/ | ||
module.exports = exports = function hasThePackageBeenInitializedTooLate() { | ||
@@ -63,0 +68,0 @@ if (firstCall) { |
@@ -12,2 +12,44 @@ /* | ||
/** | ||
* @typedef {Object} HTTPTracingOption | ||
* @property {Array<*>} [extraHttpHeadersToCapture] | ||
*/ | ||
/** | ||
* @typedef {Object} InstanaTracingOption | ||
* @property {boolean} [enabled] | ||
* @property {boolean} [automaticTracingEnabled] | ||
* @property {number} [forceTransmissionStartingAt] | ||
* @property {number} [maxBufferedSpans] | ||
* @property {number} [transmissionDelay] | ||
* @property {number} [stackTraceLength] | ||
* @property {HTTPTracingOption} [http] | ||
* @property {Array<*>} [disabledTracers] | ||
* @property {boolean} [spanBatchingEnabled] | ||
* @property {boolean} [disableAutomaticTracing] | ||
* @property {boolean} [disableW3cTraceCorrelation] | ||
*/ | ||
/** | ||
* @typedef {Object} InstanaMetricsOption | ||
* @property {number} [transmissionDelay] | ||
* @property {number} [timeBetweenHealthcheckCalls] | ||
*/ | ||
/** | ||
* @typedef {Object} InstanaSecretsOption | ||
* @property {string} [matcherMode] | ||
* @property {Array<string>} [keywords] | ||
*/ | ||
/** | ||
* @typedef {Object} InstanaConfig | ||
* @property {string} [serviceName] | ||
* @property {InstanaMetricsOption} [metrics] | ||
* @property {InstanaTracingOption} [tracing] | ||
* @property {InstanaSecretsOption} [secrets] | ||
* @property {number} [timeBetweenHealthcheckCalls] | ||
*/ | ||
/** @type {import('../logger').GenericLogger} */ | ||
let logger; | ||
@@ -18,2 +60,3 @@ logger = require('../logger').getLogger('configuration', newLogger => { | ||
/** @type {InstanaConfig} */ | ||
const defaults = { | ||
@@ -51,2 +94,8 @@ serviceName: null, | ||
*/ | ||
/** | ||
* @type {Function} | ||
* @param {InstanaConfig} config | ||
* @returns {InstanaConfig} | ||
*/ | ||
module.exports = exports = function normalizeConfig(config) { | ||
@@ -64,2 +113,5 @@ if (config == null) { | ||
/** | ||
* @param {InstanaConfig} config | ||
*/ | ||
function normalizeServiceName(config) { | ||
@@ -77,2 +129,5 @@ if (config.serviceName == null && process.env['INSTANA_SERVICE_NAME']) { | ||
/** | ||
* @param {InstanaConfig} config | ||
*/ | ||
function normalizeMetricsConfig(config) { | ||
@@ -99,2 +154,6 @@ if (config.metrics == null) { | ||
/** | ||
* | ||
* @param {InstanaConfig} config | ||
*/ | ||
function normalizeTracingConfig(config) { | ||
@@ -114,2 +173,6 @@ if (config.tracing == null) { | ||
/** | ||
* | ||
* @param {InstanaConfig} config | ||
*/ | ||
function normalizeTracingEnabled(config) { | ||
@@ -133,2 +196,6 @@ if (config.tracing.enabled === false) { | ||
/** | ||
* | ||
* @param {InstanaConfig} config | ||
*/ | ||
function normalizeAutomaticTracingEnabled(config) { | ||
@@ -169,2 +236,6 @@ if (!config.tracing.enabled) { | ||
/** | ||
* | ||
* @param {InstanaConfig} config | ||
*/ | ||
function normalizeTracingTransmission(config) { | ||
@@ -188,2 +259,5 @@ config.tracing.maxBufferedSpans = config.tracing.maxBufferedSpans || defaults.tracing.maxBufferedSpans; | ||
/** | ||
* @param {InstanaConfig} config | ||
*/ | ||
function normalizeTracingHttp(config) { | ||
@@ -218,2 +292,6 @@ config.tracing.http = config.tracing.http || {}; | ||
/** | ||
* @param {string} envVarValue | ||
* @returns {Array<string>} | ||
*/ | ||
function parseHeadersEnvVar(envVarValue) { | ||
@@ -226,2 +304,5 @@ return envVarValue | ||
/** | ||
* @param {InstanaConfig} config | ||
*/ | ||
function normalizeTracingStackTraceLength(config) { | ||
@@ -251,2 +332,6 @@ if (config.tracing.stackTraceLength == null && process.env['INSTANA_STACK_TRACE_LENGTH']) { | ||
/** | ||
* @param {InstanaConfig} config | ||
* @param {string} value | ||
*/ | ||
function parseStringStackTraceLength(config, value) { | ||
@@ -267,2 +352,6 @@ config.tracing.stackTraceLength = parseInt(value, 10); | ||
/** | ||
* @param {number} numericalLength | ||
* @returns {number} | ||
*/ | ||
function normalizeNumericalStackTraceLength(numericalLength) { | ||
@@ -281,2 +370,5 @@ // just in case folks provide non-integral numbers or negative numbers | ||
/** | ||
* @param {InstanaConfig} config | ||
*/ | ||
function normalizeDisabledTracers(config) { | ||
@@ -313,2 +405,5 @@ if ( | ||
/** | ||
* @param {InstanaConfig} config | ||
*/ | ||
function normalizeSpanBatchingEnabled(config) { | ||
@@ -339,2 +434,5 @@ if (config.tracing.spanBatchingEnabled != null) { | ||
/** | ||
* @param {InstanaConfig} config | ||
*/ | ||
function normalizeDisableW3cTraceCorrelation(config) { | ||
@@ -356,2 +454,5 @@ if (config.tracing.disableW3cTraceCorrelation === true) { | ||
/** | ||
* @param {InstanaConfig} config | ||
*/ | ||
function normalizeSecrets(config) { | ||
@@ -362,2 +463,3 @@ if (config.secrets == null) { | ||
/** @type {InstanaSecretsOption} */ | ||
let fromEnvVar = {}; | ||
@@ -398,2 +500,6 @@ if (process.env.INSTANA_SECRETS) { | ||
/** | ||
* @param {string} envVarValue | ||
* @returns {InstanaSecretsOption} | ||
*/ | ||
function parseSecretsEnvVar(envVarValue) { | ||
@@ -418,9 +524,16 @@ let [matcherMode, keywords] = envVarValue.split(':', 2); | ||
} | ||
keywords = keywords.split(',').map(word => word.trim()); | ||
const keywordsArray = keywords.split(',').map(word => word.trim()); | ||
return { | ||
matcherMode, | ||
keywords | ||
keywords: keywordsArray | ||
}; | ||
} | ||
/** | ||
* @param {*} configValue | ||
* @param {*} defaultValue | ||
* @param {string} configPath | ||
* @param {string} envVarKey | ||
* @returns {*} | ||
*/ | ||
function normalizeSingleValue(configValue, defaultValue, configPath, envVarKey) { | ||
@@ -427,0 +540,0 @@ const envVarVal = process.env[envVarKey]; |
@@ -9,3 +9,11 @@ /* | ||
/** | ||
* @typedef {Object} PropertySize | ||
* @property {string} property | ||
* @property {number} length | ||
*/ | ||
/** | ||
* Calculates the size of the given object's properties when serialized to JSON. | ||
* @param {Object.<string, *>} object | ||
* @param {string} [prefix] | ||
*/ | ||
@@ -16,2 +24,4 @@ module.exports = function propertySizes(object, prefix) { | ||
} | ||
/** @type {Array<PropertySize>} */ | ||
let sizes = []; | ||
@@ -18,0 +28,0 @@ Object.keys(object).forEach(property => { |
@@ -8,2 +8,7 @@ /* | ||
/** | ||
* @type {Function} | ||
* @param {Object.<symbol, *>} object | ||
* @param {string} symbolString | ||
*/ | ||
module.exports = exports = function readSymbolProperty(object, symbolString) { | ||
@@ -10,0 +15,0 @@ const symbol = Object.getOwnPropertySymbols(object).find(sym => sym && sym.toString() === symbolString); |
@@ -11,8 +11,32 @@ /* | ||
/** | ||
* @typedef {Object} FileNamePatternTransformer | ||
* @property {Function} fn | ||
* @property {RegExp} pattern | ||
*/ | ||
/** | ||
* @typedef {Object} ExecutedHook | ||
* @property {*} originalModuleExports | ||
* @property {*} moduleExports | ||
* @property {Array<string>} appliedByModuleNameTransformers | ||
* @property {boolean} byFileNamePatternTransformersApplied | ||
*/ | ||
/** | ||
* @typedef {Object.<string, ExecutedHook>} ExecutedHooks | ||
*/ | ||
/** @type {ExecutedHooks} */ | ||
let executedHooks = {}; | ||
/** @type {Object.<string, *>} */ | ||
let byModuleNameTransformers = {}; | ||
/** @type {Array<FileNamePatternTransformer>} */ | ||
let byFileNamePatternTransformers = []; | ||
const origLoad = Module._load; | ||
const origLoad = /** @type {*} */ (Module)._load; | ||
/** @type {import('../logger').GenericLogger} */ | ||
let logger; | ||
logger = require('../logger').getLogger('util/requireHook', newLogger => { | ||
@@ -23,5 +47,8 @@ logger = newLogger; | ||
exports.init = function() { | ||
Module._load = patchedModuleLoad; | ||
/** @type {*} */ (Module)._load = patchedModuleLoad; | ||
}; | ||
/** | ||
* @param {string} moduleName | ||
*/ | ||
function patchedModuleLoad(moduleName) { | ||
@@ -31,4 +58,6 @@ // First attempt to always get the module via the original implementation | ||
const moduleExports = origLoad.apply(Module, arguments); | ||
const filename = Module._resolveFilename.apply(Module, arguments); | ||
/** @type {string} */ | ||
const filename = /** @type {*} */ (Module)._resolveFilename.apply(Module, arguments); | ||
// We are not directly manipulating the global module cache because there might be other tools fiddling with | ||
@@ -105,3 +134,3 @@ // Module._load. We don't want to break any of them. | ||
exports.teardownForTestPurposes = function() { | ||
Module._load = origLoad; | ||
/** @type {*} */ (Module)._load = origLoad; | ||
executedHooks = {}; | ||
@@ -112,2 +141,6 @@ byModuleNameTransformers = {}; | ||
/** | ||
* @param {string} moduleName | ||
* @param {Function} fn | ||
*/ | ||
exports.onModuleLoad = function on(moduleName, fn) { | ||
@@ -118,2 +151,6 @@ byModuleNameTransformers[moduleName] = byModuleNameTransformers[moduleName] || []; | ||
/** | ||
* @param {RegExp} pattern | ||
* @param {Function} fn | ||
*/ | ||
exports.onFileLoad = function onFileLoad(pattern, fn) { | ||
@@ -126,2 +163,5 @@ byFileNamePatternTransformers.push({ | ||
/** | ||
* @param {Array<string>} arr | ||
*/ | ||
exports.buildFileNamePattern = function buildFileNamePattern(arr) { | ||
@@ -131,2 +171,7 @@ return new RegExp(`${arr.reduce(buildFileNamePatternReducer, '')}$`); | ||
/** | ||
* @param {string} agg | ||
* @param {string} pathSegment | ||
* @returns {string} | ||
*/ | ||
function buildFileNamePatternReducer(agg, pathSegment) { | ||
@@ -133,0 +178,0 @@ if (agg.length > 0) { |
@@ -10,5 +10,14 @@ /* | ||
/** | ||
* @typedef {Object} SlidingWindowOptions | ||
* @property {number} [duration] | ||
*/ | ||
/** | ||
* @param {SlidingWindowOptions} opts | ||
*/ | ||
exports.create = function createSlidingWindow(opts) { | ||
const duration = opts.duration; | ||
/** @type {Array<*>} */ | ||
let values = []; | ||
@@ -26,2 +35,5 @@ | ||
/** | ||
* @param {*} v | ||
*/ | ||
function addPoint(v) { | ||
@@ -32,2 +44,6 @@ values.push([Date.now(), v]); | ||
/** | ||
* @param {Function} reducer | ||
* @param {*} initial | ||
*/ | ||
function reduce(reducer, initial) { | ||
@@ -66,2 +82,5 @@ cleanup(); | ||
/** | ||
* @param {Array<number>} percentiles | ||
*/ | ||
function getPercentiles(percentiles) { | ||
@@ -94,2 +113,6 @@ cleanup(); | ||
/** | ||
* @param {Array<*>} values | ||
* @param {number} duration | ||
*/ | ||
function removeOldPoints(values, duration) { | ||
@@ -96,0 +119,0 @@ let itemsToRemove = 0; |
@@ -11,2 +11,8 @@ /* | ||
/** | ||
* @param {number} length | ||
* @param {Function} referenceFunction | ||
* @param {number} [drop] | ||
* @returns {object} | ||
*/ | ||
exports.captureStackTrace = function captureStackTrace(length, referenceFunction, drop = 0) { | ||
@@ -22,2 +28,3 @@ if (length <= 0) { | ||
Error.prepareStackTrace = jsonPrepareStackTrace; | ||
/** @type {*} */ | ||
const stackTraceTarget = {}; | ||
@@ -41,2 +48,6 @@ Error.captureStackTrace(stackTraceTarget, referenceFunction); | ||
/** | ||
* @param {number} length | ||
* @param {Error} error | ||
*/ | ||
exports.getStackTraceAsJson = function getStackTraceAsJson(length, error) { | ||
@@ -55,7 +66,11 @@ if (length <= 0) { | ||
Error.prepareStackTrace = originalPrepareStackTrace; | ||
const jsonStackTrace = error._jsonStackTrace; | ||
delete error._jsonStackTrace; | ||
const jsonStackTrace = /** @type {*} */ (error)._jsonStackTrace; | ||
delete /** @type {*} */ (error)._jsonStackTrace; | ||
return jsonStackTrace; | ||
}; | ||
/** | ||
* @param {Error} error | ||
* @param {Array<*>} structuredStackTrace | ||
*/ | ||
function jsonPrepareStackTrace(error, structuredStackTrace) { | ||
@@ -65,7 +80,15 @@ return jsonifyStackTrace(structuredStackTrace); | ||
/** | ||
* @param {Error} error | ||
* @param {Array<*>} structuredStackTrace | ||
*/ | ||
function attachJsonStackTrace(error, structuredStackTrace) { | ||
error._jsonStackTrace = jsonifyStackTrace(structuredStackTrace); | ||
/** @type {*} */ (error)._jsonStackTrace = jsonifyStackTrace(structuredStackTrace); | ||
return defaultPrepareStackTrace(error, structuredStackTrace); | ||
} | ||
/** | ||
* @param {Array<*>} structuredStackTrace | ||
* @returns {object} | ||
*/ | ||
function jsonifyStackTrace(structuredStackTrace) { | ||
@@ -87,2 +110,5 @@ const len = structuredStackTrace.length; | ||
/** | ||
* @param {Function | *} callSite | ||
*/ | ||
exports.buildFunctionIdentifier = function buildFunctionIdentifier(callSite) { | ||
@@ -122,2 +148,6 @@ if (callSite.isConstructor()) { | ||
/** | ||
* @param {Error} error | ||
* @param {Array<*>} frames | ||
*/ | ||
function defaultPrepareStackTrace(error, frames) { | ||
@@ -124,0 +154,0 @@ frames.push(error); |
@@ -8,2 +8,5 @@ /* | ||
/** | ||
* @param {Array<*>} arr | ||
*/ | ||
module.exports = function uniq(arr) { | ||
@@ -10,0 +13,0 @@ if (arr.length < 2) { |
@@ -10,2 +10,6 @@ /* | ||
/** | ||
* @param {string} url | ||
* @returns {string} | ||
*/ | ||
exports.discardUrlParameters = function discardUrlParameters(url) { | ||
@@ -18,2 +22,7 @@ let index = getCharCountUntilOccurenceOfChar(url, '?'); | ||
/** | ||
* @param {string} s | ||
* @param {string} char | ||
* @returns {number} | ||
*/ | ||
function getCharCountUntilOccurenceOfChar(s, char) { | ||
@@ -24,2 +33,5 @@ const index = s.indexOf(char); | ||
/** | ||
* @param {string} queryString | ||
*/ | ||
exports.filterParams = function filterParams(queryString) { | ||
@@ -26,0 +38,0 @@ if (!queryString || queryString === '') { |
457960
91
12727