From f7e8846d9eae0b75fda152d437bd1b2d4820408e Mon Sep 17 00:00:00 2001 From: jacques metevier Date: Wed, 7 Jun 2023 16:17:41 -0700 Subject: [PATCH 01/10] chore upgrade eslint packages --- .eslintrc.json | 8 +- package-lock.json | 1714 ++++++++++++++++++++++----------------------- package.json | 13 +- 3 files changed, 843 insertions(+), 892 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 9648af87d7..a5692d90ae 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -4,11 +4,11 @@ "node": true }, "extends": "standard", - "plugins": [ - "license-header" - ], + "plugins": ["license-header"], "rules": { - "license-header/header": [ "error", "./dev-utils/license-header.js" ] + "license-header/header": ["error", "./dev-utils/license-header.js"], + "no-var":0, + "array-callback-return":0 }, "ignorePatterns": [ "/*.example.js", // a pattern for uncommited local dev files to avoid linting diff --git a/package-lock.json b/package-lock.json index 62de9307d3..bca7cf14a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -73,12 +73,12 @@ "dependency-check": "^4.1.0", "diagnostics_channel": "^1.1.0", "elasticsearch": "^16.7.3", - "eslint": "^6.8.0", - "eslint-config-standard": "^14.1.1", - "eslint-plugin-import": "^2.25.4", + "eslint": "^8.42.0", + "eslint-config-standard": "^16", + "eslint-plugin-import": "^2.27.5", "eslint-plugin-license-header": "^0.6.0", "eslint-plugin-node": "^11.1.0", - "eslint-plugin-promise": "^4.3.1", + "eslint-plugin-promise": "^6.1.1", "eslint-plugin-standard": "^4.1.0", "express": "^4.17.1", "express-queue": "^0.0.13", @@ -4074,6 +4074,123 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", + "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", + "dev": true, + "dependencies": { + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz", + "integrity": "sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.5.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.5.1.tgz", + "integrity": "sha512-Z5ba73P98O1KUYCCJTUeVpja9RcGoMdncZ6T49FCUl2lN38JtCJ+3WgIDBv0AuY4WChU5PmtJmOCTlN6FZTFKQ==", + "dev": true, + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/eslintrc": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.0.3.tgz", + "integrity": "sha512-+5gy6OQfk+xx3q0d6jGZZC3f3KzAkXc/IanVxd1is/VIIziRqqt3ongQz0FiTUXqTk0c7aDB3OaFuKnuSoJicQ==", + "dev": true, + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^9.5.2", + "globals": "^13.19.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/eslintrc/node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/@eslint/eslintrc/node_modules/globals": { + "version": "13.20.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", + "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", + "dev": true, + "dependencies": { + "type-fest": "^0.20.2" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@eslint/eslintrc/node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "node_modules/@eslint/eslintrc/node_modules/type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@eslint/js": { + "version": "8.42.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.42.0.tgz", + "integrity": "sha512-6SWlXpWU5AvId8Ac7zjzmIOqMOba/JWY8XZ4A7q7Gn1Vlfg/SFFIlrtHXt9nPn4op9ZPAkl91Jao+QQv3r/ukw==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, "node_modules/@fastify/ajv-compiler": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/@fastify/ajv-compiler/-/ajv-compiler-3.5.0.tgz", @@ -4716,6 +4833,39 @@ "integrity": "sha512-aKmlCO57XFZ26wso4rJsW4oTUnrgTFw2jh3io7CAtO9w4UltBNwRXvXIVzzyfkaaLRo3nluP/19msA8vDUUuKw==", "dev": true }, + "node_modules/@humanwhocodes/config-array": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz", + "integrity": "sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==", + "dev": true, + "dependencies": { + "@humanwhocodes/object-schema": "^1.2.1", + "debug": "^4.1.1", + "minimatch": "^3.0.5" + }, + "engines": { + "node": ">=10.10.0" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/object-schema": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", + "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", + "dev": true + }, "node_modules/@ioredis/commands": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@ioredis/commands/-/commands-1.2.0.tgz", @@ -6202,15 +6352,6 @@ "node": ">=0.8" } }, - "node_modules/astral-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", - "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/async": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/async/-/async-3.2.3.tgz", @@ -7473,28 +7614,32 @@ } }, "node_modules/cross-spawn": { - "version": "6.0.5", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", - "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", "dev": true, "dependencies": { - "nice-try": "^1.0.4", - "path-key": "^2.0.1", - "semver": "^5.5.0", - "shebang-command": "^1.2.0", - "which": "^1.2.9" + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" }, "engines": { - "node": ">=4.8" + "node": ">= 8" } }, - "node_modules/cross-spawn/node_modules/semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "node_modules/cross-spawn/node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, "bin": { - "semver": "bin/semver" + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" } }, "node_modules/cssfilter": { @@ -8303,70 +8448,85 @@ } }, "node_modules/eslint": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.8.0.tgz", - "integrity": "sha512-K+Iayyo2LtyYhDSYwz5D5QdWw0hCacNzyq1Y821Xna2xSJj7cijoLLYmLxTQgcgZ9mC61nryMy9S7GRbYpI5Ig==", - "dev": true, - "dependencies": { - "@babel/code-frame": "^7.0.0", + "version": "8.42.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.42.0.tgz", + "integrity": "sha512-ulg9Ms6E1WPf67PHaEY4/6E2tEn5/f7FXGzr3t9cBMugOmf1INYvuUwwh1aXQN4MfJ6a5K2iNwP3w4AColvI9A==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.4.0", + "@eslint/eslintrc": "^2.0.3", + "@eslint/js": "8.42.0", + "@humanwhocodes/config-array": "^0.11.10", + "@humanwhocodes/module-importer": "^1.0.1", + "@nodelib/fs.walk": "^1.2.8", "ajv": "^6.10.0", - "chalk": "^2.1.0", - "cross-spawn": "^6.0.5", - "debug": "^4.0.1", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", "doctrine": "^3.0.0", - "eslint-scope": "^5.0.0", - "eslint-utils": "^1.4.3", - "eslint-visitor-keys": "^1.1.0", - "espree": "^6.1.2", - "esquery": "^1.0.1", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^7.2.0", + "eslint-visitor-keys": "^3.4.1", + "espree": "^9.5.2", + "esquery": "^1.4.2", "esutils": "^2.0.2", - "file-entry-cache": "^5.0.1", - "functional-red-black-tree": "^1.0.1", - "glob-parent": "^5.0.0", - "globals": "^12.1.0", - "ignore": "^4.0.6", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^6.0.1", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "globals": "^13.19.0", + "graphemer": "^1.4.0", + "ignore": "^5.2.0", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", - "inquirer": "^7.0.0", "is-glob": "^4.0.0", - "js-yaml": "^3.13.1", + "is-path-inside": "^3.0.3", + "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.3.0", - "lodash": "^4.17.14", - "minimatch": "^3.0.4", - "mkdirp": "^0.5.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", "natural-compare": "^1.4.0", - "optionator": "^0.8.3", - "progress": "^2.0.0", - "regexpp": "^2.0.1", - "semver": "^6.1.2", - "strip-ansi": "^5.2.0", - "strip-json-comments": "^3.0.1", - "table": "^5.2.3", - "text-table": "^0.2.0", - "v8-compile-cache": "^2.0.3" + "optionator": "^0.9.1", + "strip-ansi": "^6.0.1", + "strip-json-comments": "^3.1.0", + "text-table": "^0.2.0" }, "bin": { "eslint": "bin/eslint.js" }, "engines": { - "node": "^8.10.0 || ^10.13.0 || >=11.10.1" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "funding": { "url": "https://opencollective.com/eslint" } }, "node_modules/eslint-config-standard": { - "version": "14.1.1", - "resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-14.1.1.tgz", - "integrity": "sha512-Z9B+VR+JIXRxz21udPTL9HpFMyoMUEeX1G251EQ6e05WD9aPVtVBn09XUmZ259wCMlCDmYDSZG62Hhm+ZTJcUg==", + "version": "16.0.3", + "resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-16.0.3.tgz", + "integrity": "sha512-x4fmJL5hGqNJKGHSjnLdgA6U6h1YW/G2dW9fA+cyVur4SK6lyue8+UgNKWlZtUDTXvgKDD/Oa3GQjmB5kjtVvg==", "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], "peerDependencies": { - "eslint": ">=6.2.2", - "eslint-plugin-import": ">=2.18.0", - "eslint-plugin-node": ">=9.1.0", - "eslint-plugin-promise": ">=4.2.1", - "eslint-plugin-standard": ">=4.0.0" + "eslint": "^7.12.1", + "eslint-plugin-import": "^2.22.1", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-promise": "^4.2.1 || ^5.0.0" } }, "node_modules/eslint-import-resolver-node": { @@ -8556,12 +8716,15 @@ } }, "node_modules/eslint-plugin-promise": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-4.3.1.tgz", - "integrity": "sha512-bY2sGqyptzFBDLh/GMbAxfdJC+b0f23ME63FOE4+Jao0oZ3E1LEwFtWJX/1pGMJLiTtrSSern2CRM/g+dfc0eQ==", + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-6.1.1.tgz", + "integrity": "sha512-tjqWDwVZQo7UIPMeDReOpUgHCmCiH+ePnVT+5zVapL0uuHnegBUs2smM13CzOs2Xb5+MHMRFTs9v24yjba4Oig==", "dev": true, "engines": { - "node": ">=6" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" } }, "node_modules/eslint-plugin-standard": { @@ -8588,28 +8751,19 @@ } }, "node_modules/eslint-scope": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", - "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.0.tgz", + "integrity": "sha512-DYj5deGlHBfMt15J7rdtyKNq/Nqlv5KfU4iodrQ019XESsRnwXH9KAE0y3cwtUHDo2ob7CypAnCqefh6vioWRw==", "dev": true, "dependencies": { "esrecurse": "^4.3.0", - "estraverse": "^4.1.1" + "estraverse": "^5.2.0" }, "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/eslint-utils": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.3.tgz", - "integrity": "sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q==", - "dev": true, - "dependencies": { - "eslint-visitor-keys": "^1.1.0" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, - "engines": { - "node": ">=6" + "funding": { + "url": "https://opencollective.com/eslint" } }, "node_modules/eslint-visitor-keys": { @@ -8637,50 +8791,117 @@ "url": "https://github.com/sponsors/epoberezkin" } }, - "node_modules/eslint/node_modules/ansi-regex": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", - "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", + "node_modules/eslint/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/eslint/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, "engines": { - "node": ">=6" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/eslint/node_modules/globals": { - "version": "12.4.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz", - "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==", + "node_modules/eslint/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, "dependencies": { - "type-fest": "^0.8.1" + "color-name": "~1.1.4" }, "engines": { - "node": ">=8" + "node": ">=7.0.0" + } + }, + "node_modules/eslint/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/eslint/node_modules/eslint-visitor-keys": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz", + "integrity": "sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint/node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/eslint/node_modules/ignore": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", - "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "node_modules/eslint/node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", "dev": true, + "dependencies": { + "is-glob": "^4.0.3" + }, "engines": { - "node": ">= 4" + "node": ">=10.13.0" } }, - "node_modules/eslint/node_modules/js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "node_modules/eslint/node_modules/globals": { + "version": "13.20.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", + "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", "dev": true, "dependencies": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" + "type-fest": "^0.20.2" }, - "bin": { - "js-yaml": "bin/js-yaml.js" + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" } }, "node_modules/eslint/node_modules/json-schema-traverse": { @@ -8689,16 +8910,73 @@ "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "dev": true }, - "node_modules/eslint/node_modules/strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "node_modules/eslint/node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", "dev": true, "dependencies": { - "ansi-regex": "^4.1.0" + "p-locate": "^5.0.0" }, "engines": { - "node": ">=6" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint/node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint/node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/eslint/node_modules/type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/esm": { @@ -8711,17 +8989,44 @@ } }, "node_modules/espree": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-6.2.1.tgz", - "integrity": "sha512-ysCxRQY3WaXJz9tdbWOwuWr5Y/XrPTGX9Kiz3yoUXwW0VZ4w30HTkQLaGx/+ttFjF8i+ACbArnB4ce68a9m5hw==", + "version": "9.5.2", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.5.2.tgz", + "integrity": "sha512-7OASN1Wma5fum5SrNhFMAMJxOUAbhyfQ8dQ//PJaJbNw0URTPWqIghHWt1MmAANKhHZIYOHruW4Kw4ruUWOdGw==", "dev": true, "dependencies": { - "acorn": "^7.1.1", - "acorn-jsx": "^5.2.0", - "eslint-visitor-keys": "^1.1.0" + "acorn": "^8.8.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.4.1" }, "engines": { - "node": ">=6.0.0" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/espree/node_modules/acorn": { + "version": "8.8.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", + "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/espree/node_modules/eslint-visitor-keys": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz", + "integrity": "sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, "node_modules/esprima": { @@ -8738,9 +9043,9 @@ } }, "node_modules/esquery": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", - "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", + "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", "dev": true, "dependencies": { "estraverse": "^5.1.0" @@ -8749,15 +9054,6 @@ "node": ">=0.10" } }, - "node_modules/esquery/node_modules/estraverse": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", - "dev": true, - "engines": { - "node": ">=4.0" - } - }, "node_modules/esrecurse": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", @@ -8770,7 +9066,7 @@ "node": ">=4.0" } }, - "node_modules/esrecurse/node_modules/estraverse": { + "node_modules/estraverse": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", @@ -8779,15 +9075,6 @@ "node": ">=4.0" } }, - "node_modules/estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "dev": true, - "engines": { - "node": ">=4.0" - } - }, "node_modules/esutils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", @@ -9140,7 +9427,7 @@ "node_modules/fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "dev": true }, "node_modules/fast-querystring": { @@ -9353,15 +9640,15 @@ } }, "node_modules/file-entry-cache": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz", - "integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", + "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", "dev": true, "dependencies": { - "flat-cache": "^2.0.1" + "flat-cache": "^3.0.4" }, "engines": { - "node": ">=4" + "node": "^10.12.0 || >=12.0.0" } }, "node_modules/fill-range": { @@ -9478,29 +9765,16 @@ } }, "node_modules/flat-cache": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", - "integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", + "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", "dev": true, "dependencies": { - "flatted": "^2.0.0", - "rimraf": "2.6.3", - "write": "1.0.3" + "flatted": "^3.1.0", + "rimraf": "^3.0.2" }, "engines": { - "node": ">=4" - } - }, - "node_modules/flat-cache/node_modules/rimraf": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", - "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", - "dev": true, - "dependencies": { - "glob": "^7.1.3" - }, - "bin": { - "rimraf": "bin.js" + "node": "^10.12.0 || >=12.0.0" } }, "node_modules/flatstr": { @@ -9509,9 +9783,9 @@ "integrity": "sha512-4zPxDyhCyiN2wIAtSLI6gc82/EjqZc1onI4Mz/l0pWrAlsSfYH/2ZIcU+e3oA2wDwbzIWNKwa23F8rh6+DRWkw==" }, "node_modules/flatted": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.2.tgz", - "integrity": "sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==", + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.7.tgz", + "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==", "dev": true }, "node_modules/fn.name": { @@ -9561,65 +9835,6 @@ "node": ">=8.0.0" } }, - "node_modules/foreground-child/node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dev": true, - "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/foreground-child/node_modules/path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/foreground-child/node_modules/shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, - "dependencies": { - "shebang-regex": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/foreground-child/node_modules/shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/foreground-child/node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" - } - }, "node_modules/forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", @@ -9744,12 +9959,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/functional-red-black-tree": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", - "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", - "dev": true - }, "node_modules/functions-have-names": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", @@ -9999,6 +10208,12 @@ "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", "dev": true }, + "node_modules/graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "dev": true + }, "node_modules/graphql": { "version": "16.6.0", "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.6.0.tgz", @@ -11220,20 +11435,6 @@ "node": ">=8" } }, - "node_modules/istanbul-lib-processinfo/node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dev": true, - "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "engines": { - "node": ">= 8" - } - }, "node_modules/istanbul-lib-processinfo/node_modules/make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", @@ -11261,36 +11462,6 @@ "node": ">=8" } }, - "node_modules/istanbul-lib-processinfo/node_modules/path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/istanbul-lib-processinfo/node_modules/shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, - "dependencies": { - "shebang-regex": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/istanbul-lib-processinfo/node_modules/shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/istanbul-lib-processinfo/node_modules/uuid": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", @@ -11298,22 +11469,7 @@ "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", "dev": true, "bin": { - "uuid": "bin/uuid" - } - }, - "node_modules/istanbul-lib-processinfo/node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" + "uuid": "bin/uuid" } }, "node_modules/istanbul-lib-report": { @@ -11886,13 +12042,13 @@ } }, "node_modules/levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", "dev": true, "dependencies": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" }, "engines": { "node": ">= 0.8.0" @@ -12678,12 +12834,6 @@ "resolved": "https://registry.npmjs.org/next-line/-/next-line-1.1.0.tgz", "integrity": "sha1-/K5XhTBStqm66CCOQN19PC0wRgM=" }, - "node_modules/nice-try": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", - "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", - "dev": true - }, "node_modules/node-abort-controller": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/node-abort-controller/-/node-abort-controller-3.1.1.tgz", @@ -13212,17 +13362,17 @@ "integrity": "sha512-B0LLi+Vg+eko++0z/b8zIv57kp7HKEzaPJo7LowJXMUKYdf+3XJGu/cw03h/JhIOsLnP+cG5QnTHAuicjA5fMw==" }, "node_modules/optionator": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", - "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", + "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", "dev": true, "dependencies": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.6", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "word-wrap": "~1.2.3" + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.3" }, "engines": { "node": ">= 0.8.0" @@ -13459,12 +13609,12 @@ } }, "node_modules/path-key": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", - "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", "dev": true, "engines": { - "node": ">=4" + "node": ">=8" } }, "node_modules/path-parse": { @@ -13883,9 +14033,9 @@ } }, "node_modules/prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true, "engines": { "node": ">= 0.8.0" @@ -13923,15 +14073,6 @@ "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-1.0.0.tgz", "integrity": "sha512-du4wfLyj4yCZq1VupnVSZmRsPJsNuxoDQFdCFHLaYiEbFBD7QE0a+I4D7hOxrVnh78QE/YipFAj9lXHiXocV+Q==" }, - "node_modules/progress": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", - "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", - "dev": true, - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/proxy-addr": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", @@ -14449,15 +14590,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/regexpp": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", - "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", - "dev": true, - "engines": { - "node": ">=6.5.0" - } - }, "node_modules/regexpu-core": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-5.3.2.tgz", @@ -15221,24 +15353,24 @@ "integrity": "sha512-YRNymdiL3KGOoS67d73TEmk4tdPTO9GSMCoiphQsTcC9EtC+AOmMPjkyBkRoCJfW9ASsaZw1craaiw1dPN2D3Q==" }, "node_modules/shebang-command": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", - "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", "dev": true, "dependencies": { - "shebang-regex": "^1.0.0" + "shebang-regex": "^3.0.0" }, "engines": { - "node": ">=0.10.0" + "node": ">=8" } }, "node_modules/shebang-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true, "engines": { - "node": ">=0.10.0" + "node": ">=8" } }, "node_modules/side-channel": { @@ -15290,29 +15422,6 @@ "node": ">=6" } }, - "node_modules/slice-ansi": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", - "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==", - "dev": true, - "dependencies": { - "ansi-styles": "^3.2.0", - "astral-regex": "^1.0.0", - "is-fullwidth-code-point": "^2.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/slice-ansi/node_modules/is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/smart-buffer": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", @@ -15776,93 +15885,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/table": { - "version": "5.4.6", - "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz", - "integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==", - "dev": true, - "dependencies": { - "ajv": "^6.10.2", - "lodash": "^4.17.14", - "slice-ansi": "^2.1.0", - "string-width": "^3.0.0" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/table/node_modules/ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "dev": true, - "dependencies": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/table/node_modules/ansi-regex": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", - "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/table/node_modules/emoji-regex": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", - "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", - "dev": true - }, - "node_modules/table/node_modules/is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/table/node_modules/json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true - }, - "node_modules/table/node_modules/string-width": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", - "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", - "dev": true, - "dependencies": { - "emoji-regex": "^7.0.1", - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^5.1.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/table/node_modules/strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "dev": true, - "dependencies": { - "ansi-regex": "^4.1.0" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/tap-junit": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/tap-junit/-/tap-junit-5.0.2.tgz", @@ -16410,12 +16432,12 @@ "dev": true }, "node_modules/type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", "dev": true, "dependencies": { - "prelude-ls": "~1.1.2" + "prelude-ls": "^1.2.1" }, "engines": { "node": ">= 0.8.0" @@ -16681,12 +16703,6 @@ "uuid": "dist/bin/uuid" } }, - "node_modules/v8-compile-cache": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", - "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", - "dev": true - }, "node_modules/validate-npm-package-license": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", @@ -17023,18 +17039,6 @@ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, - "node_modules/write": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz", - "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==", - "dev": true, - "dependencies": { - "mkdirp": "^0.5.1" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/write-file-atomic": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz", @@ -20230,6 +20234,87 @@ } } }, + "@eslint-community/eslint-utils": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", + "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^3.3.0" + }, + "dependencies": { + "eslint-visitor-keys": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz", + "integrity": "sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA==", + "dev": true + } + } + }, + "@eslint-community/regexpp": { + "version": "4.5.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.5.1.tgz", + "integrity": "sha512-Z5ba73P98O1KUYCCJTUeVpja9RcGoMdncZ6T49FCUl2lN38JtCJ+3WgIDBv0AuY4WChU5PmtJmOCTlN6FZTFKQ==", + "dev": true + }, + "@eslint/eslintrc": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.0.3.tgz", + "integrity": "sha512-+5gy6OQfk+xx3q0d6jGZZC3f3KzAkXc/IanVxd1is/VIIziRqqt3ongQz0FiTUXqTk0c7aDB3OaFuKnuSoJicQ==", + "dev": true, + "requires": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^9.5.2", + "globals": "^13.19.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "dependencies": { + "ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "globals": { + "version": "13.20.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", + "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", + "dev": true, + "requires": { + "type-fest": "^0.20.2" + } + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "dev": true + } + } + }, + "@eslint/js": { + "version": "8.42.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.42.0.tgz", + "integrity": "sha512-6SWlXpWU5AvId8Ac7zjzmIOqMOba/JWY8XZ4A7q7Gn1Vlfg/SFFIlrtHXt9nPn4op9ZPAkl91Jao+QQv3r/ukw==", + "dev": true + }, "@fastify/ajv-compiler": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/@fastify/ajv-compiler/-/ajv-compiler-3.5.0.tgz", @@ -20893,6 +20978,29 @@ } } }, + "@humanwhocodes/config-array": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz", + "integrity": "sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==", + "dev": true, + "requires": { + "@humanwhocodes/object-schema": "^1.2.1", + "debug": "^4.1.1", + "minimatch": "^3.0.5" + } + }, + "@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true + }, + "@humanwhocodes/object-schema": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", + "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", + "dev": true + }, "@ioredis/commands": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@ioredis/commands/-/commands-1.2.0.tgz", @@ -22123,12 +22231,6 @@ "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", "dev": true }, - "astral-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", - "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", - "dev": true - }, "async": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/async/-/async-3.2.3.tgz", @@ -23118,23 +23220,24 @@ } }, "cross-spawn": { - "version": "6.0.5", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", - "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", "dev": true, "requires": { - "nice-try": "^1.0.4", - "path-key": "^2.0.1", - "semver": "^5.5.0", - "shebang-command": "^1.2.0", - "which": "^1.2.9" + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" }, "dependencies": { - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } } } }, @@ -23773,48 +23876,50 @@ "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==" }, "eslint": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.8.0.tgz", - "integrity": "sha512-K+Iayyo2LtyYhDSYwz5D5QdWw0hCacNzyq1Y821Xna2xSJj7cijoLLYmLxTQgcgZ9mC61nryMy9S7GRbYpI5Ig==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", + "version": "8.42.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.42.0.tgz", + "integrity": "sha512-ulg9Ms6E1WPf67PHaEY4/6E2tEn5/f7FXGzr3t9cBMugOmf1INYvuUwwh1aXQN4MfJ6a5K2iNwP3w4AColvI9A==", + "dev": true, + "requires": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.4.0", + "@eslint/eslintrc": "^2.0.3", + "@eslint/js": "8.42.0", + "@humanwhocodes/config-array": "^0.11.10", + "@humanwhocodes/module-importer": "^1.0.1", + "@nodelib/fs.walk": "^1.2.8", "ajv": "^6.10.0", - "chalk": "^2.1.0", - "cross-spawn": "^6.0.5", - "debug": "^4.0.1", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", "doctrine": "^3.0.0", - "eslint-scope": "^5.0.0", - "eslint-utils": "^1.4.3", - "eslint-visitor-keys": "^1.1.0", - "espree": "^6.1.2", - "esquery": "^1.0.1", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^7.2.0", + "eslint-visitor-keys": "^3.4.1", + "espree": "^9.5.2", + "esquery": "^1.4.2", "esutils": "^2.0.2", - "file-entry-cache": "^5.0.1", - "functional-red-black-tree": "^1.0.1", - "glob-parent": "^5.0.0", - "globals": "^12.1.0", - "ignore": "^4.0.6", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^6.0.1", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "globals": "^13.19.0", + "graphemer": "^1.4.0", + "ignore": "^5.2.0", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", - "inquirer": "^7.0.0", "is-glob": "^4.0.0", - "js-yaml": "^3.13.1", + "is-path-inside": "^3.0.3", + "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.3.0", - "lodash": "^4.17.14", - "minimatch": "^3.0.4", - "mkdirp": "^0.5.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", "natural-compare": "^1.4.0", - "optionator": "^0.8.3", - "progress": "^2.0.0", - "regexpp": "^2.0.1", - "semver": "^6.1.2", - "strip-ansi": "^5.2.0", - "strip-json-comments": "^3.0.1", - "table": "^5.2.3", - "text-table": "^0.2.0", - "v8-compile-cache": "^2.0.3" + "optionator": "^0.9.1", + "strip-ansi": "^6.0.1", + "strip-json-comments": "^3.1.0", + "text-table": "^0.2.0" }, "dependencies": { "ajv": { @@ -23829,58 +23934,134 @@ "uri-js": "^4.2.2" } }, - "ansi-regex": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", - "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "eslint-visitor-keys": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz", + "integrity": "sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA==", "dev": true }, - "globals": { - "version": "12.4.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz", - "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==", + "find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", "dev": true, "requires": { - "type-fest": "^0.8.1" + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" } }, - "ignore": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", - "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", - "dev": true + "glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "requires": { + "is-glob": "^4.0.3" + } }, - "js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "globals": { + "version": "13.20.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", + "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", "dev": true, "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" + "type-fest": "^0.20.2" } }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, "json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "dev": true }, - "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "requires": { + "p-locate": "^5.0.0" + } + }, + "p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "requires": { + "yocto-queue": "^0.1.0" + } + }, + "p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "requires": { + "p-limit": "^3.0.2" + } + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, "requires": { - "ansi-regex": "^4.1.0" + "has-flag": "^4.0.0" } + }, + "type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "dev": true } } }, "eslint-config-standard": { - "version": "14.1.1", - "resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-14.1.1.tgz", - "integrity": "sha512-Z9B+VR+JIXRxz21udPTL9HpFMyoMUEeX1G251EQ6e05WD9aPVtVBn09XUmZ259wCMlCDmYDSZG62Hhm+ZTJcUg==", + "version": "16.0.3", + "resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-16.0.3.tgz", + "integrity": "sha512-x4fmJL5hGqNJKGHSjnLdgA6U6h1YW/G2dW9fA+cyVur4SK6lyue8+UgNKWlZtUDTXvgKDD/Oa3GQjmB5kjtVvg==", "dev": true }, "eslint-import-resolver-node": { @@ -24030,9 +24211,9 @@ } }, "eslint-plugin-promise": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-4.3.1.tgz", - "integrity": "sha512-bY2sGqyptzFBDLh/GMbAxfdJC+b0f23ME63FOE4+Jao0oZ3E1LEwFtWJX/1pGMJLiTtrSSern2CRM/g+dfc0eQ==", + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-6.1.1.tgz", + "integrity": "sha512-tjqWDwVZQo7UIPMeDReOpUgHCmCiH+ePnVT+5zVapL0uuHnegBUs2smM13CzOs2Xb5+MHMRFTs9v24yjba4Oig==", "dev": true }, "eslint-plugin-standard": { @@ -24042,22 +24223,13 @@ "dev": true }, "eslint-scope": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", - "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.0.tgz", + "integrity": "sha512-DYj5deGlHBfMt15J7rdtyKNq/Nqlv5KfU4iodrQ019XESsRnwXH9KAE0y3cwtUHDo2ob7CypAnCqefh6vioWRw==", "dev": true, "requires": { "esrecurse": "^4.3.0", - "estraverse": "^4.1.1" - } - }, - "eslint-utils": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.3.tgz", - "integrity": "sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q==", - "dev": true, - "requires": { - "eslint-visitor-keys": "^1.1.0" + "estraverse": "^5.2.0" } }, "eslint-visitor-keys": { @@ -24073,14 +24245,28 @@ "dev": true }, "espree": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-6.2.1.tgz", - "integrity": "sha512-ysCxRQY3WaXJz9tdbWOwuWr5Y/XrPTGX9Kiz3yoUXwW0VZ4w30HTkQLaGx/+ttFjF8i+ACbArnB4ce68a9m5hw==", + "version": "9.5.2", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.5.2.tgz", + "integrity": "sha512-7OASN1Wma5fum5SrNhFMAMJxOUAbhyfQ8dQ//PJaJbNw0URTPWqIghHWt1MmAANKhHZIYOHruW4Kw4ruUWOdGw==", "dev": true, "requires": { - "acorn": "^7.1.1", - "acorn-jsx": "^5.2.0", - "eslint-visitor-keys": "^1.1.0" + "acorn": "^8.8.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.4.1" + }, + "dependencies": { + "acorn": { + "version": "8.8.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", + "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==", + "dev": true + }, + "eslint-visitor-keys": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz", + "integrity": "sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA==", + "dev": true + } } }, "esprima": { @@ -24090,20 +24276,12 @@ "dev": true }, "esquery": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", - "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", + "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", "dev": true, "requires": { "estraverse": "^5.1.0" - }, - "dependencies": { - "estraverse": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", - "dev": true - } } }, "esrecurse": { @@ -24113,20 +24291,12 @@ "dev": true, "requires": { "estraverse": "^5.2.0" - }, - "dependencies": { - "estraverse": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", - "dev": true - } } }, "estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", "dev": true }, "esutils": { @@ -24420,7 +24590,7 @@ "fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "dev": true }, "fast-querystring": { @@ -24605,12 +24775,12 @@ } }, "file-entry-cache": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz", - "integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", + "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", "dev": true, "requires": { - "flat-cache": "^2.0.1" + "flat-cache": "^3.0.4" } }, "fill-range": { @@ -24704,25 +24874,13 @@ } }, "flat-cache": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", - "integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", + "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", "dev": true, "requires": { - "flatted": "^2.0.0", - "rimraf": "2.6.3", - "write": "1.0.3" - }, - "dependencies": { - "rimraf": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", - "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", - "dev": true, - "requires": { - "glob": "^7.1.3" - } - } + "flatted": "^3.1.0", + "rimraf": "^3.0.2" } }, "flatstr": { @@ -24731,9 +24889,9 @@ "integrity": "sha512-4zPxDyhCyiN2wIAtSLI6gc82/EjqZc1onI4Mz/l0pWrAlsSfYH/2ZIcU+e3oA2wDwbzIWNKwa23F8rh6+DRWkw==" }, "flatted": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.2.tgz", - "integrity": "sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==", + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.7.tgz", + "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==", "dev": true }, "fn.name": { @@ -24764,49 +24922,6 @@ "requires": { "cross-spawn": "^7.0.0", "signal-exit": "^3.0.2" - }, - "dependencies": { - "cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dev": true, - "requires": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - } - }, - "path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true - }, - "shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, - "requires": { - "shebang-regex": "^3.0.0" - } - }, - "shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true - }, - "which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } - } } }, "forever-agent": { @@ -24890,12 +25005,6 @@ "functions-have-names": "^1.2.2" } }, - "functional-red-black-tree": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", - "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", - "dev": true - }, "functions-have-names": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", @@ -25075,6 +25184,12 @@ "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", "dev": true }, + "graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "dev": true + }, "graphql": { "version": "16.6.0", "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.6.0.tgz", @@ -25975,17 +26090,6 @@ "uuid": "^3.3.3" }, "dependencies": { - "cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dev": true, - "requires": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - } - }, "make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", @@ -26004,41 +26108,11 @@ "aggregate-error": "^3.0.0" } }, - "path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true - }, - "shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, - "requires": { - "shebang-regex": "^3.0.0" - } - }, - "shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true - }, "uuid": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", "dev": true - }, - "which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } } } }, @@ -26501,13 +26575,13 @@ } }, "levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", "dev": true, "requires": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" } }, "light-my-request": { @@ -27153,12 +27227,6 @@ "resolved": "https://registry.npmjs.org/next-line/-/next-line-1.1.0.tgz", "integrity": "sha1-/K5XhTBStqm66CCOQN19PC0wRgM=" }, - "nice-try": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", - "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", - "dev": true - }, "node-abort-controller": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/node-abort-controller/-/node-abort-controller-3.1.1.tgz", @@ -27571,17 +27639,17 @@ "integrity": "sha512-B0LLi+Vg+eko++0z/b8zIv57kp7HKEzaPJo7LowJXMUKYdf+3XJGu/cw03h/JhIOsLnP+cG5QnTHAuicjA5fMw==" }, "optionator": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", - "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", + "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", "dev": true, "requires": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.6", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "word-wrap": "~1.2.3" + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.3" } }, "ora": { @@ -27751,9 +27819,9 @@ "dev": true }, "path-key": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", - "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", "dev": true }, "path-parse": { @@ -28058,9 +28126,9 @@ } }, "prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true }, "process": { @@ -28089,12 +28157,6 @@ "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-1.0.0.tgz", "integrity": "sha512-du4wfLyj4yCZq1VupnVSZmRsPJsNuxoDQFdCFHLaYiEbFBD7QE0a+I4D7hOxrVnh78QE/YipFAj9lXHiXocV+Q==" }, - "progress": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", - "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", - "dev": true - }, "proxy-addr": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", @@ -28538,12 +28600,6 @@ "functions-have-names": "^1.2.2" } }, - "regexpp": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", - "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", - "dev": true - }, "regexpu-core": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-5.3.2.tgz", @@ -29161,18 +29217,18 @@ "integrity": "sha512-YRNymdiL3KGOoS67d73TEmk4tdPTO9GSMCoiphQsTcC9EtC+AOmMPjkyBkRoCJfW9ASsaZw1craaiw1dPN2D3Q==" }, "shebang-command": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", - "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", "dev": true, "requires": { - "shebang-regex": "^1.0.0" + "shebang-regex": "^3.0.0" } }, "shebang-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true }, "side-channel": { @@ -29220,25 +29276,6 @@ "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", "dev": true }, - "slice-ansi": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", - "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==", - "dev": true, - "requires": { - "ansi-styles": "^3.2.0", - "astral-regex": "^1.0.0", - "is-fullwidth-code-point": "^2.0.0" - }, - "dependencies": { - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - } - } - }, "smart-buffer": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", @@ -29599,76 +29636,6 @@ "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==" }, - "table": { - "version": "5.4.6", - "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz", - "integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==", - "dev": true, - "requires": { - "ajv": "^6.10.2", - "lodash": "^4.17.14", - "slice-ansi": "^2.1.0", - "string-width": "^3.0.0" - }, - "dependencies": { - "ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "dev": true, - "requires": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - } - }, - "ansi-regex": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", - "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", - "dev": true - }, - "emoji-regex": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", - "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - }, - "json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true - }, - "string-width": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", - "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", - "dev": true, - "requires": { - "emoji-regex": "^7.0.1", - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^5.1.0" - } - }, - "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "dev": true, - "requires": { - "ansi-regex": "^4.1.0" - } - } - } - }, "tap-junit": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/tap-junit/-/tap-junit-5.0.2.tgz", @@ -30114,12 +30081,12 @@ "dev": true }, "type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", "dev": true, "requires": { - "prelude-ls": "~1.1.2" + "prelude-ls": "^1.2.1" } }, "type-fest": { @@ -30316,12 +30283,6 @@ "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", "dev": true }, - "v8-compile-cache": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", - "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", - "dev": true - }, "validate-npm-package-license": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", @@ -30598,15 +30559,6 @@ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, - "write": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz", - "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==", - "dev": true, - "requires": { - "mkdirp": "^0.5.1" - } - }, "write-file-atomic": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz", diff --git a/package.json b/package.json index 09039b4400..afbd173714 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,8 @@ "docs:open": "PREVIEW=1 npm run docs:build", "docs:build": "./docs/scripts/build_docs.sh apm-agent-nodejs ./docs ./build", "lint": "npm run lint:eslint && npm run lint:license-files && npm run lint:yaml-files && npm run lint:tav", - "lint:eslint": "eslint . # requires node >=8.10", - "lint:fix": "eslint --fix . # requires node >=8.10", + "lint:eslint": "eslint . # requires node >10", + "lint:fix": "eslint --fix . # requires node >10", "lint:license-files": "./dev-utils/gen-notice.sh --lint . # requires node >=16", "lint:yaml-files": "./dev-utils/lint-yaml-files.sh # requires node >=10", "lint:tav": "./dev-utils/lint-tav-json.js", @@ -150,13 +150,12 @@ "dependency-check": "^4.1.0", "diagnostics_channel": "^1.1.0", "elasticsearch": "^16.7.3", - "eslint": "^6.8.0", - "eslint-config-standard": "^14.1.1", - "eslint-plugin-import": "^2.25.4", + "eslint": "^8.42.0", + "eslint-config-standard": "^16", + "eslint-plugin-import": "^2.27.5", "eslint-plugin-license-header": "^0.6.0", "eslint-plugin-node": "^11.1.0", - "eslint-plugin-promise": "^4.3.1", - "eslint-plugin-standard": "^4.1.0", + "eslint-plugin-promise": "^6.1.1", "express": "^4.17.1", "express-queue": "^0.0.13", "fastify": "^4.16.3", From 34225c72c8f3ea903452a06a0b6e1352d4dce0d4 Mon Sep 17 00:00:00 2001 From: jacques metevier Date: Wed, 7 Jun 2023 16:21:18 -0700 Subject: [PATCH 02/10] chore manual eslint fixes --- dev-utils/bitrot.js | 4 ++-- lib/instrumentation/modules/elasticsearch.js | 3 ++- lib/instrumentation/modules/mysql.js | 2 +- lib/instrumentation/span-compression.js | 3 ++- lib/tracecontext/tracestate.js | 2 +- .../modules/http/aborted-requests-enabled.test.js | 12 ++++++------ test/instrumentation/modules/http2.test.js | 6 +++--- test/metrics/index.test.js | 4 +++- 8 files changed, 20 insertions(+), 16 deletions(-) diff --git a/dev-utils/bitrot.js b/dev-utils/bitrot.js index e0280d6aae..6f0cce2ba2 100755 --- a/dev-utils/bitrot.js +++ b/dev-utils/bitrot.js @@ -136,7 +136,7 @@ function loadSupportedDoc () { var state = null // null | 'thead' | 'tbody' html.split(/\n/g).forEach(function (line) { if (!line.startsWith('|')) { - + // no op } else if (state === null) { if (line.startsWith('|===')) { state = 'thead' @@ -181,7 +181,7 @@ function loadSupportedDoc () { let match rows.forEach(function (row) { if (row[1] === 'N/A') { - + // skip } else if (row[0].includes('<<')) { match = /^\s*<<([\w-]+),(.*?)>>/.exec(row[0]) if (!match) { diff --git a/lib/instrumentation/modules/elasticsearch.js b/lib/instrumentation/modules/elasticsearch.js index d5fae30b58..c2a4da75f6 100644 --- a/lib/instrumentation/modules/elasticsearch.js +++ b/lib/instrumentation/modules/elasticsearch.js @@ -29,7 +29,8 @@ function getTargetUrlFromTransportConfig (config) { } let firstTransportHost = Array.isArray(transportHosts) - ? transportHosts[0] : transportHosts + ? transportHosts[0] + : transportHosts if (!firstTransportHost) { return null } diff --git a/lib/instrumentation/modules/mysql.js b/lib/instrumentation/modules/mysql.js index 750394b1fe..bfad3b991e 100644 --- a/lib/instrumentation/modules/mysql.js +++ b/lib/instrumentation/modules/mysql.js @@ -81,7 +81,7 @@ module.exports = function (mysql, agent, { version, enabled }) { var cb = arguments[0] if (typeof cb === 'function') { - arguments[0] = agent._instrumentation.bindFunction(function wrapedCallback (err, connection) { // eslint-disable-line handle-callback-err + arguments[0] = agent._instrumentation.bindFunction(function wrapedCallback (err, connection) { // eslint-disable-line node/handle-callback-err if (connection) wrapQueryable(connection, 'getConnection() > connection', agent) return cb.apply(this, arguments) }) diff --git a/lib/instrumentation/span-compression.js b/lib/instrumentation/span-compression.js index 80dc24f00a..c8c19d5ec1 100644 --- a/lib/instrumentation/span-compression.js +++ b/lib/instrumentation/span-compression.js @@ -115,7 +115,8 @@ class SpanCompression { const isAlreadyComposite = this.isComposite() const canBeCompressed = isAlreadyComposite - ? this.tryToCompressComposite(compositeSpan, spanToCompress) : this.tryToCompressRegular(compositeSpan, spanToCompress) + ? this.tryToCompressComposite(compositeSpan, spanToCompress) + : this.tryToCompressRegular(compositeSpan, spanToCompress) if (!canBeCompressed) { return false diff --git a/lib/tracecontext/tracestate.js b/lib/tracecontext/tracestate.js index 8f5a16ee49..1b1886808b 100644 --- a/lib/tracecontext/tracestate.js +++ b/lib/tracecontext/tracestate.js @@ -247,7 +247,7 @@ class TraceState { if (key.length > 256 || key.length < 1) { return false } - + // eslint-disable-next-line prefer-regex-literals const re = new RegExp( '^[abcdefghijklmnopqrstuvwxyz0123456789_\\-\\*/]*$' ) diff --git a/test/instrumentation/modules/http/aborted-requests-enabled.test.js b/test/instrumentation/modules/http/aborted-requests-enabled.test.js index 855fcc80c8..f0ca18a553 100644 --- a/test/instrumentation/modules/http/aborted-requests-enabled.test.js +++ b/test/instrumentation/modules/http/aborted-requests-enabled.test.js @@ -42,7 +42,7 @@ test('client-side abort below error threshold - call end', { timeout: 10000 }, f t.strictEqual(agent._apmClient._writes.length, 0, 'should not have any samples to begin with') - agent.captureError = function (err, opts) { // eslint-disable-line handle-callback-err + agent.captureError = function (err, opts) { // eslint-disable-line node/handle-callback-err t.fail('should not register the closed socket as an error') } agent._instrumentation.addEndedTransaction = function () { @@ -144,7 +144,7 @@ test('client-side abort below error threshold - don\'t call end', function (t) { t.strictEqual(agent._apmClient._writes.length, 0, 'should not have any samples to begin with') - agent.captureError = function (err, opts) { // eslint-disable-line handle-callback-err + agent.captureError = function (err, opts) { // eslint-disable-line node/handle-callback-err t.fail('should not register the closed socket as an error') } agent._instrumentation.addEndedTransaction = function () { @@ -222,7 +222,7 @@ test('server-side abort below error threshold and socket closed - call end', fun t.strictEqual(agent._apmClient._writes.length, 0, 'should not have any samples to begin with') - agent.captureError = function (err, opts) { // eslint-disable-line handle-callback-err + agent.captureError = function (err, opts) { // eslint-disable-line node/handle-callback-err t.fail('should not register the closed socket as an error') } agent._instrumentation.addEndedTransaction = function () { @@ -311,7 +311,7 @@ test('server-side abort below error threshold and socket closed - don\'t call en t.strictEqual(agent._apmClient._writes.length, 0, 'should not have any samples to begin with') - agent.captureError = function (err, opts) { // eslint-disable-line handle-callback-err + agent.captureError = function (err, opts) { // eslint-disable-line node/handle-callback-err t.fail('should not register the closed socket as an error') } agent._instrumentation.addEndedTransaction = function () { @@ -391,7 +391,7 @@ test('server-side abort below error threshold but socket not closed - call end', t.strictEqual(agent._apmClient._writes.length, 0, 'should not have any samples to begin with') - agent.captureError = function (err, opts) { // eslint-disable-line handle-callback-err + agent.captureError = function (err, opts) { // eslint-disable-line node/handle-callback-err t.fail('should not register the closed socket as an error') } agent._instrumentation.addEndedTransaction = addEndedTransaction @@ -429,7 +429,7 @@ test('server-side abort above error threshold but socket not closed - call end', t.strictEqual(agent._apmClient._writes.length, 0, 'should not have any samples to begin with') - agent.captureError = function (err, opts) { // eslint-disable-line handle-callback-err + agent.captureError = function (err, opts) { // eslint-disable-line node/handle-callback-err t.fail('should not register the closed socket as an error') } agent._instrumentation.addEndedTransaction = addEndedTransaction diff --git a/test/instrumentation/modules/http2.test.js b/test/instrumentation/modules/http2.test.js index f30bcb2608..e2b549fabb 100644 --- a/test/instrumentation/modules/http2.test.js +++ b/test/instrumentation/modules/http2.test.js @@ -309,9 +309,9 @@ isSecure.forEach(secure => { semver.lt(process.version, '8.11.2-rc') ? onPushStream : (err, pushStream, headers) => { - t.error(err) - onPushStream(pushStream, headers) - } + t.error(err) + onPushStream(pushStream, headers) + } )) stream.respond({ diff --git a/test/metrics/index.test.js b/test/metrics/index.test.js index 6625fef936..535685a553 100644 --- a/test/metrics/index.test.js +++ b/test/metrics/index.test.js @@ -244,5 +244,7 @@ test('Metrics objects do not throw/crash when not started', function (t) { function spinCPUFor (durationMs) { const start = Date.now() - while (Date.now() - start < durationMs) {} + while (Date.now() - start < durationMs) { + // spin + } } From 1727021b659c393982a775deecb3f4d7cb488e8c Mon Sep 17 00:00:00 2001 From: jacques metevier Date: Wed, 7 Jun 2023 16:31:51 -0700 Subject: [PATCH 03/10] chore lint auto fixes --- dev-utils/bitrot.js | 46 +-- examples/trace-graphql.js | 6 +- examples/trace-handlebars.js | 2 +- examples/trace-pg.js | 2 +- examples/trace-pug.js | 2 +- examples/trace-tedious.js | 2 +- examples/trace-ws.js | 4 +- index.js | 2 +- lib/activation-method.js | 2 +- lib/agent.js | 16 +- lib/config/config.js | 2 +- lib/errors.js | 16 +- lib/http-request.js | 4 +- lib/instrumentation/context.js | 2 +- lib/instrumentation/elasticsearch-shared.js | 2 +- lib/instrumentation/express-utils.js | 8 +- lib/instrumentation/generic-span.js | 4 +- lib/instrumentation/http-shared.js | 24 +- lib/instrumentation/index.js | 22 +- lib/instrumentation/modules/@apollo/server.js | 2 +- .../modules/apollo-server-core.js | 2 +- lib/instrumentation/modules/bluebird.js | 16 +- lib/instrumentation/modules/elasticsearch.js | 12 +- .../modules/express-graphql.js | 6 +- lib/instrumentation/modules/express-queue.js | 6 +- lib/instrumentation/modules/express.js | 22 +- lib/instrumentation/modules/finalhandler.js | 6 +- lib/instrumentation/modules/generic-pool.js | 24 +- lib/instrumentation/modules/graphql.js | 26 +- lib/instrumentation/modules/handlebars.js | 4 +- lib/instrumentation/modules/hapi.js | 18 +- lib/instrumentation/modules/http.js | 10 +- lib/instrumentation/modules/http2.js | 52 +-- lib/instrumentation/modules/https.js | 6 +- lib/instrumentation/modules/jade.js | 4 +- lib/instrumentation/modules/knex.js | 12 +- lib/instrumentation/modules/koa-router.js | 10 +- lib/instrumentation/modules/memcached.js | 8 +- lib/instrumentation/modules/mimic-response.js | 4 +- lib/instrumentation/modules/mongodb-core.js | 34 +- lib/instrumentation/modules/mysql.js | 26 +- lib/instrumentation/modules/mysql2.js | 14 +- lib/instrumentation/modules/pg.js | 16 +- lib/instrumentation/modules/pug.js | 4 +- lib/instrumentation/modules/redis.js | 10 +- lib/instrumentation/modules/tedious.js | 8 +- lib/instrumentation/modules/ws.js | 4 +- lib/instrumentation/patch-async.js | 92 ++--- lib/instrumentation/shimmer.js | 12 +- lib/instrumentation/span.js | 14 +- lib/instrumentation/template-shared.js | 12 +- lib/instrumentation/timer.js | 2 +- lib/instrumentation/transaction.js | 24 +- lib/lambda.js | 2 +- lib/load-source-map.js | 22 +- lib/logging.js | 6 +- lib/middleware/connect.js | 2 +- lib/opentelemetry-bridge/OTelSpan.js | 2 +- .../ElasticApmMetricExporter.js | 2 +- lib/parsers.js | 20 +- lib/propwrap.js | 10 +- lib/redact-secrets/index.js | 4 +- lib/redact-secrets/is-secret.js | 4 +- lib/stacktraces.js | 22 +- test/InflightEventSet.test.js | 2 +- test/_agent.js | 10 +- test/_assert.js | 16 +- test/_is_fastify_incompat.js | 2 +- test/_is_hapi_incompat.js | 6 +- test/_is_mongodb_incompat.js | 2 +- test/_is_restify_incompat.js | 2 +- test/_is_undici_incompat.js | 2 +- test/_mock_apm_server.js | 4 +- test/_utils.js | 8 +- .../activation-method.test.js | 2 +- test/agent.test.js | 88 ++--- test/apm-client/http-apm-client.test.js | 2 +- ...001-transaction-and-span-no-stack-trace.js | 2 +- ...action-and-span-overhead-realistic-size.js | 10 +- ...3-transaction-and-span-with-stack-trace.js | 2 +- test/benchmarks/004-transaction.js | 2 +- .../005-transaction-reading-file.js | 6 +- ...verhead-realistic-size-with-stack-trace.js | 10 +- test/config.test.js | 200 +++++------ test/connect.test.js | 4 +- test/errors.test.js | 4 +- test/fixtures/do-not-trace-self.js | 2 +- test/http-request.test.js | 2 +- test/instrumentation/_async-await.js | 4 +- test/instrumentation/_shared-promise-tests.js | 42 +-- test/instrumentation/async-await.test.js | 18 +- test/instrumentation/context.test.js | 4 +- test/instrumentation/core-async-apis.test.js | 30 +- test/instrumentation/fs.test.js | 4 +- test/instrumentation/index.test.js | 124 +++---- .../modules/@apollo/server.test.js | 6 +- .../modules/apollo-server-express.test.js | 124 +++---- .../modules/aws-sdk/dynamodb.test.js | 12 +- .../modules/aws-sdk/fixtures/use-s3.js | 2 +- .../modules/bluebird/_coroutine.js | 18 +- .../modules/bluebird/bluebird.test.js | 320 +++++++++--------- .../modules/bluebird/cancel.test.js | 26 +- .../modules/elasticsearch.test.js | 58 ++-- .../modules/express-queue.test.js | 32 +- .../modules/express/basic.test.js | 88 ++--- .../modules/fastify/fastify.test.js | 2 +- .../modules/finalhandler.test.js | 32 +- .../modules/generic-pool.test.js | 26 +- test/instrumentation/modules/graphql.test.js | 86 ++--- .../modules/handlebars.test.js | 14 +- .../hapi/set-framework-hapihapi.test.js | 2 +- test/instrumentation/modules/hapi/shared.js | 60 ++-- test/instrumentation/modules/http/_assert.js | 2 +- .../modules/http/_echo_server.js | 12 +- .../modules/http/_echo_server_util.js | 10 +- .../http/aborted-requests-disabled.test.js | 30 +- .../http/aborted-requests-enabled.test.js | 62 ++-- .../modules/http/basic.test.js | 22 +- .../bind-write-head-to-transaction.test.js | 12 +- .../modules/http/github-179.test.js | 22 +- .../modules/http/github-423.test.js | 28 +- .../ignore-url-does-not-leak-trans.test.js | 10 +- .../modules/http/ignoring.test.js | 10 +- .../http/node-prefixed-http-require.test.js | 2 +- .../modules/http/outgoing.test.js | 84 ++--- .../modules/http/request.test.js | 26 +- test/instrumentation/modules/http/sse.test.js | 26 +- test/instrumentation/modules/http2.test.js | 134 ++++---- test/instrumentation/modules/ioredis.test.js | 28 +- .../modules/koa-router/shared.js | 24 +- .../instrumentation/modules/memcached.test.js | 12 +- .../modules/mimic-response.test.js | 10 +- .../modules/mongodb-core.test.js | 24 +- test/instrumentation/modules/mysql/_utils.js | 6 +- .../modules/mysql/mysql.test.js | 78 ++--- .../modules/mysql/pool-release-1.test.js | 8 +- test/instrumentation/modules/mysql2/_utils.js | 6 +- .../modules/mysql2/mysql.test.js | 100 +++--- .../modules/mysql2/pool-release-1.test.js | 8 +- .../instrumentation/modules/next/next.test.js | 2 +- test/instrumentation/modules/pg/_utils.js | 8 +- .../pg/knex-no-span-stack-traces.test.js | 10 +- test/instrumentation/modules/pg/knex.test.js | 32 +- test/instrumentation/modules/pg/pg.test.js | 82 ++--- test/instrumentation/modules/pug.test.js | 16 +- .../instrumentation/modules/redis-2-3.test.js | 44 +-- test/instrumentation/modules/tedious.test.js | 4 +- test/instrumentation/modules/ws.test.js | 20 +- test/instrumentation/native-promises.test.js | 6 +- .../fixtures/custom-instrumentation-sync.js | 10 +- .../run-context/fixtures/ls-await.js | 6 +- .../run-context/fixtures/ls-promises.js | 6 +- test/instrumentation/span-compression.test.js | 6 +- test/instrumentation/span.test.js | 100 +++--- test/instrumentation/timer.test.js | 28 +- test/instrumentation/transaction.test.js | 110 +++--- test/integration/503.test.js | 10 +- .../integration/abort-on-invalid-cert.test.js | 12 +- test/integration/allow-invalid-cert.test.js | 12 +- test/integration/no-sampling.test.js | 14 +- test/integration/server-url-path.test.js | 8 +- test/integration/socket-close.test.js | 10 +- .../integration/verify-server-ca-cert.test.js | 18 +- test/lambda/lambda.test.js | 2 +- test/lambda/metadata.test.js | 2 +- test/lambda/metadata2.test.js | 2 +- test/logging-preamble.test.js | 10 +- test/metrics/breakdown.test.js | 58 ++-- test/outcome.test.js | 2 +- test/parsers.test.js | 60 ++-- test/redact-secrets/is-secret.test.js | 4 +- test/redact-secrets/redact-secrets.test.js | 20 +- test/sanitize-field-names/hapi.test.js | 2 +- test/service-resource-inference.test.js | 2 +- test/sourcemaps/index.test.js | 16 +- test/stacktraces/stacktraces.test.js | 2 +- test/start/env/test.test.js | 2 +- test/start/file/test.test.js | 2 +- test/test.js | 30 +- test/tracecontext/tracestate.test.js | 2 +- test/transaction-sampling.test.js | 20 +- test/wildcard-matcher.test.js | 2 +- 182 files changed, 1960 insertions(+), 1960 deletions(-) diff --git a/dev-utils/bitrot.js b/dev-utils/bitrot.js index 6f0cce2ba2..33c5949866 100755 --- a/dev-utils/bitrot.js +++ b/dev-utils/bitrot.js @@ -82,7 +82,7 @@ function saveCache () { // - Bad: blue (not visible on cmd.exe), grey (same color as background on // Solarized Dark theme from , see // issue #160) -var colors = { +const colors = { bold: [1, 22], italic: [3, 23], underline: [4, 24], @@ -100,7 +100,7 @@ var colors = { function stylizeWithColor (str, color) { if (!str) { return '' } - var codes = colors[color] + const codes = colors[color] if (codes) { return '\x1B[' + codes[0] + 'm' + str + '\x1B[' + codes[1] + 'm' } else { @@ -131,9 +131,9 @@ function rot (moduleName, s) { // I see in supported-technologies.asciidoc. function loadSupportedDoc () { const docPath = 'docs/supported-technologies.asciidoc' - var html = fs.readFileSync(docPath, 'utf8') - var rows = [] - var state = null // null | 'thead' | 'tbody' + const html = fs.readFileSync(docPath, 'utf8') + const rows = [] + let state = null // null | 'thead' | 'tbody' html.split(/\n/g).forEach(function (line) { if (!line.startsWith('|')) { // no op @@ -150,8 +150,8 @@ function loadSupportedDoc () { // Examples: // |https://www.npmjs.com/package/generic-pool[generic-pool] | ^2.0.0 \|\| ^3.1.0 |Used by a lot of ... // |https://www.npmjs.com/package/bluebird[bluebird] |>=2.0.0 <4.0.0 | - var escapePlaceholder = '6B1EC7E1-B273-40E9-94C4-197A59B55E24' - var cells = line + const escapePlaceholder = '6B1EC7E1-B273-40E9-94C4-197A59B55E24' + const cells = line .trim() .slice(1) // remove leading '|' .replace(/\\\|/g, escapePlaceholder) @@ -177,7 +177,7 @@ function loadSupportedDoc () { // The entries in the "Frameworks" table use the names of internal links in // these docs. The anchor name is *sometimes* the same name as the npm // module, but sometimes not. - var results = [] + const results = [] let match rows.forEach(function (row) { if (row[1] === 'N/A') { @@ -187,7 +187,7 @@ function loadSupportedDoc () { if (!match) { throw new Error(`could not parse this table cell text from docs/supported-technologies.asciidoc: ${JSON.stringify(row[0])}`) } - var moduleNames + let moduleNames if (match[1] === 'nextjs') { moduleNames = ['next'] } else if (match[2] === '@hapi/hapi') { @@ -246,24 +246,24 @@ function getNpmInfo (name) { function bitrot (moduleNames) { log.debug({ moduleNames }, 'bitrot') - var tavYmls = [ + const tavYmls = [ yaml.load(fs.readFileSync('.tav.yml', 'utf8')), yaml.load(fs.readFileSync('./test/opentelemetry-bridge/.tav.yml', 'utf8')), yaml.load(fs.readFileSync('./test/opentelemetry-metrics/fixtures/.tav.yml', 'utf8')), yaml.load(fs.readFileSync('test/instrumentation/modules/next/a-nextjs-app/.tav.yml', 'utf8')) ] - var supported = loadSupportedDoc() + const supported = loadSupportedDoc() // Merge into one data structure we can iterate through. - var rangesFromName = {} - var ensureKey = (name) => { + const rangesFromName = {} + const ensureKey = (name) => { if (!(name in rangesFromName)) { rangesFromName[name] = { tavRanges: [], supRanges: [] } } } tavYmls.forEach(tavYml => { for (const [label, tavInfo] of Object.entries(tavYml)) { - var name = tavInfo.name || label + const name = tavInfo.name || label ensureKey(name) rangesFromName[name].tavRanges.push(tavInfo.versions) } @@ -275,7 +275,7 @@ function bitrot (moduleNames) { // Reduce to `moduleNames` if given. if (moduleNames && moduleNames.length > 0) { - var allNames = Object.keys(rangesFromName) + const allNames = Object.keys(rangesFromName) moduleNames.forEach(name => { if (!(name in rangesFromName)) { throw new Error(`unknown module name: ${name} (known module names: ${allNames.join(', ')})`) @@ -290,15 +290,15 @@ function bitrot (moduleNames) { log.debug({ rangesFromName }, 'rangesFromName') // Check each module name. - var namesToCheck = Object.keys(rangesFromName).sort() + const namesToCheck = Object.keys(rangesFromName).sort() namesToCheck.forEach(name => { - var npmInfo = getNpmInfo(name) + const npmInfo = getNpmInfo(name) log.trace({ name, 'dist-tags': npmInfo['dist-tags'], time: npmInfo.time }, 'npmInfo') // If the current latest version is in the supported and // tav ranges, then all is good. - var latest = npmInfo['dist-tags'].latest - var tavGood = false + const latest = npmInfo['dist-tags'].latest + let tavGood = false if (EXCUSE_FROM_TAV[name]) { tavGood = true } else { @@ -309,7 +309,7 @@ function bitrot (moduleNames) { } } } - var supGood = false + let supGood = false if (EXCUSE_FROM_SUPPORTED_TECHNOLOGIES_DOC[name]) { supGood = true } else { @@ -324,7 +324,7 @@ function bitrot (moduleNames) { log.debug(`latest ${name}@${latest} is in tav and supported ranges (a good thing)`) return } - var issues = [] + const issues = [] if (!tavGood) { issues.push(`is not in .tav.yml ranges (${rangesFromName[name].tavRanges.join(', ')})`) } @@ -351,7 +351,7 @@ const options = [ ] function main (argv) { - var parser = dashdash.createParser({ options: options }) + const parser = dashdash.createParser({ options: options }) try { var opts = parser.parse(argv) } catch (e) { @@ -359,7 +359,7 @@ function main (argv) { process.exit(1) } if (opts.help) { - var help = parser.help().trimRight() + const help = parser.help().trimRight() process.stdout.write(`Synopsis: dev-utils/bitrot.js [OPTIONS] diff --git a/examples/trace-graphql.js b/examples/trace-graphql.js index 2dfa074455..f1dc2023a6 100644 --- a/examples/trace-graphql.js +++ b/examples/trace-graphql.js @@ -10,10 +10,10 @@ const apm = require('../').start({ // elastic-apm-node serviceName: 'example-trace-graphql' }) -var { graphql, buildSchema } = require('graphql') +const { graphql, buildSchema } = require('graphql') // Construct a schema, using GraphQL schema language -var schema = buildSchema(` +const schema = buildSchema(` type Query { hello: String bye: String @@ -21,7 +21,7 @@ var schema = buildSchema(` `) // The root provides a resolver function for each API endpoint -var root = { +const root = { hello: () => { return 'Hello world!' }, diff --git a/examples/trace-handlebars.js b/examples/trace-handlebars.js index fdd457fb14..c1e1543b5b 100755 --- a/examples/trace-handlebars.js +++ b/examples/trace-handlebars.js @@ -21,7 +21,7 @@ const handlebars = require('handlebars') // https://www.elastic.co/guide/en/apm/agent/nodejs/current/custom-transactions.html const t1 = apm.startTransaction('t1') -var template = handlebars.compile('Hello, {{name}}!') +const template = handlebars.compile('Hello, {{name}}!') console.log(template({ name: 'world' })) console.log(template({ name: 'Bob' })) diff --git a/examples/trace-pg.js b/examples/trace-pg.js index 269c57801b..af5ada1285 100755 --- a/examples/trace-pg.js +++ b/examples/trace-pg.js @@ -43,7 +43,7 @@ client.query('SELECT $1::text as message', ['bye'], (err, res) => { // 2. Using streaming style, i.e. using a `Submittable` as node-postgres calls it. const t2 = apm.startTransaction('t2') -var q = client.query(new Query('select 1 + 1 as solution')) +const q = client.query(new Query('select 1 + 1 as solution')) q.on('error', (err) => { console.log('[t2] Failure: err is', err) t2.end() diff --git a/examples/trace-pug.js b/examples/trace-pug.js index 34b7deb8d8..cd43e1d1c9 100755 --- a/examples/trace-pug.js +++ b/examples/trace-pug.js @@ -21,7 +21,7 @@ const pug = require('pug') // https://www.elastic.co/guide/en/apm/agent/nodejs/current/custom-transactions.html const t1 = apm.startTransaction('t1') -var template = pug.compile('p Hello, #{name}!') +const template = pug.compile('p Hello, #{name}!') console.log(template({ name: 'world' })) console.log(template({ name: 'Bob' })) diff --git a/examples/trace-tedious.js b/examples/trace-tedious.js index 5d31eb3344..afac19bc1f 100755 --- a/examples/trace-tedious.js +++ b/examples/trace-tedious.js @@ -65,7 +65,7 @@ const conn2 = new tedious.Connection(connOpts) conn2.on('connect', onConnect2) conn2.connect() function onConnect2 () { - var req = new tedious.Request("select @mynum=42, @mystr='qaz'", function (err, rowCount) { + const req = new tedious.Request("select @mynum=42, @mystr='qaz'", function (err, rowCount) { console.log('select @mynum ...: err=%s rowCount=%s', err && err.message, rowCount) conn2.close() }) diff --git a/examples/trace-ws.js b/examples/trace-ws.js index 440b83fd9f..027acb0109 100755 --- a/examples/trace-ws.js +++ b/examples/trace-ws.js @@ -20,8 +20,8 @@ const apm = require('../').start({ // elastic-apm-node serviceName: 'example-trace-ws' }) -var WebSocket = require('ws') -var PORT = 4567 +const WebSocket = require('ws') +const PORT = 4567 // Server const wss = new WebSocket.Server({ port: PORT }) diff --git a/index.js b/index.js index 04711888d1..5d7fcc8f22 100644 --- a/index.js +++ b/index.js @@ -6,6 +6,6 @@ 'use strict' -var Agent = require('./lib/agent') +const Agent = require('./lib/agent') module.exports = new Agent() diff --git a/lib/activation-method.js b/lib/activation-method.js index f9b1938b3c..3590dc8020 100644 --- a/lib/activation-method.js +++ b/lib/activation-method.js @@ -11,7 +11,7 @@ const path = require('path') const errorStackParser = require('error-stack-parser') const semver = require('semver') -var { isLambdaExecutionEnvironment } = require('./lambda') +const { isLambdaExecutionEnvironment } = require('./lambda') const CONTAINS_R_ELASTIC_APM_NODE_START = /(-r\s+|--require\s*=?\s*).*elastic-apm-node\/start/ diff --git a/lib/agent.js b/lib/agent.js index 1042d63467..0511a0d5c5 100644 --- a/lib/agent.js +++ b/lib/agent.js @@ -251,7 +251,7 @@ Agent.prototype.start = function (opts) { // Attempt to load package.json from process.argv. let pkg = null try { - var basedir = path.dirname(process.argv[1] || '.') + const basedir = path.dirname(process.argv[1] || '.') pkg = require(path.join(basedir, 'package.json')) } catch (e) {} @@ -343,14 +343,14 @@ Agent.prototype.setFramework = function ({ name, version, overwrite = true }) { } Agent.prototype.setUserContext = function (context) { - var trans = this._instrumentation.currTransaction() + const trans = this._instrumentation.currTransaction() if (!trans) return false trans.setUserContext(context) return true } Agent.prototype.setCustomContext = function (context) { - var trans = this._instrumentation.currTransaction() + const trans = this._instrumentation.currTransaction() if (!trans) return false trans.setCustomContext(context) return true @@ -373,13 +373,13 @@ Agent.prototype.setGlobalLabel = function (key, value) { } Agent.prototype.setLabel = function (key, value, stringify) { - var trans = this._instrumentation.currTransaction() + const trans = this._instrumentation.currTransaction() if (!trans) return false return trans.setLabel(key, value, stringify) } Agent.prototype.addLabels = function (labels, stringify) { - var trans = this._instrumentation.currTransaction() + const trans = this._instrumentation.currTransaction() if (!trans) return false return trans.addLabels(labels, stringify) } @@ -661,7 +661,7 @@ Agent.prototype.captureError = function (err, opts, cb) { // automatically terminate the process, so if you provide a callback you must // remember to terminate the process manually. Agent.prototype.handleUncaughtExceptions = function (cb) { - var agent = this + const agent = this if (this._uncaughtExceptionListener) { process.removeListener('uncaughtException', this._uncaughtExceptionListener) @@ -793,7 +793,7 @@ Agent.prototype._flush = function (opts, cb) { } Agent.prototype.registerMetric = function (name, labelsOrCallback, callback) { - var labels + let labels if (typeof labelsOrCallback === 'function') { callback = labelsOrCallback } else { @@ -816,7 +816,7 @@ Agent.prototype.registerMetric = function (name, labelsOrCallback, callback) { */ Agent.prototype._isMetricNameDisabled = function (name) { const regexps = this._conf.disableMetricsRegExp - for (var i = 0; i < regexps.length; i++) { + for (let i = 0; i < regexps.length; i++) { if (regexps[i].test(name)) { return true } diff --git a/lib/config/config.js b/lib/config/config.js index d8ff391f4a..42b81f35e5 100644 --- a/lib/config/config.js +++ b/lib/config/config.js @@ -277,7 +277,7 @@ class Config { } function readEnv () { - var opts = {} + const opts = {} for (const key of Object.keys(ENV_TABLE)) { let env = ENV_TABLE[key] if (!Array.isArray(env)) env = [env] diff --git a/lib/errors.js b/lib/errors.js index bdd087ef83..97a1aab8c0 100644 --- a/lib/errors.js +++ b/lib/errors.js @@ -10,7 +10,7 @@ // https://github.com/elastic/apm-server/blob/master/docs/spec/v2/error.json const crypto = require('crypto') -var path = require('path') +const path = require('path') const util = require('util') const { gatherStackTrace } = require('./stacktraces') @@ -24,9 +24,9 @@ const MYSQL_ERROR_MSG_RE = /(ER_[A-Z_]+): / function culpritFromStacktrace (frames) { if (frames.length === 0) return - var filename = frames[0].filename - var fnName = frames[0].function - for (var n = 0; n < frames.length; n++) { + let filename = frames[0].filename + let fnName = frames[0].function + for (let n = 0; n < frames.length; n++) { if (!frames[n].library_frame) { filename = frames[n].filename fnName = frames[n].function @@ -52,15 +52,15 @@ function _moduleNameFromFrames (frames) { if (frames.length === 0) { return null } - var frame = frames[0] + const frame = frames[0] if (!frame.library_frame) { return null } - var idx = frame.filename.lastIndexOf('node_modules' + path.sep) + const idx = frame.filename.lastIndexOf('node_modules' + path.sep) if (idx === -1) { return null } - var parts = frame.filename.slice(idx).split(path.sep) + const parts = frame.filename.slice(idx).split(path.sep) if (!parts[1]) { return null } else if (parts[1].startsWith('@')) { @@ -191,7 +191,7 @@ function createAPMError (args, cb) { // To provide better grouping of mysql errors that happens after the async // boundery, we modify to exception type to include the custom mysql error // type (e.g. ER_PARSE_ERROR) - var match = errMsg.match(MYSQL_ERROR_MSG_RE) + const match = errMsg.match(MYSQL_ERROR_MSG_RE) if (match) { error.exception.code = match[1] } diff --git a/lib/http-request.js b/lib/http-request.js index 56bf298691..b7580819ee 100644 --- a/lib/http-request.js +++ b/lib/http-request.js @@ -132,7 +132,7 @@ function httpRequest (url, opts, cb) { // is connected. req.on('socket', function (socket) { // log.trace({url: url}, 'start connectTimeout') - var connectTimer = setTimeout(function onConnectTimeout () { + let connectTimer = setTimeout(function onConnectTimeout () { // log.trace({url: url}, 'connectTimeout') req.emit('connectTimeout') }, connectTimeout) @@ -206,7 +206,7 @@ function main (argv) { const connectTimeout = Number(argv[3]) const timeout = Number(argv[4]) - var req = httpRequest(url, { + const req = httpRequest(url, { timeout: timeout, connectTimeout: connectTimeout // TODO: log support diff --git a/lib/instrumentation/context.js b/lib/instrumentation/context.js index 147adad65f..37d0a8eb81 100644 --- a/lib/instrumentation/context.js +++ b/lib/instrumentation/context.js @@ -6,7 +6,7 @@ 'use strict' -var { parseUrl } = require('../parsers') +const { parseUrl } = require('../parsers') // Get the port number including the default port for a protocols function getPortNumber (port, protocol) { diff --git a/lib/instrumentation/elasticsearch-shared.js b/lib/instrumentation/elasticsearch-shared.js index 75734b001f..7df91ff512 100644 --- a/lib/instrumentation/elasticsearch-shared.js +++ b/lib/instrumentation/elasticsearch-shared.js @@ -16,7 +16,7 @@ function shouldCaptureBody (path, elasticsearchCaptureBodyUrlsRegExp) { if (!path) { return false } - for (var i = 0; i < elasticsearchCaptureBodyUrlsRegExp.length; i++) { + for (let i = 0; i < elasticsearchCaptureBodyUrlsRegExp.length; i++) { const re = elasticsearchCaptureBodyUrlsRegExp[i] if (re.test(path)) { return true diff --git a/lib/instrumentation/express-utils.js b/lib/instrumentation/express-utils.js index 590040647e..02717c3dab 100644 --- a/lib/instrumentation/express-utils.js +++ b/lib/instrumentation/express-utils.js @@ -8,7 +8,7 @@ const url = require('url') -var symbols = require('../symbols') +const symbols = require('../symbols') function normalizeSlash (value) { return value[0] === '/' ? value : '/' + value @@ -30,7 +30,7 @@ function routePath (route) { } function getStackPath (req) { - var stack = req[symbols.expressMountStack] + const stack = req[symbols.expressMountStack] return join(stack) } @@ -41,8 +41,8 @@ function getPathFromRequest (req, useBase, usePathAsTransactionName) { return 'static file' } - var path = getStackPath(req) - var route = routePath(req.route) + const path = getStackPath(req) + const route = routePath(req.route) if (route) { return path ? join([path, route]) : route diff --git a/lib/instrumentation/generic-span.js b/lib/instrumentation/generic-span.js index 501e48997a..224578d3d2 100644 --- a/lib/instrumentation/generic-span.js +++ b/lib/instrumentation/generic-span.js @@ -137,7 +137,7 @@ GenericSpan.prototype.setLabel = function (key, value, stringify = true) { if (!key) return false if (!this._labels) this._labels = {} - var skey = key.replace(/[.*"]/g, '_') + const skey = key.replace(/[.*"]/g, '_') if (key !== skey) { this._agent.logger.warn('Illegal characters used in tag key: %s', key) } @@ -147,7 +147,7 @@ GenericSpan.prototype.setLabel = function (key, value, stringify = true) { GenericSpan.prototype.addLabels = function (labels, stringify) { if (!labels) return false - var keys = Object.keys(labels) + const keys = Object.keys(labels) for (const key of keys) { if (!this.setLabel(key, labels[key], stringify)) { return false diff --git a/lib/instrumentation/http-shared.js b/lib/instrumentation/http-shared.js index c7636d0852..1a8de541a1 100644 --- a/lib/instrumentation/http-shared.js +++ b/lib/instrumentation/http-shared.js @@ -6,12 +6,12 @@ 'use strict' -var { URL, urlToHttpOptions } = require('url') +const { URL, urlToHttpOptions } = require('url') -var endOfStream = require('end-of-stream') +const endOfStream = require('end-of-stream') const semver = require('semver') -var { getHTTPDestination } = require('./context') +const { getHTTPDestination } = require('./context') const transactionForResponse = new WeakMap() exports.transactionForResponse = transactionForResponse @@ -82,7 +82,7 @@ if (!urlToHttpOptions) { } exports.instrumentRequest = function (agent, moduleName) { - var ins = agent._instrumentation + const ins = agent._instrumentation return function (orig) { return function (event, req, res) { if (event === 'request') { @@ -115,7 +115,7 @@ exports.instrumentRequest = function (agent, moduleName) { if (!err) return trans.end() if (agent._conf.errorOnAbortedRequests) { - var duration = trans._timer.elapsed() + const duration = trans._timer.elapsed() if (duration > (agent._conf.abortedErrorThreshold * 1000)) { agent.captureError('Socket closed with active HTTP request (>' + agent._conf.abortedErrorThreshold + ' sec)', { request: req, @@ -142,7 +142,7 @@ exports.instrumentRequest = function (agent, moduleName) { } function shouldIgnoreRequest (agent, req) { - var i + let i for (i = 0; i < agent._conf.ignoreUrlStr.length; i++) { if (agent._conf.ignoreUrlStr[i] === req.url) return true @@ -154,7 +154,7 @@ function shouldIgnoreRequest (agent, req) { if (agent._conf.transactionIgnoreUrlRegExp[i].test(req.url)) return true } - var ua = req.headers['user-agent'] + const ua = req.headers['user-agent'] if (!ua) return false for (i = 0; i < agent._conf.ignoreUserAgentStr.length; i++) { @@ -179,13 +179,13 @@ function getSafeHost (req) { } exports.traceOutgoingRequest = function (agent, moduleName, method) { - var ins = agent._instrumentation + const ins = agent._instrumentation return function (orig) { return function (input, options, cb) { const parentRunContext = ins.currRunContext() - var span = ins.createSpan(null, 'external', 'http', { exitSpan: true }) - var id = span && span.transaction.id + const span = ins.createSpan(null, 'external', 'http', { exitSpan: true }) + const id = span && span.transaction.id agent.logger.debug('intercepted call to %s.%s %o', moduleName, method, { id: id }) // Reproduce the argument handling from node/lib/_http_client.js#ClientRequest(). @@ -258,9 +258,9 @@ exports.traceOutgoingRequest = function (agent, moduleName, method) { } const spanRunContext = parentRunContext.enterSpan(span) - var req = ins.withRunContext(spanRunContext, orig, this, ...newArgs) + const req = ins.withRunContext(spanRunContext, orig, this, ...newArgs) - var protocol = req.agent && req.agent.protocol + const protocol = req.agent && req.agent.protocol agent.logger.debug('request details: %o', { protocol: protocol, host: getSafeHost(req), id: id }) ins.bindEmitter(req) diff --git a/lib/instrumentation/index.js b/lib/instrumentation/index.js index b721b064cd..bffd273ad8 100644 --- a/lib/instrumentation/index.js +++ b/lib/instrumentation/index.js @@ -6,8 +6,8 @@ 'use strict' -var fs = require('fs') -var path = require('path') +const fs = require('fs') +const path = require('path') const Hook = require('require-in-the-middle') const semver = require('semver') @@ -17,9 +17,9 @@ const { CONTEXT_MANAGER_ASYNCHOOKS, CONTEXT_MANAGER_ASYNCLOCALSTORAGE } = require('../config/schema') -var { Ids } = require('./ids') -var NamedArray = require('./named-array') -var Transaction = require('./transaction') +const { Ids } = require('./ids') +const NamedArray = require('./named-array') +const Transaction = require('./transaction') const { BasicRunContextManager, AsyncHooksRunContextManager, @@ -34,7 +34,7 @@ const nodeSupportsAsyncLocalStorage = semver.satisfies(process.versions.node, '> // v18.0.0) based on undici@5.0.0. We can instrument undici >=v4.7.1. const nodeHasInstrumentableFetch = typeof (global.fetch) === 'function' -var MODULES = [ +const MODULES = [ '@apollo/server', '@aws-sdk/smithy-client', // Instrument the base client which all AWS-SDK v3 clients extends ['@elastic/elasticsearch', '@elastic/elasticsearch-canary'], @@ -295,13 +295,13 @@ Instrumentation.prototype._startHook = function () { this._hook.unhook() } - var self = this + const self = this this._agent.logger.debug('adding hook to Node.js module loader') this._hook = new Hook(this._patches.keys, function (exports, name, basedir) { const enabled = self._isModuleEnabled(name) - var pkg, version + let pkg, version const isHandlingLambda = self._lambdaHandlerInfo && self._lambdaHandlerInfo.module === name @@ -353,7 +353,7 @@ Instrumentation.prototype._patchModule = function (exports, name, version, enabl } Instrumentation.prototype.addEndedTransaction = function (transaction) { - var agent = this._agent + const agent = this._agent if (!this._started) { agent.logger.debug('ignoring transaction %o', { trans: transaction.id, trace: transaction.traceId }) @@ -387,7 +387,7 @@ Instrumentation.prototype.addEndedTransaction = function (transaction) { this._encodeAndSendSpan(transaction.getBufferedSpan()) } - var payload = agent._transactionFilters.process(transaction._encode()) + const payload = agent._transactionFilters.process(transaction._encode()) if (!payload) { agent.logger.debug('transaction ignored by filter %o', { trans: transaction.id, trace: transaction.traceId }) return @@ -398,7 +398,7 @@ Instrumentation.prototype.addEndedTransaction = function (transaction) { } Instrumentation.prototype.addEndedSpan = function (span) { - var agent = this._agent + const agent = this._agent if (!this._started) { agent.logger.debug('ignoring span %o', { span: span.id, parent: span.parentId, trace: span.traceId, name: span.name, type: span.type }) diff --git a/lib/instrumentation/modules/@apollo/server.js b/lib/instrumentation/modules/@apollo/server.js index 2fb428208c..02a465bd0b 100644 --- a/lib/instrumentation/modules/@apollo/server.js +++ b/lib/instrumentation/modules/@apollo/server.js @@ -15,7 +15,7 @@ module.exports = function (apolloServer, agent, { enabled }) { function wrapExecuteHTTPGraphQLRequest (orig) { return function wrappedExecuteHTTPGraphQLRequest () { - var trans = agent._instrumentation.currTransaction() + const trans = agent._instrumentation.currTransaction() if (trans) trans._graphqlRoute = true return orig.apply(this, arguments) } diff --git a/lib/instrumentation/modules/apollo-server-core.js b/lib/instrumentation/modules/apollo-server-core.js index 523febac18..b667b02402 100644 --- a/lib/instrumentation/modules/apollo-server-core.js +++ b/lib/instrumentation/modules/apollo-server-core.js @@ -20,7 +20,7 @@ module.exports = function (apolloServerCore, agent, { version, enabled }) { function wrapRunHttpQuery (orig) { return function wrappedRunHttpQuery () { - var trans = agent._instrumentation.currTransaction() + const trans = agent._instrumentation.currTransaction() if (trans) trans._graphqlRoute = true return orig.apply(this, arguments) } diff --git a/lib/instrumentation/modules/bluebird.js b/lib/instrumentation/modules/bluebird.js index 722de79341..401bde3c55 100644 --- a/lib/instrumentation/modules/bluebird.js +++ b/lib/instrumentation/modules/bluebird.js @@ -6,17 +6,17 @@ 'use strict' -var semver = require('semver') +const semver = require('semver') -var shimmer = require('../shimmer') +const shimmer = require('../shimmer') -var massWrap = shimmer.massWrap -var wrap = shimmer.wrap +const massWrap = shimmer.massWrap +const wrap = shimmer.wrap -var BLUEBIRD_FNS = ['_then', '_addCallbacks'] +const BLUEBIRD_FNS = ['_then', '_addCallbacks'] module.exports = function (bluebird, agent, { version }) { - var ins = agent._instrumentation + const ins = agent._instrumentation if (!semver.satisfies(version, '>=2 <4')) { agent.logger.debug('bluebird version %s not supported - aborting...', version) @@ -32,7 +32,7 @@ module.exports = function (bluebird, agent, { version }) { agent.logger.debug('shimming bluebird.config') wrap(bluebird, 'config', function wrapConfig (original) { return function wrappedConfig () { - var result = original.apply(this, arguments) + const result = original.apply(this, arguments) agent.logger.debug('shimming bluebird.prototype._attachCancellationCallback') wrap(bluebird.prototype, '_attachCancellationCallback', function wrapAttachCancellationCallback (original) { @@ -75,7 +75,7 @@ module.exports = function (bluebird, agent, { version }) { function wrapThen (original) { return function wrappedThen () { - var args = Array.prototype.slice.call(arguments) + const args = Array.prototype.slice.call(arguments) if (typeof args[0] === 'function') args[0] = ins.bindFunction(args[0]) if (typeof args[1] === 'function') args[1] = ins.bindFunction(args[1]) return original.apply(this, args) diff --git a/lib/instrumentation/modules/elasticsearch.js b/lib/instrumentation/modules/elasticsearch.js index c2a4da75f6..8e09d8dbbf 100644 --- a/lib/instrumentation/modules/elasticsearch.js +++ b/lib/instrumentation/modules/elasticsearch.js @@ -8,8 +8,8 @@ const { URL, URLSearchParams } = require('url') -var shimmer = require('../shimmer') -var { getDBDestination } = require('../context') +const shimmer = require('../shimmer') +const { getDBDestination } = require('../context') const { getElasticsearchDbStatement } = require('../elasticsearch-shared') const startsWithProtocolRE = /^([a-z]+:)?\/\//i @@ -76,10 +76,10 @@ module.exports = function (elasticsearch, agent, { enabled }) { function wrapRequest (original) { return function wrappedRequest (params, cb) { - var span = ins.createSpan(null, 'db', 'elasticsearch', 'request', { exitSpan: true }) - var id = span && span.transaction.id - var method = params && params.method - var path = params && params.path + const span = ins.createSpan(null, 'db', 'elasticsearch', 'request', { exitSpan: true }) + const id = span && span.transaction.id + const method = params && params.method + const path = params && params.path agent.logger.debug('intercepted call to elasticsearch.Transport.prototype.request %o', { id: id, method: method, path: path }) diff --git a/lib/instrumentation/modules/express-graphql.js b/lib/instrumentation/modules/express-graphql.js index 356d3f5605..373af6ca06 100644 --- a/lib/instrumentation/modules/express-graphql.js +++ b/lib/instrumentation/modules/express-graphql.js @@ -6,7 +6,7 @@ 'use strict' -var semver = require('semver') +const semver = require('semver') const shimmer = require('../shimmer') @@ -41,7 +41,7 @@ module.exports = function (expressGraphql, agent, { version, enabled }) { function wrapGraphqlHTTP (origGraphqlHTTP) { return function wrappedGraphqlHTTP () { - var orig = origGraphqlHTTP.apply(this, arguments) + const orig = origGraphqlHTTP.apply(this, arguments) if (typeof orig !== 'function') { return orig @@ -49,7 +49,7 @@ module.exports = function (expressGraphql, agent, { version, enabled }) { // Express is very particular with the number of arguments! return function (req, res) { - var trans = agent._instrumentation.currTransaction() + const trans = agent._instrumentation.currTransaction() if (trans) { trans._graphqlRoute = true } diff --git a/lib/instrumentation/modules/express-queue.js b/lib/instrumentation/modules/express-queue.js index 14ea180826..745cd27247 100644 --- a/lib/instrumentation/modules/express-queue.js +++ b/lib/instrumentation/modules/express-queue.js @@ -6,15 +6,15 @@ 'use strict' -var shimmer = require('../shimmer') +const shimmer = require('../shimmer') module.exports = function (expressQueue, agent, { enabled }) { if (!enabled) return expressQueue - var ins = agent._instrumentation + const ins = agent._instrumentation return function wrappedExpressQueue (config) { - var result = expressQueue(config) + const result = expressQueue(config) shimmer.wrap(result.queue, 'createJob', function (original) { return function (job) { if (job.next) { diff --git a/lib/instrumentation/modules/express.js b/lib/instrumentation/modules/express.js index 9f420e7ec4..3c11af4a03 100644 --- a/lib/instrumentation/modules/express.js +++ b/lib/instrumentation/modules/express.js @@ -6,11 +6,11 @@ 'use strict' -var isError = require('core-util-is').isError -var semver = require('semver') +const isError = require('core-util-is').isError +const semver = require('semver') -var shimmer = require('../shimmer') -var symbols = require('../../symbols') +const shimmer = require('../shimmer') +const symbols = require('../../symbols') module.exports = function (express, agent, { version, enabled }) { if (!enabled) return express @@ -23,11 +23,11 @@ module.exports = function (express, agent, { version, enabled }) { } // express 5 moves the router methods onto a prototype - var routerProto = semver.satisfies(version, '^5') + const routerProto = semver.satisfies(version, '^5') ? (express.Router && express.Router.prototype) : express.Router - var layerPatchedSymbol = Symbol('layer-patched') + const layerPatchedSymbol = Symbol('layer-patched') function shouldReport (err) { if (!agent._conf.captureExceptions) return false @@ -97,8 +97,8 @@ module.exports = function (express, agent, { version, enabled }) { shimmer.wrap(routerProto, 'route', orig => { return function route (path) { - var route = orig.apply(this, arguments) - var layer = this.stack[this.stack.length - 1] + const route = orig.apply(this, arguments) + const layer = this.stack[this.stack.length - 1] patchLayer(layer, path) return route } @@ -106,8 +106,8 @@ module.exports = function (express, agent, { version, enabled }) { shimmer.wrap(routerProto, 'use', orig => { return function use (path) { - var route = orig.apply(this, arguments) - var layer = this.stack[this.stack.length - 1] + const route = orig.apply(this, arguments) + const layer = this.stack[this.stack.length - 1] patchLayer(layer, typeof path === 'string' && path) return route } @@ -129,7 +129,7 @@ module.exports = function (express, agent, { version, enabled }) { return wrappedStatic function wrappedStatic () { - var origServeStatic = orig.apply(this, arguments) + const origServeStatic = orig.apply(this, arguments) return function serveStatic (req, res, next) { req[symbols.staticFile] = true diff --git a/lib/instrumentation/modules/finalhandler.js b/lib/instrumentation/modules/finalhandler.js index 251775a8d2..f5ff65045a 100644 --- a/lib/instrumentation/modules/finalhandler.js +++ b/lib/instrumentation/modules/finalhandler.js @@ -14,9 +14,9 @@ // The `errorReportedSymbol` symbol is used to coordinate with 'express' // instrumentation to avoid double-reporting errors. -var isError = require('core-util-is').isError +const isError = require('core-util-is').isError -var symbols = require('../../symbols') +const symbols = require('../../symbols') function shouldReport (err) { if (typeof err === 'string') return true @@ -29,7 +29,7 @@ function shouldReport (err) { module.exports = function (finalhandler, agent) { return function wrappedFinalhandler (req, res, options) { - var final = finalhandler.apply(this, arguments) + const final = finalhandler.apply(this, arguments) return function (err) { if (shouldReport(err)) { diff --git a/lib/instrumentation/modules/generic-pool.js b/lib/instrumentation/modules/generic-pool.js index f9b050c124..f0f1352f0b 100644 --- a/lib/instrumentation/modules/generic-pool.js +++ b/lib/instrumentation/modules/generic-pool.js @@ -6,22 +6,22 @@ 'use strict' -var semver = require('semver') +const semver = require('semver') -var shimmer = require('../shimmer') +const shimmer = require('../shimmer') module.exports = function (generic, agent, { version }) { if (semver.satisfies(version, '^2.0.0')) { agent.logger.debug('shimming generic-pool.Pool') shimmer.wrap(generic, 'Pool', function (orig) { return function wrappedPool () { - var trans = agent._instrumentation.currTransaction() - var id = trans && trans.id + const trans = agent._instrumentation.currTransaction() + const id = trans && trans.id agent.logger.debug('intercepted call to generic-pool.Pool %o', { id: id }) - var pool + let pool if (this instanceof generic.Pool) { - var args = [].slice.call(arguments) + const args = [].slice.call(arguments) args.unshift(null) pool = new (Function.prototype.bind.apply(orig, args))() } else { @@ -30,11 +30,11 @@ module.exports = function (generic, agent, { version }) { shimmer.wrap(pool, 'acquire', function (orig) { return function wrappedAcquire () { - var trans = agent._instrumentation.currTransaction() - var id = trans && trans.id + const trans = agent._instrumentation.currTransaction() + const id = trans && trans.id agent.logger.debug('intercepted call to pool.acquire %o', { id: id }) - var cb = arguments[0] + const cb = arguments[0] if (typeof cb === 'function') { arguments[0] = agent._instrumentation.bindFunction(cb) } @@ -57,11 +57,11 @@ module.exports = function (generic, agent, { version }) { agent.logger.debug('shimming generic-pool.PriorityQueue.prototype.enqueue') shimmer.wrap(generic.PriorityQueue.prototype, 'enqueue', function (orig) { return function wrappedEnqueue () { - var trans = agent._instrumentation.currTransaction() - var id = trans && trans.id + const trans = agent._instrumentation.currTransaction() + const id = trans && trans.id agent.logger.debug('intercepted call to generic-pool.PriorityQueue.prototype.enqueue %o', { id: id }) - var obj = arguments[0] + const obj = arguments[0] // Expect obj to of type Deferred if (obj._resolve && obj._reject) { obj._resolve = agent._instrumentation.bindFunction(obj._resolve) diff --git a/lib/instrumentation/modules/graphql.js b/lib/instrumentation/modules/graphql.js index 214cb80d11..82df26f5e6 100644 --- a/lib/instrumentation/modules/graphql.js +++ b/lib/instrumentation/modules/graphql.js @@ -6,10 +6,10 @@ 'use strict' -var semver = require('semver') -var clone = require('shallow-clone-shim') +const semver = require('semver') +const clone = require('shallow-clone-shim') -var getPathFromRequest = require('../express-utils').getPathFromRequest +const getPathFromRequest = require('../express-utils').getPathFromRequest module.exports = function (graphql, agent, { version, enabled }) { if (!enabled) return graphql @@ -85,7 +85,7 @@ module.exports = function (graphql, agent, { version, enabled }) { ? new graphql.Source(source || '', 'GraphQL request') : source) if (sourceObj) { - var documentAST + let documentAST try { documentAST = graphql.parse(sourceObj) @@ -94,9 +94,9 @@ module.exports = function (graphql, agent, { version, enabled }) { } if (documentAST) { - var validationErrors = graphql.validate(schema, documentAST) + const validationErrors = graphql.validate(schema, documentAST) if (validationErrors && validationErrors.length === 0) { - var queries = extractDetails(documentAST, operationName).queries + const queries = extractDetails(documentAST, operationName).queries if (queries.length > 0) span.name = 'GraphQL: ' + queries.join(', ') } } @@ -133,8 +133,8 @@ module.exports = function (graphql, agent, { version, enabled }) { operationName = arguments[5] } - var details = extractDetails(document, operationName) - var queries = details.queries + const details = extractDetails(document, operationName) + const queries = details.queries operationName = operationName || (details.operation && details.operation.name && details.operation.name.value) if (queries.length > 0) { span.name = 'GraphQL: ' + (operationName ? operationName + ' ' : '') + queries.join(', ') @@ -145,9 +145,9 @@ module.exports = function (graphql, agent, { version, enabled }) { // indicate that this transaction is for a GraphQL request. const trans = span.transaction if (trans._graphqlRoute) { - var name = queries.length > 0 ? queries.join(', ') : 'Unknown GraphQL query' + const name = queries.length > 0 ? queries.join(', ') : 'Unknown GraphQL query' if (trans.req) var path = getPathFromRequest(trans.req, true) - var defaultName = name + let defaultName = name defaultName = path ? defaultName + ' (' + path + ')' : defaultName defaultName = operationName ? operationName + ' ' + defaultName : defaultName trans.setDefaultName(defaultName) @@ -168,8 +168,8 @@ module.exports = function (graphql, agent, { version, enabled }) { } function extractDetails (document, operationName) { - var queries = [] - var operation + let queries = [] + let operation if (document && Array.isArray(document.definitions)) { document.definitions.some(function (definition) { @@ -181,7 +181,7 @@ module.exports = function (graphql, agent, { version, enabled }) { } }) - var selections = operation && operation.selectionSet && operation.selectionSet.selections + const selections = operation && operation.selectionSet && operation.selectionSet.selections if (selections && Array.isArray(selections)) { for (const selection of selections) { const kind = selection.name && selection.name.kind diff --git a/lib/instrumentation/modules/handlebars.js b/lib/instrumentation/modules/handlebars.js index 85065655d1..ee1597a50d 100644 --- a/lib/instrumentation/modules/handlebars.js +++ b/lib/instrumentation/modules/handlebars.js @@ -6,8 +6,8 @@ 'use strict' -var shimmer = require('../shimmer') -var templateShared = require('../template-shared') +const shimmer = require('../shimmer') +const templateShared = require('../template-shared') module.exports = function (handlebars, agent, { enabled }) { if (!enabled) return handlebars diff --git a/lib/instrumentation/modules/hapi.js b/lib/instrumentation/modules/hapi.js index dad5e0b7e7..adf7c488cf 100644 --- a/lib/instrumentation/modules/hapi.js +++ b/lib/instrumentation/modules/hapi.js @@ -6,11 +6,11 @@ 'use strict' -var semver = require('semver') +const semver = require('semver') -var shimmer = require('../shimmer') +const shimmer = require('../shimmer') -var onPreAuthSym = Symbol('ElasticAPMOnPreAuth') +const onPreAuthSym = Symbol('ElasticAPMOnPreAuth') module.exports = function (hapi, agent, { version, enabled }) { if (!enabled) return hapi @@ -28,7 +28,7 @@ module.exports = function (hapi, agent, { version, enabled }) { if (isHapiGte17) { shimmer.massWrap(hapi, ['Server', 'server'], function (orig) { return function (options) { - var res = orig.apply(this, arguments) + const res = orig.apply(this, arguments) patchServer(res) return res } @@ -56,7 +56,7 @@ module.exports = function (hapi, agent, { version, enabled }) { // connection lifecycle hooks (in hapi 17+ the server always has // connections, though the `server.connections` property doesn't exists, // so this if-statement wont fire) - var conns = server.connections + const conns = server.connections if (conns && conns.length === 0) { agent.logger.debug('unable to enable hapi instrumentation on connectionless server') return @@ -99,7 +99,7 @@ module.exports = function (hapi, agent, { version, enabled }) { } // TODO: Find better location to put this than custom - var payload = { + const payload = { custom: { tags: event.tags, internals: event.internals, @@ -109,7 +109,7 @@ module.exports = function (hapi, agent, { version, enabled }) { request: req && req.raw && req.raw.req } - var err = payload.custom.data + let err = payload.custom.data if (!(err instanceof Error) && typeof err !== 'string') { err = 'hapi server emitted a ' + type + ' event tagged error' } @@ -131,10 +131,10 @@ module.exports = function (hapi, agent, { version, enabled }) { // stable in case the param names change // - path example: /foo/{bar*2} // - fingerprint example: /foo/?/? - var fingerprint = request.route.fingerprint || request.route.path + const fingerprint = request.route.fingerprint || request.route.path if (fingerprint) { - var name = (request.raw && request.raw.req && request.raw.req.method) || + let name = (request.raw && request.raw.req && request.raw.req.method) || (request.route.method && request.route.method.toUpperCase()) if (typeof name === 'string') { diff --git a/lib/instrumentation/modules/http.js b/lib/instrumentation/modules/http.js index 8f1fdecbbc..c30d228f7c 100644 --- a/lib/instrumentation/modules/http.js +++ b/lib/instrumentation/modules/http.js @@ -6,8 +6,8 @@ 'use strict' -var httpShared = require('../http-shared') -var shimmer = require('../shimmer') +const httpShared = require('../http-shared') +const shimmer = require('../shimmer') function getSafeHeaders (res) { return res.getHeaders ? res.getHeaders() : res._headers @@ -34,13 +34,13 @@ module.exports = function (http, agent, { enabled }) { function wrapWriteHead (original) { return function wrappedWriteHead () { - var headers = arguments.length === 1 + const headers = arguments.length === 1 ? getSafeHeaders(this) // might be because of implicit headers. : arguments[arguments.length - 1] - var result = original.apply(this, arguments) + const result = original.apply(this, arguments) - var trans = httpShared.transactionForResponse.get(this) + const trans = httpShared.transactionForResponse.get(this) if (trans) { httpShared.transactionForResponse.delete(this) diff --git a/lib/instrumentation/modules/http2.js b/lib/instrumentation/modules/http2.js index 2a8106b164..e37b3950c6 100644 --- a/lib/instrumentation/modules/http2.js +++ b/lib/instrumentation/modules/http2.js @@ -6,12 +6,12 @@ 'use strict' -var eos = require('end-of-stream') +const eos = require('end-of-stream') -var shimmer = require('../shimmer') -var symbols = require('../../symbols') -var { parseUrl } = require('../../parsers') -var { getHTTPDestination } = require('../context') +const shimmer = require('../shimmer') +const symbols = require('../../symbols') +const { parseUrl } = require('../../parsers') +const { getHTTPDestination } = require('../context') // Return true iff this is an HTTP 1.0 or 1.1 request. // @@ -28,7 +28,7 @@ module.exports = function (http2, agent, { enabled }) { } if (!enabled) return http2 - var ins = agent._instrumentation + const ins = agent._instrumentation agent.logger.debug('shimming http2.connect function') shimmer.wrap(http2, 'connect', wrapConnect) @@ -38,7 +38,7 @@ module.exports = function (http2, agent, { enabled }) { // the first server prototype it patches. function wrapCreateServer (original) { return function wrappedCreateServer (options, handler) { - var server = original.apply(this, arguments) + const server = original.apply(this, arguments) shimmer.wrap(server.constructor.prototype, 'emit', wrapEmit) wrappedCreateServer[symbols.unwrap]() return server @@ -46,12 +46,12 @@ module.exports = function (http2, agent, { enabled }) { } function wrapEmit (original) { - var patched = false + let patched = false return function wrappedEmit (event, stream, headers) { if (event === 'stream') { if (!patched) { patched = true - var proto = stream.constructor.prototype + const proto = stream.constructor.prototype shimmer.wrap(proto, 'pushStream', wrapPushStream) shimmer.wrap(proto, 'respondWithFile', wrapRespondWith) shimmer.wrap(proto, 'respondWithFD', wrapRespondWith) @@ -105,8 +105,8 @@ module.exports = function (http2, agent, { enabled }) { agent.logger.debug('intercepted request event call to http2.Server.prototype.emit for %s', req.url) - var traceparent = req.headers.traceparent || req.headers['elastic-apm-traceparent'] - var tracestate = req.headers.tracestate + const traceparent = req.headers.traceparent || req.headers['elastic-apm-traceparent'] + const tracestate = req.headers.tracestate const trans = agent.startTransaction(null, null, { childOf: traceparent, tracestate: tracestate @@ -126,7 +126,7 @@ module.exports = function (http2, agent, { enabled }) { } if (agent._conf.errorOnAbortedRequests) { - var duration = trans._timer.elapsed() + const duration = trans._timer.elapsed() if (duration > (agent._conf.abortedErrorThreshold * 1000)) { agent.captureError('Socket closed with active HTTP request (>' + agent._conf.abortedErrorThreshold + ' sec)', { request: req, @@ -151,9 +151,9 @@ module.exports = function (http2, agent, { enabled }) { } function updateHeaders (headers) { - var trans = agent._instrumentation.currTransaction() + const trans = agent._instrumentation.currTransaction() if (trans && !trans.ended) { - var status = headers[':status'] || 200 + const status = headers[':status'] || 200 trans.result = 'HTTP ' + status.toString()[0] + 'xx' trans.res.statusCode = status trans._setOutcomeFromHttpStatusCode(status) @@ -178,7 +178,7 @@ module.exports = function (http2, agent, { enabled }) { function wrapEnd (original) { return function (headers) { - var trans = agent._instrumentation.currTransaction() + const trans = agent._instrumentation.currTransaction() // `trans.res` might be removed, because before // https://github.com/nodejs/node/pull/20084 (e.g. in node v10.0.0) the // 'end' event could be called multiple times for the same Http2Stream, @@ -194,7 +194,7 @@ module.exports = function (http2, agent, { enabled }) { return function wrappedPushStream (...args) { // Note: Break the run context so that the wrapped `stream.respond` et al // for this pushStream do not overwrite outer transaction state. - var callback = args.pop() + const callback = args.pop() args.push(agent._instrumentation.bindFunctionToEmptyRunContext(callback)) return original.apply(this, args) } @@ -202,10 +202,10 @@ module.exports = function (http2, agent, { enabled }) { function mergeHeaders (source, target) { if (source === null) return target - var result = Object.assign({}, target) - var keys = Object.keys(source) + const result = Object.assign({}, target) + const keys = Object.keys(source) for (let i = 0; i < keys.length; i++) { - var key = keys[i] + const key = keys[i] if (typeof target[key] === 'undefined') { result[key] = source[key] } else if (Array.isArray(target[key])) { @@ -228,11 +228,11 @@ module.exports = function (http2, agent, { enabled }) { function wrapRequest (orig, host) { return function (headers) { agent.logger.debug('intercepted call to http2.request') - var method = headers[':method'] || 'GET' + const method = headers[':method'] || 'GET' const span = ins.createSpan(null, 'external', 'http', method, { exitSpan: true }) const parentRunContext = ins.currRunContext() - var parent = span || parentRunContext.currSpan() || parentRunContext.currTransaction() + const parent = span || parentRunContext.currSpan() || parentRunContext.currTransaction() if (parent) { const newHeaders = Object.assign({}, headers) parent.propagateTraceContextHeaders(newHeaders, function (carrier, name, value) { @@ -245,16 +245,16 @@ module.exports = function (http2, agent, { enabled }) { } const spanRunContext = parentRunContext.enterSpan(span) - var req = ins.withRunContext(spanRunContext, orig, this, ...arguments) + const req = ins.withRunContext(spanRunContext, orig, this, ...arguments) ins.bindEmitterToRunContext(parentRunContext, req) - var urlObj = parseUrl(headers[':path']) - var path = urlObj.pathname - var url = host + path + const urlObj = parseUrl(headers[':path']) + const path = urlObj.pathname + const url = host + path span.name = method + ' ' + host - var statusCode + let statusCode req.on('response', (headers) => { statusCode = headers[':status'] }) diff --git a/lib/instrumentation/modules/https.js b/lib/instrumentation/modules/https.js index c6591ca4b7..731f51b100 100644 --- a/lib/instrumentation/modules/https.js +++ b/lib/instrumentation/modules/https.js @@ -6,10 +6,10 @@ 'use strict' -var semver = require('semver') +const semver = require('semver') -var httpShared = require('../http-shared') -var shimmer = require('../shimmer') +const httpShared = require('../http-shared') +const shimmer = require('../shimmer') module.exports = function (https, agent, { version, enabled }) { if (agent._conf.instrumentIncomingHTTPRequests) { diff --git a/lib/instrumentation/modules/jade.js b/lib/instrumentation/modules/jade.js index f2f4480972..768f78f536 100644 --- a/lib/instrumentation/modules/jade.js +++ b/lib/instrumentation/modules/jade.js @@ -6,8 +6,8 @@ 'use strict' -var shimmer = require('../shimmer') -var templateShared = require('../template-shared') +const shimmer = require('../shimmer') +const templateShared = require('../template-shared') module.exports = function (jade, agent, { enabled }) { if (!enabled) return jade diff --git a/lib/instrumentation/modules/knex.js b/lib/instrumentation/modules/knex.js index af168d299c..02654e28f5 100644 --- a/lib/instrumentation/modules/knex.js +++ b/lib/instrumentation/modules/knex.js @@ -10,10 +10,10 @@ 'use strict' -var semver = require('semver') +const semver = require('semver') -var shimmer = require('../shimmer') -var symbols = require('../../symbols') +const shimmer = require('../shimmer') +const symbols = require('../../symbols') module.exports = function (Knex, agent, { version, enabled }) { if (!enabled) { @@ -40,10 +40,10 @@ module.exports = function (Knex, agent, { version, enabled }) { function wrapQueryStartPoint (original) { return function wrappedQueryStartPoint () { - var builder = original.apply(this, arguments) + const builder = original.apply(this, arguments) agent.logger.debug('capturing custom stack trace for knex') - var obj = {} + const obj = {} Error.captureStackTrace(obj) builder[symbols.knexStackObj] = obj @@ -53,7 +53,7 @@ module.exports = function (Knex, agent, { version, enabled }) { function wrapRunner (original) { return function wrappedRunner () { - var runner = original.apply(this, arguments) + const runner = original.apply(this, arguments) agent.logger.debug('shimming knex runner.query') shimmer.wrap(runner, 'query', wrapQuery) diff --git a/lib/instrumentation/modules/koa-router.js b/lib/instrumentation/modules/koa-router.js index 4a08e404ba..0d827695cd 100644 --- a/lib/instrumentation/modules/koa-router.js +++ b/lib/instrumentation/modules/koa-router.js @@ -6,9 +6,9 @@ 'use strict' -var semver = require('semver') +const semver = require('semver') -var shimmer = require('../shimmer') +const shimmer = require('../shimmer') module.exports = function (Router, agent, { version, enabled }) { if (!enabled) return Router @@ -20,7 +20,7 @@ module.exports = function (Router, agent, { version, enabled }) { agent.logger.debug('shimming koa-router prototype.match function') shimmer.wrap(Router.prototype, 'match', function (orig) { return function (_, method) { - var matched = orig.apply(this, arguments) + const matched = orig.apply(this, arguments) if (typeof method !== 'string') { agent.logger.debug('unexpected method type in koa-router prototype.match: %s', typeof method) @@ -32,9 +32,9 @@ module.exports = function (Router, agent, { version, enabled }) { return layer && layer.opts && layer.opts.end === true }) - var path = layer && layer.path + const path = layer && layer.path if (typeof path === 'string') { - var name = method + ' ' + path + const name = method + ' ' + path agent._instrumentation.setDefaultTransactionName(name) } else { agent.logger.debug('unexpected path type in koa-router prototype.match: %s', typeof path) diff --git a/lib/instrumentation/modules/memcached.js b/lib/instrumentation/modules/memcached.js index cb84817899..b641eda8cd 100644 --- a/lib/instrumentation/modules/memcached.js +++ b/lib/instrumentation/modules/memcached.js @@ -6,10 +6,10 @@ 'use strict' -var semver = require('semver') +const semver = require('semver') -var shimmer = require('../shimmer') -var { getDBDestination } = require('../context') +const shimmer = require('../shimmer') +const { getDBDestination } = require('../context') module.exports = function (memcached, agent, { version, enabled }) { if (!enabled) { @@ -48,7 +48,7 @@ module.exports = function (memcached, agent, { version, enabled }) { return original.apply(this, arguments) } - var query = queryCompiler() + const query = queryCompiler() // Replace the queryCompiler function so it isn't called a second time. arguments[0] = function prerunQueryCompiler () { return query diff --git a/lib/instrumentation/modules/mimic-response.js b/lib/instrumentation/modules/mimic-response.js index 51a9bd8cfd..36d6825dca 100644 --- a/lib/instrumentation/modules/mimic-response.js +++ b/lib/instrumentation/modules/mimic-response.js @@ -12,7 +12,7 @@ * See https://github.com/elastic/apm-agent-nodejs/issues/423. */ -var semver = require('semver') +const semver = require('semver') module.exports = function (mimicResponse, agent, { version, enabled }) { if (!enabled) return mimicResponse @@ -22,7 +22,7 @@ module.exports = function (mimicResponse, agent, { version, enabled }) { return mimicResponse } - var ins = agent._instrumentation + const ins = agent._instrumentation return function wrappedMimicResponse (fromStream, toStream) { // If we bound the `fromStream` emitter, but not the `toStream` emitter, we diff --git a/lib/instrumentation/modules/mongodb-core.js b/lib/instrumentation/modules/mongodb-core.js index ab08f7e671..42b818bab8 100644 --- a/lib/instrumentation/modules/mongodb-core.js +++ b/lib/instrumentation/modules/mongodb-core.js @@ -6,13 +6,13 @@ 'use strict' -var semver = require('semver') +const semver = require('semver') const { getDBDestination } = require('../context') -var shimmer = require('../shimmer') +const shimmer = require('../shimmer') -var SERVER_FNS = ['insert', 'update', 'remove', 'auth'] -var CURSOR_FNS_FIRST = ['next', '_getmore'] +const SERVER_FNS = ['insert', 'update', 'remove', 'auth'] +const CURSOR_FNS_FIRST = ['next', '_getmore'] const firstSpan = Symbol('first-span') @@ -41,17 +41,17 @@ module.exports = function (mongodb, agent, { version, enabled }) { function wrapCommand (orig) { return function wrappedFunction (ns, cmd) { - var trans = agent._instrumentation.currTransaction() - var id = trans && trans.id - var span + const trans = agent._instrumentation.currTransaction() + const id = trans && trans.id + let span agent.logger.debug('intercepted call to mongodb-core.Server.prototype.command %o', { id: id, ns: ns }) if (trans && arguments.length > 0) { - var index = arguments.length - 1 + const index = arguments.length - 1 var cb = arguments[index] if (typeof cb === 'function') { - var type + let type if (cmd.findAndModify) type = 'findAndModify' else if (cmd.createIndexes) type = 'createIndexes' else if (cmd.ismaster) type = 'ismaster' @@ -82,14 +82,14 @@ module.exports = function (mongodb, agent, { version, enabled }) { function wrapQuery (orig, name) { return function wrappedFunction (ns) { - var trans = agent._instrumentation.currTransaction() - var id = trans && trans.id - var span + const trans = agent._instrumentation.currTransaction() + const id = trans && trans.id + let span agent.logger.debug('intercepted call to mongodb-core.Server.prototype.%s %o', name, { id: id, ns: ns }) if (trans && arguments.length > 0) { - var index = arguments.length - 1 + const index = arguments.length - 1 var cb = arguments[index] if (typeof cb === 'function') { span = ins.createSpan(ns + '.' + name, 'db', 'mongodb', 'query', { exitSpan: true }) @@ -115,9 +115,9 @@ module.exports = function (mongodb, agent, { version, enabled }) { } function wrapCursor (orig, name) { return function wrappedFunction () { - var trans = agent._instrumentation.currTransaction() - var id = trans && trans.id - var span + const trans = agent._instrumentation.currTransaction() + const id = trans && trans.id + let span agent.logger.debug('intercepted call to mongodb-core.Cursor.prototype.%s %o', name, { id: id }) @@ -125,7 +125,7 @@ module.exports = function (mongodb, agent, { version, enabled }) { var cb = arguments[0] if (typeof cb === 'function') { if (name !== 'next' || !this[firstSpan]) { - var spanName = `${this.ns}.${this.cmd.find ? 'find' : name}` + const spanName = `${this.ns}.${this.cmd.find ? 'find' : name}` span = ins.createSpan(spanName, 'db', 'mongodb', 'query', { exitSpan: true }) } if (span) { diff --git a/lib/instrumentation/modules/mysql.js b/lib/instrumentation/modules/mysql.js index bfad3b991e..f8040f72f9 100644 --- a/lib/instrumentation/modules/mysql.js +++ b/lib/instrumentation/modules/mysql.js @@ -8,12 +8,12 @@ const EventEmitter = require('events') -var semver = require('semver') -var sqlSummary = require('sql-summary') +const semver = require('semver') +const sqlSummary = require('sql-summary') -var shimmer = require('../shimmer') -var symbols = require('../../symbols') -var { getDBDestination } = require('../context') +const shimmer = require('../shimmer') +const symbols = require('../../symbols') +const { getDBDestination } = require('../context') module.exports = function (mysql, agent, { version, enabled }) { if (!enabled) { @@ -37,7 +37,7 @@ module.exports = function (mysql, agent, { version, enabled }) { function wrapCreateConnection (original) { return function wrappedCreateConnection () { - var connection = original.apply(this, arguments) + const connection = original.apply(this, arguments) wrapQueryable(connection, 'connection', agent) @@ -47,7 +47,7 @@ module.exports = function (mysql, agent, { version, enabled }) { function wrapCreatePool (original) { return function wrappedCreatePool () { - var pool = original.apply(this, arguments) + const pool = original.apply(this, arguments) agent.logger.debug('shimming mysql pool.getConnection') shimmer.wrap(pool, 'getConnection', wrapGetConnection) @@ -58,12 +58,12 @@ module.exports = function (mysql, agent, { version, enabled }) { function wrapCreatePoolCluster (original) { return function wrappedCreatePoolCluster () { - var cluster = original.apply(this, arguments) + const cluster = original.apply(this, arguments) agent.logger.debug('shimming mysql cluster.of') shimmer.wrap(cluster, 'of', function wrapOf (original) { return function wrappedOf () { - var ofCluster = original.apply(this, arguments) + const ofCluster = original.apply(this, arguments) agent.logger.debug('shimming mysql cluster of.getConnection') shimmer.wrap(ofCluster, 'getConnection', wrapGetConnection) @@ -78,7 +78,7 @@ module.exports = function (mysql, agent, { version, enabled }) { function wrapGetConnection (original) { return function wrappedGetConnection () { - var cb = arguments[0] + const cb = arguments[0] if (typeof cb === 'function') { arguments[0] = agent._instrumentation.bindFunction(function wrapedCallback (err, connection) { // eslint-disable-line node/handle-callback-err @@ -107,13 +107,13 @@ function wrapQueryable (connection, objType, agent) { return function wrappedQuery (sql, values, cb) { agent.logger.debug('intercepted call to mysql %s.query', objType) - var span = ins.createSpan(null, 'db', 'mysql', 'query', { exitSpan: true }) + const span = ins.createSpan(null, 'db', 'mysql', 'query', { exitSpan: true }) if (!span) { return original.apply(this, arguments) } - var hasCallback = false - var sqlStr + let hasCallback = false + let sqlStr if (this[symbols.knexStackObj]) { span.customStackTrace(this[symbols.knexStackObj]) diff --git a/lib/instrumentation/modules/mysql2.js b/lib/instrumentation/modules/mysql2.js index 7570001368..5c003f34fc 100644 --- a/lib/instrumentation/modules/mysql2.js +++ b/lib/instrumentation/modules/mysql2.js @@ -6,12 +6,12 @@ 'use strict' -var semver = require('semver') -var sqlSummary = require('sql-summary') +const semver = require('semver') +const sqlSummary = require('sql-summary') -var shimmer = require('../shimmer') -var symbols = require('../../symbols') -var { getDBDestination } = require('../context') +const shimmer = require('../shimmer') +const symbols = require('../../symbols') +const { getDBDestination } = require('../context') module.exports = function (mysql2, agent, { version, enabled }) { if (!enabled) { @@ -22,7 +22,7 @@ module.exports = function (mysql2, agent, { version, enabled }) { return mysql2 } - var ins = agent._instrumentation + const ins = agent._instrumentation shimmer.wrap(mysql2.Connection.prototype, 'query', wrapQuery) shimmer.wrap(mysql2.Connection.prototype, 'execute', wrapQuery) @@ -33,7 +33,7 @@ module.exports = function (mysql2, agent, { version, enabled }) { return function wrappedQuery (sql, values, cb) { agent.logger.debug('intercepted call to mysql2.%s', original.name) - var span = ins.createSpan(null, 'db', 'mysql', 'query', { exitSpan: true }) + const span = ins.createSpan(null, 'db', 'mysql', 'query', { exitSpan: true }) if (!span) { return original.apply(this, arguments) } diff --git a/lib/instrumentation/modules/pg.js b/lib/instrumentation/modules/pg.js index dca971b379..4a0d16f669 100644 --- a/lib/instrumentation/modules/pg.js +++ b/lib/instrumentation/modules/pg.js @@ -8,12 +8,12 @@ const EventEmitter = require('events') -var semver = require('semver') -var sqlSummary = require('sql-summary') +const semver = require('semver') +const sqlSummary = require('sql-summary') -var shimmer = require('../shimmer') -var symbols = require('../../symbols') -var { getDBDestination } = require('../context') +const shimmer = require('../shimmer') +const symbols = require('../../symbols') +const { getDBDestination } = require('../context') module.exports = function (pg, agent, { version, enabled }) { if (!enabled) { @@ -30,13 +30,13 @@ module.exports = function (pg, agent, { version, enabled }) { // "Cannot find module 'pg-native'" to STDERR if the module isn't installed. // Overwriting the getter we can lazily patch the native client only if the // user is acually requesting it. - var getter = pg.__lookupGetter__('native') + const getter = pg.__lookupGetter__('native') if (getter) { delete pg.native // To be as true to the original pg module as possible, we use // __defineGetter__ instead of Object.defineProperty. pg.__defineGetter__('native', function () { - var native = getter() + const native = getter() if (native && native.Client) { patchClient(native.Client, 'pg.native.Client', agent) } @@ -111,7 +111,7 @@ function patchClient (Client, klass, agent) { }) return orig.apply(this, arguments) } else { - var queryOrPromise = orig.apply(this, arguments) + const queryOrPromise = orig.apply(this, arguments) // It is important to prefer `.on` to `.then` for pg <7 >=6.3.0, because // `query.then` is broken in those versions. See diff --git a/lib/instrumentation/modules/pug.js b/lib/instrumentation/modules/pug.js index b00597c1f8..e88e57823a 100644 --- a/lib/instrumentation/modules/pug.js +++ b/lib/instrumentation/modules/pug.js @@ -6,8 +6,8 @@ 'use strict' -var shimmer = require('../shimmer') -var templateShared = require('../template-shared') +const shimmer = require('../shimmer') +const templateShared = require('../template-shared') module.exports = function (pug, agent, { enabled }) { if (!enabled) return pug diff --git a/lib/instrumentation/modules/redis.js b/lib/instrumentation/modules/redis.js index b8a4b507ba..0d044905df 100644 --- a/lib/instrumentation/modules/redis.js +++ b/lib/instrumentation/modules/redis.js @@ -6,11 +6,11 @@ 'use strict' -var semver = require('semver') +const semver = require('semver') const constants = require('../../constants') -var shimmer = require('../shimmer') -var { getDBDestination } = require('../context') +const shimmer = require('../shimmer') +const { getDBDestination } = require('../context') const isWrappedRedisCbSym = Symbol('ElasticAPMIsWrappedRedisCb') @@ -39,7 +39,7 @@ module.exports = function (redis, agent, { version, enabled }) { const connOptsFromRedisClient = (rc) => rc.connection_options || rc.connection_option || rc.connectionOption || {} - var proto = redis.RedisClient && redis.RedisClient.prototype + const proto = redis.RedisClient && redis.RedisClient.prototype if (semver.satisfies(version, '>2.5.3')) { agent.logger.debug('shimming redis.RedisClient.prototype.internal_send_command') shimmer.wrap(proto, 'internal_send_command', wrapInternalSendCommand) @@ -113,7 +113,7 @@ module.exports = function (redis, agent, { version, enabled }) { } agent.logger.debug({ command: command }, 'intercepted call to RedisClient.prototype.send_command') - var span = ins.createSpan(command.toUpperCase(), TYPE, SUBTYPE, ACTION, { exitSpan: true }) + const span = ins.createSpan(command.toUpperCase(), TYPE, SUBTYPE, ACTION, { exitSpan: true }) if (!span) { return original.apply(this, arguments) } diff --git a/lib/instrumentation/modules/tedious.js b/lib/instrumentation/modules/tedious.js index 4a95631f10..4bb90cb1d1 100644 --- a/lib/instrumentation/modules/tedious.js +++ b/lib/instrumentation/modules/tedious.js @@ -6,11 +6,11 @@ 'use strict' -var semver = require('semver') -var clone = require('shallow-clone-shim') -var sqlSummary = require('sql-summary') +const semver = require('semver') +const clone = require('shallow-clone-shim') +const sqlSummary = require('sql-summary') -var { getDBDestination } = require('../context') +const { getDBDestination } = require('../context') module.exports = function (tedious, agent, { version, enabled }) { if (!enabled) return tedious diff --git a/lib/instrumentation/modules/ws.js b/lib/instrumentation/modules/ws.js index 4a20774695..0e9141663d 100644 --- a/lib/instrumentation/modules/ws.js +++ b/lib/instrumentation/modules/ws.js @@ -6,9 +6,9 @@ 'use strict' -var semver = require('semver') +const semver = require('semver') -var shimmer = require('../shimmer') +const shimmer = require('../shimmer') module.exports = function (ws, agent, { version, enabled }) { if (!enabled) return ws diff --git a/lib/instrumentation/patch-async.js b/lib/instrumentation/patch-async.js index 6cc81e106d..119f23f7f2 100644 --- a/lib/instrumentation/patch-async.js +++ b/lib/instrumentation/patch-async.js @@ -23,21 +23,21 @@ * BSD-2-Clause, http://opensource.org/licenses/BSD-2-Clause */ -var { promisify } = require('util') +const { promisify } = require('util') -var isNative = require('is-native') -var semver = require('semver') +const isNative = require('is-native') +const semver = require('semver') -var shimmer = require('./shimmer') +const shimmer = require('./shimmer') -var wrap = shimmer.wrap -var massWrap = shimmer.massWrap +const wrap = shimmer.wrap +const massWrap = shimmer.massWrap -var v7plus = semver.gte(process.version, '7.0.0') -var v11plus = semver.gte(process.version, '11.0.0') +const v7plus = semver.gte(process.version, '7.0.0') +const v11plus = semver.gte(process.version, '11.0.0') module.exports = function (ins) { - var net = require('net') + const net = require('net') // From Node.js v7.0.0, net._normalizeConnectArgs have been renamed net._normalizeArgs if (v7plus && !net._normalizeArgs) { @@ -47,8 +47,8 @@ module.exports = function (ins) { return [{}, null] } - var arg0 = args[0] - var options = {} + const arg0 = args[0] + let options = {} if (typeof arg0 === 'object' && arg0 !== null) { // (options[...][, cb]) options = arg0 @@ -63,7 +63,7 @@ module.exports = function (ins) { } } - var cb = args[args.length - 1] + const cb = args[args.length - 1] if (typeof cb !== 'function') { return [options, null] } else { @@ -73,7 +73,7 @@ module.exports = function (ins) { } else if (!v7plus && !net._normalizeConnectArgs) { // a polyfill in our polyfill etc so forth -- taken from node master on 2013/10/30 net._normalizeConnectArgs = function (args) { - var options = {} + let options = {} function toNumber (x) { return (x = Number(x)) >= 0 ? x : false } @@ -91,7 +91,7 @@ module.exports = function (ins) { } } - var cb = args[args.length - 1] + const cb = args[args.length - 1] return typeof cb === 'function' ? [options, cb] : [options] } } @@ -117,7 +117,7 @@ module.exports = function (ins) { function patchOnRead (ctx) { if (ctx && ctx._handle) { - var handle = ctx._handle + const handle = ctx._handle if (!handle._obOriginalOnread) { handle._obOriginalOnread = handle.onread } @@ -128,17 +128,17 @@ module.exports = function (ins) { wrap(net.Socket.prototype, 'connect', function (original) { return function () { // From Node.js v7.0.0, net._normalizeConnectArgs have been renamed net._normalizeArgs - var args = v7plus + const args = v7plus ? net._normalizeArgs(arguments) : net._normalizeConnectArgs(arguments) if (args[1]) args[1] = ins.bindFunction(args[1]) - var result = original.apply(this, args) + const result = original.apply(this, args) patchOnRead(this) return result } }) - var http = require('http') + const http = require('http') // NOTE: A rewrite occurred in 0.11 that changed the addRequest signature // from (req, host, port, localAddress) to (req, options) @@ -146,7 +146,7 @@ module.exports = function (ins) { // the rest of the arguments aren't actually used wrap(http.Agent.prototype, 'addRequest', function (original) { return function (req) { - var onSocket = req.onSocket + const onSocket = req.onSocket req.onSocket = ins.bindFunction(function (socket) { patchOnRead(socket) return onSocket.apply(this, arguments) @@ -155,7 +155,7 @@ module.exports = function (ins) { } }) - var childProcess = require('child_process') + const childProcess = require('child_process') function wrapChildProcess (child) { if (Array.isArray(child.stdio)) { @@ -176,7 +176,7 @@ module.exports = function (ins) { if (childProcess.ChildProcess) { wrap(childProcess.ChildProcess.prototype, 'spawn', function (original) { return function () { - var result = original.apply(this, arguments) + const result = original.apply(this, arguments) wrapChildProcess(this) return result } @@ -188,7 +188,7 @@ module.exports = function (ins) { 'spawn' ], function (original) { return function () { - var result = original.apply(this, arguments) + const result = original.apply(this, arguments) wrapChildProcess(result) return result } @@ -200,7 +200,7 @@ module.exports = function (ins) { process._originalNextTick = process.nextTick } - var processors = [] + const processors = [] if (process._nextDomainTick) processors.push('_nextDomainTick') if (process._tickDomainCallback) processors.push('_tickDomainCallback') @@ -211,14 +211,14 @@ module.exports = function (ins) { ) wrap(process, 'nextTick', activatorFirst) - var asynchronizers = [ + const asynchronizers = [ 'setTimeout', 'setInterval' ] if (global.setImmediate) asynchronizers.push('setImmediate') - var timers = require('timers') - var patchGlobalTimers = global.setTimeout === timers.setTimeout + const timers = require('timers') + const patchGlobalTimers = global.setTimeout === timers.setTimeout massWrap( timers, @@ -234,7 +234,7 @@ module.exports = function (ins) { ) } - var dns = require('dns') + const dns = require('dns') massWrap( dns, [ @@ -254,8 +254,8 @@ module.exports = function (ins) { if (dns.resolveNaptr) wrap(dns, 'resolveNaptr', activator) - var fs = require('fs') - var wrappedFsRealpathNative + const fs = require('fs') + let wrappedFsRealpathNative if (fs.realpath.native) { wrappedFsRealpathNative = wrap(fs.realpath, 'native', activator) } @@ -310,10 +310,10 @@ module.exports = function (ins) { if (fs.ftruncate) wrap(fs, 'ftruncate', activator) // Wrap zlib streams - var zlib + let zlib try { zlib = require('zlib') } catch (err) { } if (zlib && zlib.Deflate && zlib.Deflate.prototype) { - var proto = Object.getPrototypeOf(zlib.Deflate.prototype) + const proto = Object.getPrototypeOf(zlib.Deflate.prototype) if (proto._transform) { // streams2 wrap(proto, '_transform', activator) @@ -332,10 +332,10 @@ module.exports = function (ins) { } // Wrap Crypto - var crypto + let crypto try { crypto = require('crypto') } catch (err) { } if (crypto) { - var cryptoFunctions = ['pbkdf2', 'randomBytes'] + const cryptoFunctions = ['pbkdf2', 'randomBytes'] if (!v11plus) cryptoFunctions.push('pseudoRandomBytes') massWrap( crypto, @@ -344,7 +344,7 @@ module.exports = function (ins) { ) } - var instrumentPromise = isNative(global.Promise) + let instrumentPromise = isNative(global.Promise) // In case it's a non-native Promise, but bind have been used so it // looks native. There's still a potential false positive if the @@ -408,7 +408,7 @@ module.exports = function (ins) { } function wrapPromise () { - var Promise = global.Promise + const Promise = global.Promise wrap(Promise.prototype, 'then', wrapThen) // Node.js = 0 && !sourceMapUrl; i--) { + const lines = sourceFile.split(/\r?\n/) + let sourceMapUrl = null + for (let i = lines.length - 1; i >= 0 && !sourceMapUrl; i--) { sourceMapUrl = lines[i].match(SOURCEMAP_REGEX) } @@ -85,6 +85,6 @@ function isInlineMap (url) { } function decodeInlineMap (data) { - var rawData = data.slice(data.indexOf(',') + 1) + const rawData = data.slice(data.indexOf(',') + 1) return Buffer.from(rawData, 'base64').toString() } diff --git a/lib/logging.js b/lib/logging.js index 4727eadade..f934bf123f 100644 --- a/lib/logging.js +++ b/lib/logging.js @@ -34,9 +34,9 @@ // - error // - fatal - mapped to "critical" for backward compat -var ecsFormat = require('@elastic/ecs-pino-format') -var pino = require('pino') -var semver = require('semver') +const ecsFormat = require('@elastic/ecs-pino-format') +const pino = require('pino') +const semver = require('semver') const DEFAULT_LOG_LEVEL = 'info' diff --git a/lib/middleware/connect.js b/lib/middleware/connect.js index e6d4848f40..69385d9c3b 100644 --- a/lib/middleware/connect.js +++ b/lib/middleware/connect.js @@ -7,7 +7,7 @@ 'use strict' module.exports = function connectMiddleware () { - var agent = this + const agent = this return function (err, req, res, next) { agent.captureError(err, { request: req }, function elasticAPMMiddleware () { next(err) diff --git a/lib/opentelemetry-bridge/OTelSpan.js b/lib/opentelemetry-bridge/OTelSpan.js index f9341e465d..eda8127e7a 100644 --- a/lib/opentelemetry-bridge/OTelSpan.js +++ b/lib/opentelemetry-bridge/OTelSpan.js @@ -229,7 +229,7 @@ class OTelSpan { if (u.port !== '') { return u.host // host:port already in URL } else { - var port = httpPortFromScheme(u.protocol.substring(0, u.protocol.length - 1)) + const port = httpPortFromScheme(u.protocol.substring(0, u.protocol.length - 1)) return port > 0 ? u.hostname + ':' + port : u.hostname } } diff --git a/lib/opentelemetry-metrics/ElasticApmMetricExporter.js b/lib/opentelemetry-metrics/ElasticApmMetricExporter.js index db1b542df5..9cf4f3c573 100644 --- a/lib/opentelemetry-metrics/ElasticApmMetricExporter.js +++ b/lib/opentelemetry-metrics/ElasticApmMetricExporter.js @@ -247,7 +247,7 @@ class ElasticApmMetricExporter { */ _labelsFromOTelMetricAttributes (attrs, metricName) { const keys = Object.keys(attrs) - for (var i = 0; i < keys.length; i++) { + for (let i = 0; i < keys.length; i++) { const k = keys[i] const v = attrs[k] if (Array.isArray(v)) { diff --git a/lib/parsers.js b/lib/parsers.js index 17103d541f..5735c11eca 100644 --- a/lib/parsers.js +++ b/lib/parsers.js @@ -41,9 +41,9 @@ const { * is being captured for an APM error or transaction event. */ function getContextFromRequest (req, conf, type) { - var captureBody = conf.captureBody === type || conf.captureBody === 'all' + const captureBody = conf.captureBody === type || conf.captureBody === 'all' - var context = { + const context = { http_version: req.httpVersion, method: req.method, url: getUrlFromRequest(req), @@ -71,11 +71,11 @@ function getContextFromRequest (req, conf, type) { } } - var contentLength = parseInt(req.headers['content-length'], 10) - var transferEncoding = req.headers['transfer-encoding'] - var chunked = typeof transferEncoding === 'string' && transferEncoding.toLowerCase() === 'chunked' - var body = req.json || req.body || req.payload - var haveBody = body && (chunked || contentLength > 0) + const contentLength = parseInt(req.headers['content-length'], 10) + const transferEncoding = req.headers['transfer-encoding'] + const chunked = typeof transferEncoding === 'string' && transferEncoding.toLowerCase() === 'chunked' + let body = req.json || req.body || req.payload + const haveBody = body && (chunked || contentLength > 0) if (haveBody) { if (!captureBody) { @@ -103,7 +103,7 @@ function getContextFromRequest (req, conf, type) { } function getContextFromResponse (res, conf, isError) { - var context = { + const context = { status_code: res.statusCode, headers: undefined } @@ -132,12 +132,12 @@ function getContextFromResponse (res, conf, isError) { * - `headers` - Required. An object. */ function getUserContextFromRequest (req) { - var user = req.user || basicAuth(req) || req.session + const user = req.user || basicAuth(req) || req.session if (!user) { return } - var context = {} + const context = {} if (typeof user.id === 'string' || typeof user.id === 'number') { context.id = user.id diff --git a/lib/propwrap.js b/lib/propwrap.js index 194edc7bb5..952d78d0c5 100644 --- a/lib/propwrap.js +++ b/lib/propwrap.js @@ -39,11 +39,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -var __defProp = Object.defineProperty -var __getOwnPropDesc = Object.getOwnPropertyDescriptor -var __hasOwnProp = Object.prototype.hasOwnProperty -var __getOwnPropNames = Object.getOwnPropertyNames -var __copyProps = (to, from, except, desc) => { +const __defProp = Object.defineProperty +const __getOwnPropDesc = Object.getOwnPropertyDescriptor +const __hasOwnProp = Object.prototype.hasOwnProperty +const __getOwnPropNames = Object.getOwnPropertyNames +const __copyProps = (to, from, except, desc) => { if ((from && typeof from === 'object') || typeof from === 'function') { for (const key of __getOwnPropNames(from)) { if (!__hasOwnProp.call(to, key) && key !== except) { diff --git a/lib/redact-secrets/index.js b/lib/redact-secrets/index.js index 5dfdfbefbe..817e5a275d 100644 --- a/lib/redact-secrets/index.js +++ b/lib/redact-secrets/index.js @@ -28,8 +28,8 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -var traverse = require('traverse') -var isSecret = require('./is-secret') +const traverse = require('traverse') +const isSecret = require('./is-secret') module.exports = function (redacted) { return { diff --git a/lib/redact-secrets/is-secret.js b/lib/redact-secrets/is-secret.js index a985d702a4..442139665f 100644 --- a/lib/redact-secrets/is-secret.js +++ b/lib/redact-secrets/is-secret.js @@ -31,7 +31,7 @@ const agent = require('../..') -var KEYS = [ +const KEYS = [ // generic /passw(or)?d/i, /^pw$/, @@ -45,7 +45,7 @@ var KEYS = [ /^connect\.sid$/ // https://github.com/expressjs/session ] -var VALUES = [ +const VALUES = [ /^\d{4}[- ]?\d{4}[- ]?\d{4}[- ]?\d{4}$/ // credit card number ] exports.key = key diff --git a/lib/stacktraces.js b/lib/stacktraces.js index b3ed19935e..68d9d7d1d8 100644 --- a/lib/stacktraces.js +++ b/lib/stacktraces.js @@ -13,8 +13,8 @@ // A lot of this derived from https://github.com/watson/stackman but was // moved internal to allow breaking compat for perf work. -var fs = require('fs') -var path = require('path') +const fs = require('fs') +const path = require('path') const asyncCache = require('async-cache') const afterAllResults = require('after-all-results') @@ -113,7 +113,7 @@ function stackTraceFromErrStackString (log, err) { if (frames) { const cwd = getCwd(log) - for (var i = 0; i < frames.length; i++) { + for (let i = 0; i < frames.length; i++) { const frame = frames[i] const filename = frame.getFileName() || '' stacktrace.push({ @@ -212,17 +212,17 @@ function getCallSiteTypeNameSafely (callsite) { // From stackman getFunctionNameSanitized(). function getCallSiteFunctionNameSanitized (callsite) { - var fnName = callsite.getFunctionName() + const fnName = callsite.getFunctionName() if (fnName) return fnName - var typeName = getCallSiteTypeNameSafely(callsite) + const typeName = getCallSiteTypeNameSafely(callsite) if (typeName) return typeName + '.' + (callsite.getMethodName() || '') return '' } function addSourceContextToFrame (frame, lines, lineNum, n) { - var index = lineNum - 1 // lines 1-based -> index 0-based - var nBefore = Math.ceil((n - 1) / 2) - var nAfter = Math.floor((n - 1) / 2) + const index = lineNum - 1 // lines 1-based -> index 0-based + const nBefore = Math.ceil((n - 1) / 2) + const nAfter = Math.floor((n - 1) / 2) frame.pre_context = lines.slice(Math.max(0, index - nBefore), index) frame.context_line = lines[index] frame.post_context = lines.slice(index + 1, index + 1 + nAfter) @@ -242,7 +242,7 @@ function getSourceMapConsumer (callsite, cb) { if (isCallSiteNode(callsite)) { process.nextTick(cb, null, null) } else { - var filename = callsite.getFileName() + const filename = callsite.getFileName() if (!filename) { process.nextTick(cb, null, null) } else { @@ -351,7 +351,7 @@ function frameFromCallSite (log, callsite, cwd, sourceLinesAppFrames, sourceLine } // Finish early if we do not need to collect source lines of context. - var linesOfContext = (isApp ? sourceLinesAppFrames : sourceLinesLibraryFrames) + const linesOfContext = (isApp ? sourceLinesAppFrames : sourceLinesLibraryFrames) if (linesOfContext === 0 || !filename || isCallSiteNode(callsite)) { cacheAndCb(frame) return @@ -366,7 +366,7 @@ function frameFromCallSite (log, callsite, cwd, sourceLinesAppFrames, sourceLine const sourceFilename = sourceMapConsumer.sourceRoot ? path.relative(sourceMapConsumer.sourceRoot, mappedFilename) : mappedFilename - var source = sourceMapConsumer.sourceContentFor(sourceFilename, true) + const source = sourceMapConsumer.sourceContentFor(sourceFilename, true) log.trace({ sourceRoot: sourceMapConsumer.sourceRoot, mappedFilename, diff --git a/test/InflightEventSet.test.js b/test/InflightEventSet.test.js index f40a0bac31..9712768574 100644 --- a/test/InflightEventSet.test.js +++ b/test/InflightEventSet.test.js @@ -6,7 +6,7 @@ 'use strict' -var tape = require('tape') +const tape = require('tape') const { InflightEventSet } = require('../lib/InflightEventSet') diff --git a/test/_agent.js b/test/_agent.js index 90d208c1c2..3fd915a8ee 100644 --- a/test/_agent.js +++ b/test/_agent.js @@ -18,13 +18,13 @@ // t.end() // }) -var Agent = require('../lib/agent') -var symbols = require('../lib/symbols') +const Agent = require('../lib/agent') +const symbols = require('../lib/symbols') -var Filters = require('object-filter-sequence') +const Filters = require('object-filter-sequence') -var uncaughtExceptionListeners = process._events.uncaughtException -var agent +let uncaughtExceptionListeners = process._events.uncaughtException +let agent module.exports = setup diff --git a/test/_assert.js b/test/_assert.js index 4349b60a79..ac46bda2f0 100644 --- a/test/_assert.js +++ b/test/_assert.js @@ -6,9 +6,9 @@ 'use strict' -var path = require('path') -var Agent = require('../lib/agent') -var agent = new Agent() +const path = require('path') +const Agent = require('../lib/agent') +const agent = new Agent() agent._config({}) exports.stacktrace = function (t, topFunctionName, topAbsPath, stacktrace, _agent, isError) { @@ -21,17 +21,17 @@ exports.stacktrace = function (t, topFunctionName, topAbsPath, stacktrace, _agen } function stackFrameValidator (t, agent, isError) { - var conf = agent._conf + const conf = agent._conf return function (frame) { - var nodeCore = !path.isAbsolute(frame.abs_path) + const nodeCore = !path.isAbsolute(frame.abs_path) - var lines = isError + const lines = isError ? (frame.library_frame ? conf.sourceLinesErrorLibraryFrames : conf.sourceLinesErrorAppFrames) : (frame.library_frame ? conf.sourceLinesSpanLibraryFrames : conf.sourceLinesSpanAppFrames) - var shouldHaveSource = !nodeCore && lines !== 0 + const shouldHaveSource = !nodeCore && lines !== 0 - var expectedKeys = shouldHaveSource + const expectedKeys = shouldHaveSource ? ['filename', 'lineno', 'function', 'library_frame', 'abs_path', 'pre_context', 'context_line', 'post_context'] : ['filename', 'lineno', 'function', 'library_frame', 'abs_path'] t.deepEqual(Object.keys(frame), expectedKeys, 'frame should have expected properties') diff --git a/test/_is_fastify_incompat.js b/test/_is_fastify_incompat.js index 7c34298b4b..36d96393c2 100644 --- a/test/_is_fastify_incompat.js +++ b/test/_is_fastify_incompat.js @@ -6,7 +6,7 @@ 'use strict' -var semver = require('semver') +const semver = require('semver') /** * Return whether the current 'fastify' version is incompatible with the diff --git a/test/_is_hapi_incompat.js b/test/_is_hapi_incompat.js index 0d1d3168b5..5354b1e5e4 100644 --- a/test/_is_hapi_incompat.js +++ b/test/_is_hapi_incompat.js @@ -6,13 +6,13 @@ 'use strict' -var semver = require('semver') +const semver = require('semver') // 'hapi' and '@hapi/hapi' versions have some challenges with compat with // various versions of node. This method tells you if the current versions // are incompatible. function isHapiIncompat (moduleName) { - var hapiVersion = require(`${moduleName}/package.json`).version + const hapiVersion = require(`${moduleName}/package.json`).version // hapi 17+ requires Node.js 8.9.0 or higher if (semver.lt(process.version, '8.9.0') && semver.gte(hapiVersion, '17.0.0')) { @@ -39,7 +39,7 @@ function isHapiIncompat (moduleName) { // https://github.com/nodejs/node/issues/20516 // // NOTE: Do not use semver.satisfies, as it does not match prereleases - var parsed = semver.parse(process.version) + const parsed = semver.parse(process.version) if (parsed.major === 10 && parsed.minor >= 0 && parsed.minor < 8) { return true } diff --git a/test/_is_mongodb_incompat.js b/test/_is_mongodb_incompat.js index cb351be82b..945e5f1fd2 100644 --- a/test/_is_mongodb_incompat.js +++ b/test/_is_mongodb_incompat.js @@ -6,7 +6,7 @@ 'use strict' -var semver = require('semver') +const semver = require('semver') /** * Return whether the current 'mongodb' version is incompatible with the diff --git a/test/_is_restify_incompat.js b/test/_is_restify_incompat.js index 2f100b2fdf..7fd260bde8 100644 --- a/test/_is_restify_incompat.js +++ b/test/_is_restify_incompat.js @@ -6,7 +6,7 @@ 'use strict' -var semver = require('semver') +const semver = require('semver') /** * Return whether the current 'restify' version is incompatible with the diff --git a/test/_is_undici_incompat.js b/test/_is_undici_incompat.js index 5c444b4a99..0e37aad57e 100644 --- a/test/_is_undici_incompat.js +++ b/test/_is_undici_incompat.js @@ -6,7 +6,7 @@ 'use strict' -var semver = require('semver') +const semver = require('semver') /** * Return whether the current 'undici' version is incompatible with the diff --git a/test/_mock_apm_server.js b/test/_mock_apm_server.js index 353c970c3d..9ecbe75b16 100644 --- a/test/_mock_apm_server.js +++ b/test/_mock_apm_server.js @@ -46,8 +46,8 @@ class MockAPMServer { } _onRequest (req, res) { - var parsedUrl = new URL(req.url, this.serverUrl) - var instream = req + const parsedUrl = new URL(req.url, this.serverUrl) + let instream = req if (req.headers['content-encoding'] === 'gzip') { instream = req.pipe(zlib.createGunzip()) } else { diff --git a/test/_utils.js b/test/_utils.js index 99aaa5184b..90b594a1dc 100644 --- a/test/_utils.js +++ b/test/_utils.js @@ -15,10 +15,10 @@ const moduleDetailsFromPath = require('module-details-from-path') // Lookup the property "str" (given in dot-notation) in the object "obj". // If the property isn't found, then `undefined` is returned. function dottedLookup (obj, str) { - var o = obj - var fields = str.split('.') - for (var i = 0; i < fields.length; i++) { - var field = fields[i] + let o = obj + const fields = str.split('.') + for (let i = 0; i < fields.length; i++) { + const field = fields[i] if (!Object.prototype.hasOwnProperty.call(o, field)) { return undefined } diff --git a/test/activation-method/activation-method.test.js b/test/activation-method/activation-method.test.js index 675cbf627a..4560af0b6c 100644 --- a/test/activation-method/activation-method.test.js +++ b/test/activation-method/activation-method.test.js @@ -44,7 +44,7 @@ tape.test(`setup: npm install (in ${fixturesDir})`, { skip: haveNodeModules }, t tape.test('metadata.system.agent.activation_method fixtures', function (suite) { // Note: We do not test the "aws-lambda-layer" case, because this would // require simulating an agent install to the special path used in that case. - var cases = [ + const cases = [ { script: 'require1.js', expectedMethod: 'require' diff --git a/test/agent.test.js b/test/agent.test.js index 458b68311a..a24f4977b1 100644 --- a/test/agent.test.js +++ b/test/agent.test.js @@ -12,11 +12,11 @@ // we do not need to start the agent at the top of file. Instead, tests create // separate instances of the Agent. -var http = require('http') -var path = require('path') -var os = require('os') +const http = require('http') +const path = require('path') +const os = require('os') -var test = require('tape') +const test = require('tape') const Agent = require('../lib/agent') const { @@ -28,7 +28,7 @@ const { const { findObjInArray } = require('./_utils') const { MockAPMServer } = require('./_mock_apm_server') const { NoopApmClient } = require('../lib/apm-client/noop-apm-client') -var packageJson = require('../package.json') +const packageJson = require('../package.json') // Options to pass to `agent.start()` to turn off some default agent behavior // that is unhelpful for these tests. @@ -170,7 +170,7 @@ test('#startTransaction()', function (t) { t.test('name, type, subtype and action', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - var trans = agent.startTransaction('foo', 'type', 'subtype', 'action') + const trans = agent.startTransaction('foo', 'type', 'subtype', 'action') t.strictEqual(trans.name, 'foo') t.strictEqual(trans.type, 'type') t.strictEqual(trans.subtype, 'subtype') @@ -181,10 +181,10 @@ test('#startTransaction()', function (t) { t.test('options.startTime', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - var startTime = Date.now() - 1000 - var trans = agent.startTransaction('foo', 'bar', { startTime }) + const startTime = Date.now() - 1000 + const trans = agent.startTransaction('foo', 'bar', { startTime }) trans.end() - var duration = trans.duration() + const duration = trans.duration() t.ok(duration > 990, `duration should be circa more than 1s (was: ${duration})`) // we've seen 998.752 in the wild t.ok(duration < 1100, `duration should be less than 1.1s (was: ${duration})`) agent.destroy() @@ -193,8 +193,8 @@ test('#startTransaction()', function (t) { t.test('options.childOf', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - var childOf = '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01' - var trans = agent.startTransaction('foo', 'bar', { childOf }) + const childOf = '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01' + const trans = agent.startTransaction('foo', 'bar', { childOf }) t.strictEqual(trans._context.traceparent.version, '00') t.strictEqual(trans._context.traceparent.traceId, '4bf92f3577b34da6a3ce929d0e0e4736') t.notEqual(trans._context.traceparent.id, '00f067aa0ba902b7') @@ -217,7 +217,7 @@ test('#endTransaction()', function (t) { t.test('with no result', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - var trans = agent.startTransaction() + const trans = agent.startTransaction() t.strictEqual(trans.ended, false) agent.endTransaction() t.strictEqual(trans.ended, true) @@ -228,7 +228,7 @@ test('#endTransaction()', function (t) { t.test('with explicit result', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - var trans = agent.startTransaction() + const trans = agent.startTransaction() t.strictEqual(trans.ended, false) agent.endTransaction('done') t.strictEqual(trans.ended, true) @@ -239,9 +239,9 @@ test('#endTransaction()', function (t) { t.test('with custom endTime', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - var startTime = Date.now() - 1000 - var endTime = startTime + 2000.123 - var trans = agent.startTransaction('foo', 'bar', { startTime }) + const startTime = Date.now() - 1000 + const endTime = startTime + 2000.123 + const trans = agent.startTransaction('foo', 'bar', { startTime }) agent.endTransaction('done', endTime) t.strictEqual(trans.duration(), 2000.123) agent.destroy() @@ -261,7 +261,7 @@ test('#currentTransaction', function (t) { t.test('with active transaction', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - var trans = agent.startTransaction() + const trans = agent.startTransaction() t.strictEqual(agent.currentTransaction, trans) agent.endTransaction() agent.destroy() @@ -279,8 +279,8 @@ test('#currentSpan', function (t) { t.test('with binding span', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - var trans = agent.startTransaction() - var span = agent.startSpan() + const trans = agent.startTransaction() + const span = agent.startSpan() t.strictEqual(agent.currentSpan, span) span.end() trans.end() @@ -290,8 +290,8 @@ test('#currentSpan', function (t) { t.test('with active span', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - var trans = agent.startTransaction() - var span = agent.startSpan() + const trans = agent.startTransaction() + const span = agent.startSpan() process.nextTick(() => { t.strictEqual(agent.currentSpan, span) span.end() @@ -314,7 +314,7 @@ test('#currentTraceparent', function (t) { t.test('with active transaction', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - var trans = agent.startTransaction() + const trans = agent.startTransaction() t.strictEqual(agent.currentTraceparent, trans.traceparent) agent.endTransaction() agent.destroy() @@ -324,7 +324,7 @@ test('#currentTraceparent', function (t) { t.test('with active span', function (t) { const agent = new Agent().start(agentOptsNoopTransport) agent.startTransaction() - var span = agent.startSpan() + const span = agent.startSpan() t.strictEqual(agent.currentTraceparent, span.traceparent) span.end() agent.endTransaction() @@ -346,7 +346,7 @@ test('#currentTraceIds', function (t) { t.test('with active transaction', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - var trans = agent.startTransaction() + const trans = agent.startTransaction() t.deepLooseEqual(agent.currentTraceIds, { 'trace.id': trans.traceId, 'transaction.id': trans.id @@ -360,7 +360,7 @@ test('#currentTraceIds', function (t) { t.test('with active span', function (t) { const agent = new Agent().start(agentOptsNoopTransport) agent.startTransaction() - var span = agent.startSpan() + const span = agent.startSpan() t.deepLooseEqual(agent.currentTraceIds, { 'trace.id': span.traceId, 'span.id': span.id @@ -387,7 +387,7 @@ test('#setTransactionName', function (t) { t.test('active transaction', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - var trans = agent.startTransaction() + const trans = agent.startTransaction() agent.setTransactionName('foo') t.strictEqual(trans.name, 'foo') agent.destroy() @@ -408,7 +408,7 @@ test('#startSpan()', function (t) { t.test('active transaction', function (t) { const agent = new Agent().start(agentOptsNoopTransport) agent.startTransaction() - var span = agent.startSpan('span-name', 'type', 'subtype', 'action') + const span = agent.startSpan('span-name', 'type', 'subtype', 'action') t.ok(span, 'should return a span') t.strictEqual(span.name, 'span-name') t.strictEqual(span.type, 'type') @@ -421,7 +421,7 @@ test('#startSpan()', function (t) { t.test('startSpan with no name results in span.name="unnamed"', function (t) { const agent = new Agent().start(agentOptsNoopTransport) agent.startTransaction() - var span = agent.startSpan() + const span = agent.startSpan() t.ok(span, 'should return a span') t.strictEqual(span.name, 'unnamed') t.strictEqual(span.type, 'custom') @@ -434,10 +434,10 @@ test('#startSpan()', function (t) { t.test('options.startTime', function (t) { const agent = new Agent().start(agentOptsNoopTransport) agent.startTransaction() - var startTime = Date.now() - 1000 - var span = agent.startSpan('span-with-startTime', null, { startTime }) + const startTime = Date.now() - 1000 + const span = agent.startSpan('span-with-startTime', null, { startTime }) span.end() - var duration = span.duration() + const duration = span.duration() t.ok(duration > 990, `duration should be circa more than 1s (was: ${duration})`) // we've seen 998.752 in the wild t.ok(duration < 1100, `duration should be less than 1.1s (was: ${duration})`) agent.destroy() @@ -447,8 +447,8 @@ test('#startSpan()', function (t) { t.test('options.childOf', function (t) { const agent = new Agent().start(agentOptsNoopTransport) agent.startTransaction() - var childOf = '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01' - var span = agent.startSpan(null, null, { childOf }) + const childOf = '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01' + const span = agent.startSpan(null, null, { childOf }) t.strictEqual(span._context.traceparent.version, '00') t.strictEqual(span._context.traceparent.traceId, '4bf92f3577b34da6a3ce929d0e0e4736') t.notEqual(span._context.traceparent.id, '00f067aa0ba902b7') @@ -472,7 +472,7 @@ test('#setUserContext()', function (t) { t.test('active transaction', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - var trans = agent.startTransaction() + const trans = agent.startTransaction() t.strictEqual(agent.setUserContext({ foo: 1 }), true) t.deepEqual(trans._user, { foo: 1 }) agent.destroy() @@ -492,7 +492,7 @@ test('#setCustomContext()', function (t) { t.test('active transaction', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - var trans = agent.startTransaction() + const trans = agent.startTransaction() t.strictEqual(agent.setCustomContext({ foo: 1 }), true) t.deepEqual(trans._custom, { foo: 1 }) agent.destroy() @@ -586,7 +586,7 @@ test('#setLabel()', function (t) { t.test('active transaction', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - var trans = agent.startTransaction() + const trans = agent.startTransaction() t.strictEqual(agent.setLabel('foo', 1), true) t.deepEqual(trans._labels, { foo: '1' }) agent.destroy() @@ -595,7 +595,7 @@ test('#setLabel()', function (t) { t.test('active transaction without label stringification', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - var trans = agent.startTransaction() + const trans = agent.startTransaction() t.strictEqual(agent.setLabel('positive', 1, false), true) t.strictEqual(agent.setLabel('negative', -10, false), true) t.strictEqual(agent.setLabel('boolean-true', true, false), true) @@ -625,7 +625,7 @@ test('#addLabels()', function (t) { t.test('active transaction', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - var trans = agent.startTransaction() + const trans = agent.startTransaction() t.strictEqual(agent.addLabels({ foo: 1, bar: 2 }), true) t.strictEqual(agent.addLabels({ foo: 3 }), true) t.deepEqual(trans._labels, { foo: '3', bar: '2' }) @@ -635,7 +635,7 @@ test('#addLabels()', function (t) { t.test('active transaction without label stringification', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - var trans = agent.startTransaction() + const trans = agent.startTransaction() t.strictEqual(agent.addLabels({ foo: 1, bar: true }, false), true) t.deepEqual(trans._labels, { foo: 1, bar: true }) agent.destroy() @@ -1073,7 +1073,7 @@ test('#flush()', function (t) { { serverUrl } )) const t0 = agent.startTransaction('t0') - for (var i = 0; i < 10; i++) { + for (let i = 0; i < 10; i++) { agent.startSpan('s').end() } t0.end() @@ -1081,7 +1081,7 @@ test('#flush()', function (t) { t.error(err, 'no error passed to agent.flush callback') t.equal(apmServer.events.length, 12, 'apmServer got 12 events') t.equal(apmServer.events[1].transaction.name, 't0', 'event[1] is transaction t0') - for (var i = 2; i < 12; i++) { + for (let i = 2; i < 12; i++) { t.equal(apmServer.events[i].span.name, 's', `event[${i}] is span s`) } @@ -1335,7 +1335,7 @@ test('#captureError()', function (t) { t.test('should not fail on a non string err.message', function (t) { const agent = new Agent().start(ceAgentOpts) - var err = new Error() + const err = new Error() err.message = { foo: 'bar' } agent.captureError(err, function () { t.equal(apmServer.events.length, 2, 'APM server got 2 events') @@ -1863,7 +1863,7 @@ test('#handleUncaughtExceptions()', function (t) { t.test('should not add more than one listener for the uncaughtException event', function (t) { const agent = new Agent().start(agentOptsNoopTransport) agent.handleUncaughtExceptions() - var before = process._events.uncaughtException.length + const before = process._events.uncaughtException.length agent.handleUncaughtExceptions() t.strictEqual(process._events.uncaughtException.length, before) @@ -1951,7 +1951,7 @@ test('patches', function (t) { agent.clearPatches('express') agent.start(agentOptsNoopTransport) - var replacement = { + const replacement = { foo: 'bar' } diff --git a/test/apm-client/http-apm-client.test.js b/test/apm-client/http-apm-client.test.js index d34ad1fb8e..e30f343127 100644 --- a/test/apm-client/http-apm-client.test.js +++ b/test/apm-client/http-apm-client.test.js @@ -8,7 +8,7 @@ const test = require('tape') -var apmVersion = require('../../package').version +const apmVersion = require('../../package').version const { userAgentFromConf } = require('../../lib/apm-client/http-apm-client') diff --git a/test/benchmarks/001-transaction-and-span-no-stack-trace.js b/test/benchmarks/001-transaction-and-span-no-stack-trace.js index e3ba291390..fa7e32d508 100644 --- a/test/benchmarks/001-transaction-and-span-no-stack-trace.js +++ b/test/benchmarks/001-transaction-and-span-no-stack-trace.js @@ -15,7 +15,7 @@ bench('transaction-and-span-no-stack-trace', { spanStackTraceMinDuration: -1 }, setup () { - var agent = this.benchmark.agent + const agent = this.benchmark.agent }, fn (deferred) { if (agent) agent.startTransaction() diff --git a/test/benchmarks/002-transaction-and-span-overhead-realistic-size.js b/test/benchmarks/002-transaction-and-span-overhead-realistic-size.js index 37721cd475..4f6d9aa44d 100644 --- a/test/benchmarks/002-transaction-and-span-overhead-realistic-size.js +++ b/test/benchmarks/002-transaction-and-span-overhead-realistic-size.js @@ -17,14 +17,14 @@ const bench = require('./utils/bench') bench('transaction-and-span-overhead-realistic-size', { setup () { - var agent = this.benchmark.agent - var callstack = this.benchmark.callstack + const agent = this.benchmark.agent + const callstack = this.benchmark.callstack // To avoid randomness, but still generate what appears to be natural random // call stacks, number of spans etc, use a pre-defined set of numbers - var numbers = [2, 5, 10, 1, 2, 21, 2, 5, 6, 9, 1, 11, 9, 8, 12] - var numbersSpanIndex = 5 - var numbersStackLevelIndex = 0 + const numbers = [2, 5, 10, 1, 2, 21, 2, 5, 6, 9, 1, 11, 9, 8, 12] + const numbersSpanIndex = 5 + const numbersStackLevelIndex = 0 function addSpan (amount, cb) { setImmediate(() => { diff --git a/test/benchmarks/003-transaction-and-span-with-stack-trace.js b/test/benchmarks/003-transaction-and-span-with-stack-trace.js index 67a828000b..10065d5712 100644 --- a/test/benchmarks/003-transaction-and-span-with-stack-trace.js +++ b/test/benchmarks/003-transaction-and-span-with-stack-trace.js @@ -16,7 +16,7 @@ bench('transaction-and-span-with-stack-trace', { spanFramesMinDuration: '-1ms' }, setup () { - var agent = this.benchmark.agent + const agent = this.benchmark.agent }, fn (deferred) { if (agent) agent.startTransaction() diff --git a/test/benchmarks/004-transaction.js b/test/benchmarks/004-transaction.js index 35aba5df61..1a5a077985 100644 --- a/test/benchmarks/004-transaction.js +++ b/test/benchmarks/004-transaction.js @@ -12,7 +12,7 @@ const bench = require('./utils/bench') bench('transaction', { setup () { - var agent = this.benchmark.agent + const agent = this.benchmark.agent }, fn (deferred) { if (agent) agent.startTransaction() diff --git a/test/benchmarks/005-transaction-reading-file.js b/test/benchmarks/005-transaction-reading-file.js index 20864216f4..c8fb5829d0 100644 --- a/test/benchmarks/005-transaction-reading-file.js +++ b/test/benchmarks/005-transaction-reading-file.js @@ -12,9 +12,9 @@ const bench = require('./utils/bench') bench('transaction-reading-file', { setup () { - var agent = this.benchmark.agent - var fs = this.benchmark.fs - var filename = this.benchmark.testFile + const agent = this.benchmark.agent + const fs = this.benchmark.fs + const filename = this.benchmark.testFile }, fn (deferred) { if (agent) agent.startTransaction() diff --git a/test/benchmarks/006-transaction-and-span-overhead-realistic-size-with-stack-trace.js b/test/benchmarks/006-transaction-and-span-overhead-realistic-size-with-stack-trace.js index 86c216eacc..36fc820a03 100644 --- a/test/benchmarks/006-transaction-and-span-overhead-realistic-size-with-stack-trace.js +++ b/test/benchmarks/006-transaction-and-span-overhead-realistic-size-with-stack-trace.js @@ -22,14 +22,14 @@ bench('transaction-and-span-overhead-realistic-size-with-stack-trace', { spanStackTraceMinDuration: 0 // ensure span stacktrace collection }, setup () { - var agent = this.benchmark.agent - var callstack = this.benchmark.callstack + const agent = this.benchmark.agent + const callstack = this.benchmark.callstack // To avoid randomness, but still generate what appears to be natural random // call stacks, number of spans etc, use a pre-defined set of numbers - var numbers = [2, 5, 10, 1, 2, 21, 2, 5, 6, 9, 1, 11, 9, 8, 12] - var numbersSpanIndex = 5 - var numbersStackLevelIndex = 0 + const numbers = [2, 5, 10, 1, 2, 21, 2, 5, 6, 9, 1, 11, 9, 8, 12] + const numbersSpanIndex = 5 + const numbersStackLevelIndex = 0 function addSpan (amount, cb) { setImmediate(() => { diff --git a/test/config.test.js b/test/config.test.js index 4cc0a5625e..e641d0408a 100644 --- a/test/config.test.js +++ b/test/config.test.js @@ -6,18 +6,18 @@ 'use strict' -var cp = require('child_process') -var fs = require('fs') -var IncomingMessage = require('http').IncomingMessage -var os = require('os') -var path = require('path') -var util = require('util') - -var isRegExp = require('core-util-is').isRegExp -var mkdirp = require('mkdirp') -var rimraf = require('rimraf') -var semver = require('semver') -var test = require('tape') +const cp = require('child_process') +const fs = require('fs') +const IncomingMessage = require('http').IncomingMessage +const os = require('os') +const path = require('path') +const util = require('util') + +const isRegExp = require('core-util-is').isRegExp +const mkdirp = require('mkdirp') +const rimraf = require('rimraf') +const semver = require('semver') +const test = require('tape') const Agent = require('../lib/agent') const { MockAPMServer } = require('./_mock_apm_server') @@ -33,10 +33,10 @@ const { } = require('../lib/config/schema') const config = require('../lib/config/config') -var Instrumentation = require('../lib/instrumentation') -var apmVersion = require('../package').version -var apmName = require('../package').name -var isHapiIncompat = require('./_is_hapi_incompat') +const Instrumentation = require('../lib/instrumentation') +const apmVersion = require('../package').version +const apmName = require('../package').name +const isHapiIncompat = require('./_is_hapi_incompat') const isMongodbIncompat = require('./_is_mongodb_incompat') const isFastifyIncompat = require('./_is_fastify_incompat') @@ -102,7 +102,7 @@ function assertEncodedError (t, error, result, trans, parent) { // ---- tests -var optionFixtures = [ +const optionFixtures = [ ['abortedErrorThreshold', 'ABORTED_ERROR_THRESHOLD', 25], ['active', 'ACTIVE', true], ['apiKey', 'API_KEY'], @@ -157,8 +157,8 @@ var optionFixtures = [ ['verifyServerCert', 'VERIFY_SERVER_CERT', true] ] -var falsyValues = [false, 'false'] -var truthyValues = [true, 'true'] +const falsyValues = [false, 'false'] +const truthyValues = [true, 'true'] optionFixtures.forEach(function (fixture) { if (fixture[1]) { @@ -187,8 +187,8 @@ optionFixtures.forEach(function (fixture) { var existingValue = process.env[envName] test(`should be configurable by environment variable ${envName}`, function (t) { - var agent = new Agent() - var value + const agent = new Agent() + let value switch (type) { case 'bool': @@ -251,9 +251,9 @@ optionFixtures.forEach(function (fixture) { }) test(`should overwrite option property ${fixture[0]} by ${envName}`, function (t) { - var agent = new Agent() - var opts = {} - var value1, value2 + const agent = new Agent() + const opts = {} + let value1, value2 switch (type) { case 'bool': @@ -326,12 +326,12 @@ optionFixtures.forEach(function (fixture) { if (existingValue) { delete process.env[envName] } - var opts = Object.assign({}, agentOptsNoopTransport) + const opts = Object.assign({}, agentOptsNoopTransport) if (fixture[0] in opts) { delete opts[fixture[0]] } - var agent = new Agent().start(opts) + const agent = new Agent().start(opts) switch (type) { case 'array': @@ -353,7 +353,7 @@ optionFixtures.forEach(function (fixture) { falsyValues.forEach(function (val) { test('should be disabled by environment variable ELASTIC_APM_ACTIVE set to: ' + util.inspect(val), function (t) { - var agent = new Agent() + const agent = new Agent() process.env.ELASTIC_APM_ACTIVE = val agent.start(Object.assign({}, agentOptsNoopTransport, { serviceName: 'foo', secretToken: 'baz' })) t.strictEqual(agent._conf.active, false) @@ -365,7 +365,7 @@ falsyValues.forEach(function (val) { truthyValues.forEach(function (val) { test('should be enabled by environment variable ELASTIC_APM_ACTIVE set to: ' + util.inspect(val), function (t) { - var agent = new Agent() + const agent = new Agent() process.env.ELASTIC_APM_ACTIVE = val agent.start(Object.assign({}, agentOptsNoopTransport, { serviceName: 'foo', secretToken: 'baz' })) t.strictEqual(agent._conf.active, true) @@ -376,8 +376,8 @@ truthyValues.forEach(function (val) { }) test('should log invalid booleans', function (t) { - var agent = new Agent() - var logger = new MockLogger() + const agent = new Agent() + const logger = new MockLogger() agent.start(Object.assign( {}, @@ -390,10 +390,10 @@ test('should log invalid booleans', function (t) { } )) - var warning = findObjInArray(logger.calls, 'type', 'warn') + const warning = findObjInArray(logger.calls, 'type', 'warn') t.strictEqual(warning.message, 'unrecognized boolean value "nope" for "active"') - var debug = findObjInArray(logger.calls, 'type', 'debug') + const debug = findObjInArray(logger.calls, 'type', 'debug') t.strictEqual(debug.message, 'Elastic APM agent disabled (`active` is false)') agent.destroy() @@ -401,8 +401,8 @@ test('should log invalid booleans', function (t) { }) test('it should log deprecated booleans', function (t) { - var agent = new Agent() - var logger = new MockLogger() + const agent = new Agent() + const logger = new MockLogger() agent.start(Object.assign( {}, @@ -416,21 +416,21 @@ test('it should log deprecated booleans', function (t) { } )) - var warning = findObjInArray(logger.calls, 'type', 'warn') + const warning = findObjInArray(logger.calls, 'type', 'warn') t.strictEqual(warning.message, 'the `filterHttpHeaders` config option is deprecated') agent.destroy() t.end() }) -var MINUS_ONE_EQUAL_INFINITY = [ +const MINUS_ONE_EQUAL_INFINITY = [ 'transactionMaxSpans' ] MINUS_ONE_EQUAL_INFINITY.forEach(function (key) { test(key + ' should be Infinity if set to -1', function (t) { - var agent = new Agent() - var opts = {} + const agent = new Agent() + const opts = {} opts[key] = -1 agent.start(Object.assign({}, agentOptsNoopTransport, opts)) t.strictEqual(agent._conf[key], Infinity) @@ -439,15 +439,15 @@ MINUS_ONE_EQUAL_INFINITY.forEach(function (key) { }) }) -var bytesValues = [ +const bytesValues = [ 'apiRequestSize', 'errorMessageMaxLength' ] bytesValues.forEach(function (key) { test(key + ' should be converted to a number', function (t) { - var agent = new Agent() - var opts = {} + const agent = new Agent() + const opts = {} opts[key] = '1mb' agent.start(Object.assign({}, agentOptsNoopTransport, opts)) t.strictEqual(agent._conf[key], 1024 * 1024) @@ -479,8 +479,8 @@ DURATION_OPTS.forEach(function (optSpec) { if (!optSpec.allowNegative) { test(key + ' should guard against a negative time', function (t) { - var agent = new Agent() - var logger = new MockLogger() + const agent = new Agent() + const logger = new MockLogger() agent.start(Object.assign( {}, agentOptsNoopTransport, @@ -506,8 +506,8 @@ DURATION_OPTS.forEach(function (optSpec) { } test(key + ' should guard against a bogus non-time', function (t) { - var agent = new Agent() - var logger = new MockLogger() + const agent = new Agent() + const logger = new MockLogger() agent.start(Object.assign( {}, agentOptsNoopTransport, @@ -532,8 +532,8 @@ DURATION_OPTS.forEach(function (optSpec) { }) test(key + ' should convert minutes to seconds', function (t) { - var agent = new Agent() - var opts = {} + const agent = new Agent() + const opts = {} opts[key] = '1m' agent.start(Object.assign({}, agentOptsNoopTransport, opts)) t.strictEqual(agent._conf[key], 60) @@ -542,8 +542,8 @@ DURATION_OPTS.forEach(function (optSpec) { }) test(key + ' should convert milliseconds to seconds', function (t) { - var agent = new Agent() - var opts = {} + const agent = new Agent() + const opts = {} opts[key] = '2000ms' agent.start(Object.assign({}, agentOptsNoopTransport, opts)) t.strictEqual(agent._conf[key], 2) @@ -552,8 +552,8 @@ DURATION_OPTS.forEach(function (optSpec) { }) test(key + ' should parse seconds', function (t) { - var agent = new Agent() - var opts = {} + const agent = new Agent() + const opts = {} opts[key] = '5s' agent.start(Object.assign({}, agentOptsNoopTransport, opts)) t.strictEqual(agent._conf[key], 5) @@ -562,11 +562,11 @@ DURATION_OPTS.forEach(function (optSpec) { }) test(key + ' should support bare numbers', function (t) { - var agent = new Agent() - var opts = {} + const agent = new Agent() + const opts = {} opts[key] = 10 agent.start(Object.assign({}, agentOptsNoopTransport, opts)) - var expectedVal + let expectedVal switch (optSpec.defaultUnit) { case 's': expectedVal = 10 @@ -583,15 +583,15 @@ DURATION_OPTS.forEach(function (optSpec) { }) }) -var keyValuePairValues = [ +const keyValuePairValues = [ 'addPatch', 'globalLabels' ] keyValuePairValues.forEach(function (key) { - var string = 'foo=bar,baz=buz' - var object = { foo: 'bar', baz: 'buz' } - var pairs = [ + const string = 'foo=bar,baz=buz' + const object = { foo: 'bar', baz: 'buz' } + const pairs = [ [ 'foo', 'bar' @@ -603,8 +603,8 @@ keyValuePairValues.forEach(function (key) { ] test(key + ' should support string form', function (t) { - var agent = new Agent() - var opts = {} + const agent = new Agent() + const opts = {} opts[key] = string agent.start(Object.assign({}, agentOptsNoopTransport, opts)) t.deepEqual(agent._conf[key], pairs) @@ -613,8 +613,8 @@ keyValuePairValues.forEach(function (key) { }) test(key + ' should support object form', function (t) { - var agent = new Agent() - var opts = {} + const agent = new Agent() + const opts = {} opts[key] = object agent.start(Object.assign({}, agentOptsNoopTransport, opts)) t.deepEqual(agent._conf[key], pairs) @@ -623,8 +623,8 @@ keyValuePairValues.forEach(function (key) { }) test(key + ' should support pair form', function (t) { - var agent = new Agent() - var opts = {} + const agent = new Agent() + const opts = {} opts[key] = pairs agent.start(Object.assign({}, agentOptsNoopTransport, opts)) t.deepEqual(agent._conf[key], pairs) @@ -633,7 +633,7 @@ keyValuePairValues.forEach(function (key) { }) }) -var noPrefixValues = [ +const noPrefixValues = [ ['kubernetesNodeName', 'KUBERNETES_NODE_NAME'], ['kubernetesNamespace', 'KUBERNETES_NAMESPACE'], ['kubernetesPodName', 'KUBERNETES_POD_NAME'], @@ -643,7 +643,7 @@ var noPrefixValues = [ noPrefixValues.forEach(function (pair) { const [key, envVar] = pair test(`maps ${envVar} to ${key}`, (t) => { - var agent = new Agent() + const agent = new Agent() process.env[envVar] = 'test' agent.start(agentOptsNoopTransport) delete process.env[envVar] @@ -654,8 +654,8 @@ noPrefixValues.forEach(function (pair) { }) test('should overwrite option property active by ELASTIC_APM_ACTIVE', function (t) { - var agent = new Agent() - var opts = { serviceName: 'foo', secretToken: 'baz', active: true } + const agent = new Agent() + const opts = { serviceName: 'foo', secretToken: 'baz', active: true } process.env.ELASTIC_APM_ACTIVE = 'false' agent.start(Object.assign({}, agentOptsNoopTransport, opts)) t.strictEqual(agent._conf.active, false) @@ -665,7 +665,7 @@ test('should overwrite option property active by ELASTIC_APM_ACTIVE', function ( }) test('should default to empty request ignore arrays', function (t) { - var agent = new Agent() + const agent = new Agent() agent.start(agentOptsNoopTransport) t.strictEqual(agent._conf.ignoreUrlStr.length, 0) t.strictEqual(agent._conf.ignoreUrlRegExp.length, 0) @@ -677,7 +677,7 @@ test('should default to empty request ignore arrays', function (t) { }) test('should separate strings and regexes into their own ignore arrays', function (t) { - var agent = new Agent() + const agent = new Agent() agent.start(Object.assign( {}, agentOptsNoopTransport, @@ -703,7 +703,7 @@ test('should separate strings and regexes into their own ignore arrays', functio }) test('should prepare WildcardMatcher array config vars', function (t) { - var agent = new Agent() + const agent = new Agent() agent.start(Object.assign( {}, agentOptsNoopTransport, @@ -747,7 +747,7 @@ test('invalid serviceName => inactive', function (t) { }) test('valid serviceName => active', function (t) { - var agent = new Agent() + const agent = new Agent() agent.start(Object.assign({}, agentOptsNoopTransport, { serviceName: 'fooBAR0123456789_- ' })) t.strictEqual(agent._conf.active, true) agent.destroy() @@ -901,7 +901,7 @@ test('serviceName/serviceVersion zero-conf: no package.json to find', function ( }) }) -var captureBodyTests = [ +const captureBodyTests = [ { value: 'off', errors: '[REDACTED]', transactions: '[REDACTED]' }, { value: 'transactions', errors: '[REDACTED]', transactions: 'test' }, { value: 'errors', errors: 'test', transactions: '[REDACTED]' }, @@ -921,13 +921,13 @@ captureBodyTests.forEach(function (captureBodyTest) { } )) - var req = new IncomingMessage() + const req = new IncomingMessage() req.socket = { remoteAddress: '127.0.0.1' } req.headers['transfer-encoding'] = 'chunked' req.headers['content-length'] = 4 req.body = 'test' - var trans = agent.startTransaction() + const trans = agent.startTransaction() trans.req = req trans.end() @@ -952,15 +952,15 @@ captureBodyTests.forEach(function (captureBodyTest) { }) }) -var usePathAsTransactionNameTests = [ +const usePathAsTransactionNameTests = [ { value: true, url: '/foo/bar?baz=2', transactionName: 'GET /foo/bar' }, { value: false, url: '/foo/bar?baz=2', transactionName: 'GET unknown route' } ] usePathAsTransactionNameTests.forEach(function (usePathAsTransactionNameTest) { test('usePathAsTransactionName => ' + usePathAsTransactionNameTest.value, function (t) { - var sentTrans - var agent = new Agent() + let sentTrans + const agent = new Agent() agent.start(Object.assign( {}, agentOptsNoopTransport, @@ -986,12 +986,12 @@ usePathAsTransactionNameTests.forEach(function (usePathAsTransactionNameTest) { } )) - var req = new IncomingMessage() + const req = new IncomingMessage() req.socket = { remoteAddress: '127.0.0.1' } req.url = usePathAsTransactionNameTest.url req.method = 'GET' - var trans = agent.startTransaction() + const trans = agent.startTransaction() trans.req = req trans.end() @@ -1007,13 +1007,13 @@ usePathAsTransactionNameTests.forEach(function (usePathAsTransactionNameTest) { }) test('disableInstrumentations', function (t) { - var esVersion = safeGetPackageVersion('@elastic/elasticsearch') + const esVersion = safeGetPackageVersion('@elastic/elasticsearch') // require('apollo-server-core') is a hard crash on nodes < 12.0.0 const apolloServerCoreVersion = require('apollo-server-core/package.json').version - var flattenedModules = Instrumentation.modules.reduce((acc, val) => acc.concat(val), []) - var modules = new Set(flattenedModules) + const flattenedModules = Instrumentation.modules.reduce((acc, val) => acc.concat(val), []) + const modules = new Set(flattenedModules) modules.delete('hapi') // Deprecated, we no longer test this instrumentation. modules.delete('jade') // Deprecated, we no longer test this instrumentation. if (isHapiIncompat('@hapi/hapi')) { @@ -1077,18 +1077,18 @@ test('disableInstrumentations', function (t) { modules.delete('mysql2') function testSlice (t, name, selector) { - var selection = selector(modules) - var selectionSet = new Set(typeof selection === 'string' ? selection.split(',') : selection) + const selection = selector(modules) + const selectionSet = new Set(typeof selection === 'string' ? selection.split(',') : selection) t.test(name + ' -> ' + Array.from(selectionSet).join(','), function (t) { - var agent = new Agent() + const agent = new Agent() agent.start(Object.assign( {}, agentOptsNoopTransport, { disableInstrumentations: selection } )) - var found = new Set() + const found = new Set() agent._instrumentation._patchModule = function (exports, name, version, enabled) { if (!enabled) found.add(name) @@ -1166,12 +1166,12 @@ test('custom transport', function (t) { } const myTransport = new MyTransport() - var agent = new Agent() + const agent = new Agent() agent.start(Object.assign({}, agentOpts, { transport: () => myTransport })) - var error = new Error('error') - var trans = agent.startTransaction('transaction') - var span = agent.startSpan('span') + const error = new Error('error') + const trans = agent.startTransaction('transaction') + const span = agent.startSpan('span') agent.captureError(error) span.end() trans.end() @@ -1210,7 +1210,7 @@ test('addPatch', function (t) { }) test('globalLabels should be received by transport', function (t) { - var globalLabels = { + const globalLabels = { foo: 'bar' } @@ -1264,7 +1264,7 @@ test('instrument: false allows manual instrumentation', function (t) { }) test('parsing of ARRAY and KEY_VALUE opts', function (t) { - var cases = [ + const cases = [ { opts: { transactionIgnoreUrls: ['foo', 'bar'] }, expect: { transactionIgnoreUrls: ['foo', 'bar'] } @@ -1320,13 +1320,13 @@ test('parsing of ARRAY and KEY_VALUE opts', function (t) { ] cases.forEach(function testOneCase ({ opts, env, expect }) { - var origEnv = process.env + const origEnv = process.env try { if (env) { process.env = Object.assign({}, origEnv, env) } - var cfg = config.createConfig(opts) - for (var field in expect) { + const cfg = config.createConfig(opts) + for (const field in expect) { t.deepEqual(cfg[field], expect[field], util.format('opts=%j env=%j -> %j', opts, env, expect)) } @@ -1339,7 +1339,7 @@ test('parsing of ARRAY and KEY_VALUE opts', function (t) { }) test('transactionSampleRate precision', function (t) { - var cases = [ + const cases = [ { opts: { transactionSampleRate: 0 }, expect: { transactionSampleRate: 0 } @@ -1379,13 +1379,13 @@ test('transactionSampleRate precision', function (t) { ] cases.forEach(function testOneCase ({ opts, env, expect }) { - var origEnv = process.env + const origEnv = process.env try { if (env) { process.env = Object.assign({}, origEnv, env) } - var cfg = config.createConfig(opts) - for (var field in expect) { + const cfg = config.createConfig(opts) + for (const field in expect) { t.deepEqual(cfg[field], expect[field], util.format('opts=%j env=%j -> %j', opts, env, expect)) } diff --git a/test/connect.test.js b/test/connect.test.js index 025f62be82..772558ab4a 100644 --- a/test/connect.test.js +++ b/test/connect.test.js @@ -60,8 +60,8 @@ tape.test('apm.middleware.connect()', function (t) { const server = http.createServer(app) server.listen(function () { - var port = server.address().port - var baseUrl = 'http://localhost:' + port + const port = server.address().port + const baseUrl = 'http://localhost:' + port t.comment('test server url: ' + baseUrl) http.get(baseUrl + '/error', function () { diff --git a/test/errors.test.js b/test/errors.test.js index 05f7c4201a..0ca9a53900 100644 --- a/test/errors.test.js +++ b/test/errors.test.js @@ -247,7 +247,7 @@ tape.test('#createAPMError({ logMessage: ... })', function (suite) { }) tape.test('#_moduleNameFromFrames()', function (suite) { - var cases = [ + const cases = [ { name: 'unnamespaced package', frames: [ @@ -355,7 +355,7 @@ tape.test('#_moduleNameFromFrames()', function (suite) { }) tape.test('#attributesFromErr()', function (suite) { - var cases = [ + const cases = [ // 'err' is an Error instance, or a function that returns one. { name: 'no attrs', diff --git a/test/fixtures/do-not-trace-self.js b/test/fixtures/do-not-trace-self.js index 9a30ffbd5c..ea5b7b3be7 100644 --- a/test/fixtures/do-not-trace-self.js +++ b/test/fixtures/do-not-trace-self.js @@ -7,7 +7,7 @@ // A small APM-using script used to test that the APM agent's own HTTP // communication with APM server is not traced. -var apm = require('../../').start({ // elastic-apm-node +const apm = require('../../').start({ // elastic-apm-node serviceName: 'test-do-not-trace-self', metricsInterval: 0, apmServerVersion: '8.0.0', diff --git a/test/http-request.test.js b/test/http-request.test.js index 410fd1deaa..bfbbfe6b35 100644 --- a/test/http-request.test.js +++ b/test/http-request.test.js @@ -6,7 +6,7 @@ 'use strict' -var test = require('tape') +const test = require('tape') const http = require('http') const { httpRequest } = require('../lib/http-request') diff --git a/test/instrumentation/_async-await.js b/test/instrumentation/_async-await.js index 544adef3d3..466099bd1a 100644 --- a/test/instrumentation/_async-await.js +++ b/test/instrumentation/_async-await.js @@ -10,7 +10,7 @@ exports.promise = promise exports.nonPromise = nonPromise async function promise (delay) { - var res = await promise2(delay) + const res = await promise2(delay) return res.toUpperCase() } @@ -23,6 +23,6 @@ async function promise2 (delay) { } async function nonPromise () { - var res = await 'success' + const res = await 'success' return res.toUpperCase() } diff --git a/test/instrumentation/_shared-promise-tests.js b/test/instrumentation/_shared-promise-tests.js index 63afb11e23..f786ae025a 100644 --- a/test/instrumentation/_shared-promise-tests.js +++ b/test/instrumentation/_shared-promise-tests.js @@ -10,7 +10,7 @@ module.exports = function (test, Promise, ins) { test('new Promise -> resolve -> then', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() new Promise(function (resolve) { resolve('foo') }).then(function (data) { @@ -20,14 +20,14 @@ module.exports = function (test, Promise, ins) { }) }) - var catchNames = ['catch'] + const catchNames = ['catch'] // caught is a catch alias and an early ECMAScript standard since abandoned if (Promise.prototype.caught) catchNames.push('caught') catchNames.forEach(function (fnName) { test('new Promise -> reject -> ' + fnName, function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() new Promise(function (resolve, reject) { reject(new Error('foo')) }).then(function () { @@ -42,7 +42,7 @@ module.exports = function (test, Promise, ins) { test('new Promise -> reject -> ' + fnName + ' -> then', function (t) { t.plan(8) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() new Promise(function (resolve, reject) { reject(new Error('foo')) })[fnName](function (err) { @@ -60,7 +60,7 @@ module.exports = function (test, Promise, ins) { test('new Promise -> reject -> then (2nd arg)', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() new Promise(function (resolve, reject) { reject(new Error('foo')) }).then(function () { @@ -75,7 +75,7 @@ module.exports = function (test, Promise, ins) { test('Promise.resolve', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() Promise.resolve('foo') .then(function (data) { t.strictEqual(data, 'foo') @@ -90,7 +90,7 @@ module.exports = function (test, Promise, ins) { test('Promise.reject', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() Promise.reject(new Error('foo')) .then(function () { t.fail('should not resolve') @@ -105,10 +105,10 @@ module.exports = function (test, Promise, ins) { test('Promise.all', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() - var p1 = Promise.resolve(3) - var p2 = 1337 - var p3 = new Promise(function (resolve, reject) { + const trans = ins.startTransaction() + const p1 = Promise.resolve(3) + const p2 = 1337 + const p3 = new Promise(function (resolve, reject) { setTimeout(resolve, 10, 'foo') }) @@ -122,11 +122,11 @@ module.exports = function (test, Promise, ins) { test('Promise.race - 2nd resolve', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() - var p1 = new Promise(function (resolve, reject) { + const trans = ins.startTransaction() + const p1 = new Promise(function (resolve, reject) { setTimeout(resolve, 50, 'one') }) - var p2 = new Promise(function (resolve, reject) { + const p2 = new Promise(function (resolve, reject) { setTimeout(resolve, 10, 'two') }) @@ -140,11 +140,11 @@ module.exports = function (test, Promise, ins) { test('Promise.race - 1st resolve', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() - var p1 = new Promise(function (resolve, reject) { + const trans = ins.startTransaction() + const p1 = new Promise(function (resolve, reject) { setTimeout(resolve, 10, 'one') }) - var p2 = new Promise(function (resolve, reject) { + const p2 = new Promise(function (resolve, reject) { setTimeout(reject, 50, 'two') }) @@ -160,11 +160,11 @@ module.exports = function (test, Promise, ins) { test('Promise.race - 2nd reject', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() - var p1 = new Promise(function (resolve, reject) { + const trans = ins.startTransaction() + const p1 = new Promise(function (resolve, reject) { setTimeout(resolve, 50, 'one') }) - var p2 = new Promise(function (resolve, reject) { + const p2 = new Promise(function (resolve, reject) { setTimeout(reject, 10, 'two') }) @@ -180,7 +180,7 @@ module.exports = function (test, Promise, ins) { test('return new Promise', function (t) { t.plan(12) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() new Promise(function (resolve) { resolve('foo') }).then(function (data) { diff --git a/test/instrumentation/async-await.test.js b/test/instrumentation/async-await.test.js index 2d796a91d3..f5fcc42968 100644 --- a/test/instrumentation/async-await.test.js +++ b/test/instrumentation/async-await.test.js @@ -6,25 +6,25 @@ 'use strict' -var agent = require('../..').start({ +const agent = require('../..').start({ serviceName: 'test', captureExceptions: false }) -var test = require('tape') +const test = require('tape') -var ins = agent._instrumentation +const ins = agent._instrumentation -var _async = require('./_async-await') +const _async = require('./_async-await') test('await promise', function (t) { t.plan(4) - var t1 = ins.startTransaction() + const t1 = ins.startTransaction() _async.promise(100).then(function (result) { t.strictEqual(result, 'SUCCESS') t.strictEqual(ins.currTransaction() && ins.currTransaction().id, t1.id) }) - var t2 = ins.startTransaction() + const t2 = ins.startTransaction() _async.promise(50).then(function (result) { t.strictEqual(result, 'SUCCESS') t.strictEqual(ins.currTransaction() && ins.currTransaction().id, t2.id) @@ -33,14 +33,14 @@ test('await promise', function (t) { test('await non-promise', function (t) { t.plan(7) - var n = 0 - var t1 = ins.startTransaction() + let n = 0 + const t1 = ins.startTransaction() _async.nonPromise().then(function (result) { t.strictEqual(++n, 2) // this should be the first then-callback to execute t.strictEqual(result, 'SUCCESS') t.strictEqual(ins.currTransaction() && ins.currTransaction().id, t1.id) }) - var t2 = ins.startTransaction() + const t2 = ins.startTransaction() _async.nonPromise().then(function (result) { t.strictEqual(++n, 3) // this should be the second then-callback to execute t.strictEqual(result, 'SUCCESS') diff --git a/test/instrumentation/context.test.js b/test/instrumentation/context.test.js index bc06677f5d..da81294dbe 100644 --- a/test/instrumentation/context.test.js +++ b/test/instrumentation/context.test.js @@ -6,8 +6,8 @@ 'use strict' -var test = require('tape') -var { getHTTPDestination, getDBDestination } = require('../../lib/instrumentation/context') +const test = require('tape') +const { getHTTPDestination, getDBDestination } = require('../../lib/instrumentation/context') test('#getHTTPDestination', function (t) { t.test('username and pass', (t) => { diff --git a/test/instrumentation/core-async-apis.test.js b/test/instrumentation/core-async-apis.test.js index e59199f4f8..d17d322f08 100644 --- a/test/instrumentation/core-async-apis.test.js +++ b/test/instrumentation/core-async-apis.test.js @@ -6,19 +6,19 @@ 'use strict' -var agent = require('../..').start({ +const agent = require('../..').start({ serviceName: 'test-core-async-apis', captureExceptions: false }) -var test = require('tape') +const test = require('tape') -var ins = agent._instrumentation +const ins = agent._instrumentation test('setTimeout', function (t) { t.plan(2) twice(function () { - var trans = agent.startTransaction() + const trans = agent.startTransaction() setTimeout(function () { t.strictEqual(ins.currTransaction() && ins.currTransaction().id, trans.id) trans.end() @@ -29,7 +29,7 @@ test('setTimeout', function (t) { test('setInterval', function (t) { t.plan(2) twice(function () { - var trans = agent.startTransaction() + const trans = agent.startTransaction() var timer = setInterval(function () { clearInterval(timer) t.strictEqual(ins.currTransaction() && ins.currTransaction().id, trans.id) @@ -41,7 +41,7 @@ test('setInterval', function (t) { test('setImmediate', function (t) { t.plan(2) twice(function () { - var trans = agent.startTransaction() + const trans = agent.startTransaction() setImmediate(function () { t.strictEqual(ins.currTransaction() && ins.currTransaction().id, trans.id) trans.end() @@ -52,7 +52,7 @@ test('setImmediate', function (t) { test('process.nextTick', function (t) { t.plan(2) twice(function () { - var trans = agent.startTransaction() + const trans = agent.startTransaction() process.nextTick(function () { t.strictEqual(ins.currTransaction() && ins.currTransaction().id, trans.id) trans.end() @@ -63,10 +63,10 @@ test('process.nextTick', function (t) { test('pre-defined, pre-resolved shared promise', function (t) { t.plan(4) - var p = Promise.resolve('success') + const p = Promise.resolve('success') twice(function () { - var trans = agent.startTransaction() + const trans = agent.startTransaction() p.then(function (result) { t.strictEqual(result, 'success') t.strictEqual(ins.currTransaction() && ins.currTransaction().id, trans.id) @@ -79,8 +79,8 @@ test('pre-defined, pre-resolved non-shared promise', function (t) { t.plan(4) twice(function () { - var p = Promise.resolve('success') - var trans = agent.startTransaction() + const p = Promise.resolve('success') + const trans = agent.startTransaction() p.then(function (result) { t.strictEqual(result, 'success') t.strictEqual(ins.currTransaction() && ins.currTransaction().id, trans.id) @@ -92,12 +92,12 @@ test('pre-defined, pre-resolved non-shared promise', function (t) { test('pre-defined, post-resolved promise', function (t) { t.plan(4) twice(function () { - var p = new Promise(function (resolve) { + const p = new Promise(function (resolve) { setTimeout(function () { resolve('success') }, 20) }) - var trans = agent.startTransaction() + const trans = agent.startTransaction() p.then(function (result) { t.strictEqual(result, 'success') t.strictEqual(ins.currTransaction() && ins.currTransaction().id, trans.id) @@ -109,8 +109,8 @@ test('pre-defined, post-resolved promise', function (t) { test('post-defined, post-resolved promise', function (t) { t.plan(4) twice(function () { - var trans = agent.startTransaction() - var p = new Promise(function (resolve) { + const trans = agent.startTransaction() + const p = new Promise(function (resolve) { setTimeout(function () { resolve('success') }, 20) diff --git a/test/instrumentation/fs.test.js b/test/instrumentation/fs.test.js index f808254666..97d25bafdb 100644 --- a/test/instrumentation/fs.test.js +++ b/test/instrumentation/fs.test.js @@ -25,8 +25,8 @@ if (typeof fs.realpath.native === 'function') { // Before https://github.com/elastic/apm-agent-nodejs/issues/2401 this test // would crash with asyncHooks=false tape.test('fs.realpath.native', function (t) { - var trans = apm.startTransaction('t0') - var span = apm.startSpan('s1') + const trans = apm.startTransaction('t0') + const span = apm.startSpan('s1') fs.realpath.native(__filename, function (err, resolvedPath) { t.error(err, 'no error from fs.realpath.native') t.equal(apm.currentSpan, span, 'apm.currentSpan is as expected') diff --git a/test/instrumentation/index.test.js b/test/instrumentation/index.test.js index 10e18864d7..c4d7700f0c 100644 --- a/test/instrumentation/index.test.js +++ b/test/instrumentation/index.test.js @@ -6,7 +6,7 @@ 'use strict' -var agent = require('../..').start({ +const agent = require('../..').start({ serviceName: 'test-instrumentation', breakdownMetrics: false, captureExceptions: false, @@ -16,15 +16,15 @@ var agent = require('../..').start({ spanStackTraceMinDuration: 0 // Always have span stacktraces. }) -var EventEmitter = require('events') -var http = require('http') +const EventEmitter = require('events') +const http = require('http') -var test = require('tape') +const test = require('tape') -var mockClient = require('../_mock_http_client') -var findObjInArray = require('../_utils').findObjInArray +const mockClient = require('../_mock_http_client') +const findObjInArray = require('../_utils').findObjInArray -var origCaptureError = agent.captureError +const origCaptureError = agent.captureError test('basic', function (t) { resetAgent(6, function (data) { @@ -65,16 +65,16 @@ test('basic', function (t) { t.end() }) - var ins = agent._instrumentation + const ins = agent._instrumentation generateTransaction(0, function () { generateTransaction(1) }) function generateTransaction (id, cb) { - var trans = ins.startTransaction('foo' + id, 'bar' + id) + const trans = ins.startTransaction('foo' + id, 'bar' + id) trans.result = 'baz' + id - var span = ins.startSpan('t' + id + '0', 'type') + let span = ins.startSpan('t' + id + '0', 'type') process.nextTick(function () { span.end() @@ -101,11 +101,11 @@ test('same tick', function (t) { } t.end() }) - var ins = agent._instrumentation + const ins = agent._instrumentation - var trans = ins.startTransaction('foo') - var t0 = ins.startSpan('t0') - var t1 = ins.startSpan('t1') + const trans = ins.startTransaction('foo') + const t0 = ins.startSpan('t0') + const t1 = ins.startSpan('t1') t1.end() t0.end() trans.end() @@ -124,13 +124,13 @@ test('serial - no parents', function (t) { } t.end() }) - var ins = agent._instrumentation + const ins = agent._instrumentation - var trans = ins.startTransaction('foo') - var t0 = ins.startSpan('t0') + const trans = ins.startTransaction('foo') + const t0 = ins.startSpan('t0') process.nextTick(function () { t0.end() - var t1 = ins.startSpan('t1') + const t1 = ins.startSpan('t1') process.nextTick(function () { t1.end() trans.end() @@ -151,12 +151,12 @@ test('serial - with parents', function (t) { } t.end() }) - var ins = agent._instrumentation + const ins = agent._instrumentation - var trans = ins.startTransaction('foo') - var t0 = ins.startSpan('t0') + const trans = ins.startTransaction('foo') + const t0 = ins.startSpan('t0') process.nextTick(function () { - var t1 = ins.startSpan('t1') + const t1 = ins.startSpan('t1') process.nextTick(function () { t1.end() t0.end() @@ -178,11 +178,11 @@ test('stack branching - no parents', function (t) { } t.end() }) - var ins = agent._instrumentation + const ins = agent._instrumentation - var trans = ins.startTransaction('foo') - var t0 = ins.startSpan('t0') // 1 - var t1 = ins.startSpan('t1') // 2 + const trans = ins.startTransaction('foo') + const t0 = ins.startSpan('t0') // 1 + const t1 = ins.startSpan('t1') // 2 setTimeout(function () { t0.end() // 3 }, 25) @@ -241,15 +241,15 @@ test('captureError should handle opts.captureAttributes', function (t) { agent.captureError = origCaptureError - var ex0 = new Error('ex0') + const ex0 = new Error('ex0') ex0.theProperty = 'this is the property' agent.captureError(ex0) - var ex1 = new Error('ex1') + const ex1 = new Error('ex1') ex1.theProperty = 'this is the property' agent.captureError(ex1, { captureAttributes: true }) - var ex2 = new Error('ex2') + const ex2 = new Error('ex2') ex2.theProperty = 'this is the property' agent.captureError(ex2, { captureAttributes: false }) }) @@ -281,7 +281,7 @@ test('unsampled request transactions should have the correct result', function ( }) server.listen(function () { - var port = server.address().port + const port = server.address().port http.get('http://localhost:' + port, function (res) { res.resume() }) @@ -294,12 +294,12 @@ test('bind', function (t) { t.strictEqual(data.transactions.length, 1) t.end() }) - var ins = agent._instrumentation + const ins = agent._instrumentation - var trans = ins.startTransaction('foo') + const trans = ins.startTransaction('foo') function fn () { - var t0 = ins.startSpan('t0') + const t0 = ins.startSpan('t0') t.equal(t0, null, 'should not get a span, because there is no current transaction') if (t0) t0.end() trans.end() @@ -317,12 +317,12 @@ test('bind', function (t) { t.strictEqual(data.spans[0].name, 't0') t.end() }) - var ins = agent._instrumentation + const ins = agent._instrumentation - var trans = ins.startTransaction('foo') + const trans = ins.startTransaction('foo') - var fn = ins.bindFunction(function () { - var t0 = ins.startSpan('t0') + const fn = ins.bindFunction(function () { + const t0 = ins.startSpan('t0') t.ok(t0, 'should get a span, because run context with transaction was bound to fn') if (t0) t0.end() trans.end() @@ -338,11 +338,11 @@ test('bind', function (t) { t.strictEqual(data.transactions.length, 1) t.end() }) - var ins = agent._instrumentation - var trans = ins.startTransaction('foo') - var listeners + const ins = agent._instrumentation + const trans = ins.startTransaction('foo') + let listeners - var emitter = new EventEmitter() + const emitter = new EventEmitter() ins.bindEmitter(emitter) function myHandler () { } @@ -369,7 +369,7 @@ test('bind', function (t) { trans.end() }) - var methods = [ + const methods = [ 'on', 'once', 'addListener', @@ -383,15 +383,15 @@ test('bind', function (t) { t.strictEqual(data.transactions.length, 1) t.end() }) - var ins = agent._instrumentation + const ins = agent._instrumentation - var trans = ins.startTransaction('foo') + const trans = ins.startTransaction('foo') - var emitter = new EventEmitter() + const emitter = new EventEmitter() // Explicitly *not* using `bindEmitter` here. emitter[method]('foo', function () { - var s1 = ins.startSpan('s1') + const s1 = ins.startSpan('s1') t.equal(s1, null, 'should *not* get span s1') if (s1) s1.end() trans.end() @@ -413,14 +413,14 @@ test('bind', function (t) { t.end() }) - var ins = agent._instrumentation - var trans = ins.startTransaction('foo') + const ins = agent._instrumentation + const trans = ins.startTransaction('foo') - var emitter = new EventEmitter() + const emitter = new EventEmitter() ins.bindEmitter(emitter) emitter[method]('foo', function () { - var s1 = ins.startSpan('s1') + const s1 = ins.startSpan('s1') if (s1) s1.end() trans.end() }) @@ -471,10 +471,10 @@ test('nested spans', function (t) { t.end() }) - var ins = agent._instrumentation + const ins = agent._instrumentation - var trans = ins.startTransaction('foo') - var count = 0 + const trans = ins.startTransaction('foo') + let count = 0 function done () { s1.end() if (++count === 2) { @@ -482,10 +482,10 @@ test('nested spans', function (t) { } } - var s0 = ins.startSpan('s0') + const s0 = ins.startSpan('s0') process.nextTick(function () { process.nextTick(function () { - var s01 = ins.startSpan('s01') + const s01 = ins.startSpan('s01') process.nextTick(function () { s01.end() done() @@ -496,7 +496,7 @@ test('nested spans', function (t) { var s1 = ins.startSpan('s1') process.nextTick(function () { - var s11 = ins.startSpan('s11') + const s11 = ins.startSpan('s11') process.nextTick(function () { s11.end() done() @@ -506,7 +506,7 @@ test('nested spans', function (t) { // Will adopt the t1 span as its parent, // because no new span has been created. process.nextTick(function () { - var s12 = ins.startSpan('s12') + const s12 = ins.startSpan('s12') process.nextTick(function () { s12.end() done() @@ -541,14 +541,14 @@ test('nested transactions', function (t) { t.end() }) - var ins = agent._instrumentation + const ins = agent._instrumentation - var t0 = ins.startTransaction('t0') - var s0 = ins.startSpan('s0') - var t1 = ins.startTransaction('t1', null, { + const t0 = ins.startTransaction('t0') + const s0 = ins.startSpan('s0') + const t1 = ins.startTransaction('t1', null, { childOf: t0._context.toString() }) - var s1 = ins.startSpan('s1') + const s1 = ins.startSpan('s1') s1.end() t1.end() s0.end() diff --git a/test/instrumentation/modules/@apollo/server.test.js b/test/instrumentation/modules/@apollo/server.test.js index f1f3f11b3a..00c36e404e 100644 --- a/test/instrumentation/modules/@apollo/server.test.js +++ b/test/instrumentation/modules/@apollo/server.test.js @@ -205,8 +205,8 @@ function done (t, query) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 1) - var trans = data.transactions[0] - var span = data.spans[0] + const trans = data.transactions[0] + const span = data.spans[0] t.strictEqual(trans.name, query + ' (/)') t.strictEqual(trans.type, 'graphql') @@ -215,7 +215,7 @@ function done (t, query) { t.strictEqual(span.subtype, 'graphql') t.strictEqual(span.action, 'execute') - var offset = span.timestamp - trans.timestamp + const offset = span.timestamp - trans.timestamp t.ok(offset + span.duration * 1000 < trans.duration * 1000) t.end() diff --git a/test/instrumentation/modules/apollo-server-express.test.js b/test/instrumentation/modules/apollo-server-express.test.js index 1a6da041ea..da12805315 100644 --- a/test/instrumentation/modules/apollo-server-express.test.js +++ b/test/instrumentation/modules/apollo-server-express.test.js @@ -11,7 +11,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -var agent = require('../../..').start({ +const agent = require('../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -20,11 +20,11 @@ var agent = require('../../..').start({ spanStackTraceMinDuration: 0 // Always have span stacktraces. }) -var test = require('tape') +const test = require('tape') -var http = require('http') -var express = require('express') -var querystring = require('querystring') +const http = require('http') +const express = require('express') +const querystring = require('querystring') const semver = require('semver') // require('apollo-server-express') is a hard crash for nodes < 12.0.0 const apolloServerExpressVersion = require('apollo-server-express/package.json').version @@ -33,20 +33,20 @@ if (semver.gte(apolloServerExpressVersion, '3.0.0') && semver.lt(process.version process.exit() } -var ApolloServer = require('apollo-server-express').ApolloServer -var gql = require('apollo-server-express').gql +const ApolloServer = require('apollo-server-express').ApolloServer +const gql = require('apollo-server-express').gql -var mockClient = require('../../_mock_http_client') +const mockClient = require('../../_mock_http_client') test('POST /graphql', function (t) { resetAgent(done(t, 'hello')) - var typeDefs = gql` + const typeDefs = gql` type Query { hello: String } ` - var resolvers = { + const resolvers = { Query: { hello () { t.ok(agent._instrumentation.currTransaction(), 'have active transaction') @@ -54,26 +54,26 @@ test('POST /graphql', function (t) { } } } - var query = '{"query":"{ hello }"}' + const query = '{"query":"{ hello }"}' - var app = express() - var apollo = new ApolloServer({ typeDefs, resolvers, uploads: false }) + const app = express() + const apollo = new ApolloServer({ typeDefs, resolvers, uploads: false }) apollo.start().then(function () { apollo.applyMiddleware({ app }) var server = app.listen(function () { - var port = server.address().port - var opts = { + const port = server.address().port + const opts = { method: 'POST', port: port, path: '/graphql', headers: { 'Content-Type': 'application/json' } } - var req = http.request(opts, function (res) { - var chunks = [] + const req = http.request(opts, function (res) { + const chunks = [] res.on('data', chunks.push.bind(chunks)) res.on('end', function () { server.close() - var result = Buffer.concat(chunks).toString() + const result = Buffer.concat(chunks).toString() t.strictEqual(result, '{"data":{"hello":"Hello world!"}}\n', 'client got the expected response body') agent.flush() @@ -87,12 +87,12 @@ test('POST /graphql', function (t) { test('GET /graphql', function (t) { resetAgent(done(t, 'hello')) - var typeDefs = gql` + const typeDefs = gql` type Query { hello: String } ` - var resolvers = { + const resolvers = { Query: { hello () { t.ok(agent._instrumentation.currTransaction(), 'have active transaction') @@ -100,25 +100,25 @@ test('GET /graphql', function (t) { } } } - var query = querystring.stringify({ query: '{ hello }' }) + const query = querystring.stringify({ query: '{ hello }' }) - var app = express() - var apollo = new ApolloServer({ typeDefs, resolvers, uploads: false }) + const app = express() + const apollo = new ApolloServer({ typeDefs, resolvers, uploads: false }) apollo.start().then(function () { apollo.applyMiddleware({ app }) var server = app.listen(function () { - var port = server.address().port - var opts = { + const port = server.address().port + const opts = { method: 'GET', port: port, path: '/graphql?' + query } - var req = http.request(opts, function (res) { - var chunks = [] + const req = http.request(opts, function (res) { + const chunks = [] res.on('data', chunks.push.bind(chunks)) res.on('end', function () { server.close() - var result = Buffer.concat(chunks).toString() + const result = Buffer.concat(chunks).toString() t.strictEqual(result, '{"data":{"hello":"Hello world!"}}\n', 'client got the expected response body') agent.flush() @@ -132,12 +132,12 @@ test('GET /graphql', function (t) { test('POST /graphql - named query', function (t) { resetAgent(done(t, 'HelloQuery hello')) - var typeDefs = gql` + const typeDefs = gql` type Query { hello: String } ` - var resolvers = { + const resolvers = { Query: { hello () { t.ok(agent._instrumentation.currTransaction(), 'have active transaction') @@ -145,26 +145,26 @@ test('POST /graphql - named query', function (t) { } } } - var query = '{"query":"query HelloQuery { hello }"}' + const query = '{"query":"query HelloQuery { hello }"}' - var app = express() - var apollo = new ApolloServer({ typeDefs, resolvers, uploads: false }) + const app = express() + const apollo = new ApolloServer({ typeDefs, resolvers, uploads: false }) apollo.start().then(function () { apollo.applyMiddleware({ app }) var server = app.listen(function () { - var port = server.address().port - var opts = { + const port = server.address().port + const opts = { method: 'POST', port: port, path: '/graphql', headers: { 'Content-Type': 'application/json' } } - var req = http.request(opts, function (res) { - var chunks = [] + const req = http.request(opts, function (res) { + const chunks = [] res.on('data', chunks.push.bind(chunks)) res.on('end', function () { server.close() - var result = Buffer.concat(chunks).toString() + const result = Buffer.concat(chunks).toString() t.strictEqual(result, '{"data":{"hello":"Hello world!"}}\n') agent.flush() }) @@ -177,13 +177,13 @@ test('POST /graphql - named query', function (t) { test('POST /graphql - sort multiple queries', function (t) { resetAgent(done(t, 'hello, life')) - var typeDefs = gql` + const typeDefs = gql` type Query { hello: String life: Int } ` - var resolvers = { + const resolvers = { Query: { hello () { t.ok(agent._instrumentation.currTransaction(), 'have active transaction') @@ -195,26 +195,26 @@ test('POST /graphql - sort multiple queries', function (t) { } } } - var query = '{"query":"{ life, hello }"}' + const query = '{"query":"{ life, hello }"}' - var app = express() - var apollo = new ApolloServer({ typeDefs, resolvers, uploads: false }) + const app = express() + const apollo = new ApolloServer({ typeDefs, resolvers, uploads: false }) apollo.start().then(function () { apollo.applyMiddleware({ app }) var server = app.listen(function () { - var port = server.address().port - var opts = { + const port = server.address().port + const opts = { method: 'POST', port: port, path: '/graphql', headers: { 'Content-Type': 'application/json' } } - var req = http.request(opts, function (res) { - var chunks = [] + const req = http.request(opts, function (res) { + const chunks = [] res.on('data', chunks.push.bind(chunks)) res.on('end', function () { server.close() - var result = Buffer.concat(chunks).toString() + const result = Buffer.concat(chunks).toString() t.strictEqual(result, '{"data":{"life":42,"hello":"Hello world!"}}\n') agent.flush() }) @@ -227,7 +227,7 @@ test('POST /graphql - sort multiple queries', function (t) { test('POST /graphql - sub-query', function (t) { resetAgent(done(t, 'books')) - var books = [ + const books = [ { title: 'Harry Potter and the Chamber of Secrets', author: 'J.K. Rowling', @@ -239,7 +239,7 @@ test('POST /graphql - sub-query', function (t) { publisher: { name: 'ACME' } } ] - var typeDefs = gql` + const typeDefs = gql` type Publisher { name: String } @@ -252,7 +252,7 @@ test('POST /graphql - sub-query', function (t) { books: [Book] } ` - var resolvers = { + const resolvers = { Query: { books () { t.ok(agent._instrumentation.currTransaction(), 'have active transaction') @@ -260,26 +260,26 @@ test('POST /graphql - sub-query', function (t) { } } } - var query = '{"query":"{ books { title author, publisher { name } } }"}' + const query = '{"query":"{ books { title author, publisher { name } } }"}' - var app = express() - var apollo = new ApolloServer({ typeDefs, resolvers, uploads: false }) + const app = express() + const apollo = new ApolloServer({ typeDefs, resolvers, uploads: false }) apollo.start().then(function () { apollo.applyMiddleware({ app }) var server = app.listen(function () { - var port = server.address().port - var opts = { + const port = server.address().port + const opts = { method: 'POST', port: port, path: '/graphql', headers: { 'Content-Type': 'application/json' } } - var req = http.request(opts, function (res) { - var chunks = [] + const req = http.request(opts, function (res) { + const chunks = [] res.on('data', chunks.push.bind(chunks)) res.on('end', function () { server.close() - var result = Buffer.concat(chunks).toString() + const result = Buffer.concat(chunks).toString() t.strictEqual(result, JSON.stringify({ data: { books } }) + '\n') agent.flush() }) @@ -294,8 +294,8 @@ function done (t, query) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 1) - var trans = data.transactions[0] - var span = data.spans[0] + const trans = data.transactions[0] + const span = data.spans[0] t.strictEqual(trans.name, query + ' (/graphql)') t.strictEqual(trans.type, 'graphql') @@ -304,7 +304,7 @@ function done (t, query) { t.strictEqual(span.subtype, 'graphql') t.strictEqual(span.action, 'execute') - var offset = span.timestamp - trans.timestamp + const offset = span.timestamp - trans.timestamp t.ok(offset + span.duration * 1000 < trans.duration * 1000) t.end() diff --git a/test/instrumentation/modules/aws-sdk/dynamodb.test.js b/test/instrumentation/modules/aws-sdk/dynamodb.test.js index e18905e26e..7875a670cf 100644 --- a/test/instrumentation/modules/aws-sdk/dynamodb.test.js +++ b/test/instrumentation/modules/aws-sdk/dynamodb.test.js @@ -182,7 +182,7 @@ tape.test('AWS DynamoDB: End to End Test', function (test) { endpoint: `http://localhost:${port}` }) agent.startTransaction('myTransaction') - var ddb = new AWS.DynamoDB({ apiVersion: '2012-08-10' }) + const ddb = new AWS.DynamoDB({ apiVersion: '2012-08-10' }) var params = { TableName: 'fixture-table', KeyConditionExpression: 'id = :foo', @@ -230,7 +230,7 @@ tape.test('AWS DynamoDB: End to End Test', function (test) { endpoint: `http://localhost:${port}` }) agent.startTransaction('myTransaction') - var ddb = new AWS.DynamoDB({ apiVersion: '2012-08-10' }) + const ddb = new AWS.DynamoDB({ apiVersion: '2012-08-10' }) ddb.listTables(function (err, data) { t.ok(agent.currentSpan === null, 'no currentSpan in ddb.listTables callback') t.error(err) @@ -260,8 +260,8 @@ tape.test('AWS DynamoDB: End to End Test', function (test) { endpoint: `http://localhost:${port}` }) agent.startTransaction('myTransaction') - var ddb = new AWS.DynamoDB({ apiVersion: '2012-08-10' }) - var params = { + const ddb = new AWS.DynamoDB({ apiVersion: '2012-08-10' }) + const params = { TableName: 'fixture-table', KeyConditionExpression: 'id = :foo', ExpressionAttributeValues: { @@ -292,8 +292,8 @@ tape.test('AWS DynamoDB: End to End Test', function (test) { AWS.config.update({ endpoint: `http://localhost:${port}` }) - var ddb = new AWS.DynamoDB({ apiVersion: '2012-08-10' }) - var params = { + const ddb = new AWS.DynamoDB({ apiVersion: '2012-08-10' }) + const params = { TableName: 'fixture-table', KeyConditionExpression: 'id = :foo', ExpressionAttributeValues: { diff --git a/test/instrumentation/modules/aws-sdk/fixtures/use-s3.js b/test/instrumentation/modules/aws-sdk/fixtures/use-s3.js index 3fdf8e5a5e..d0cfe0ab37 100644 --- a/test/instrumentation/modules/aws-sdk/fixtures/use-s3.js +++ b/test/instrumentation/modules/aws-sdk/fixtures/use-s3.js @@ -120,7 +120,7 @@ function useS3 (s3Client, bucketName, cb) { // https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#putObject-property function createObj (_, next) { - var md5 = crypto.createHash('md5').update(content).digest('base64') + const md5 = crypto.createHash('md5').update(content).digest('base64') s3Client.putObject({ Bucket: bucketName, Key: key, diff --git a/test/instrumentation/modules/bluebird/_coroutine.js b/test/instrumentation/modules/bluebird/_coroutine.js index 4d1717e618..c28cc88390 100644 --- a/test/instrumentation/modules/bluebird/_coroutine.js +++ b/test/instrumentation/modules/bluebird/_coroutine.js @@ -6,11 +6,11 @@ 'use strict' -var semver = require('semver') -var BLUEBIRD_VERSION = require('bluebird/package').version +const semver = require('semver') +const BLUEBIRD_VERSION = require('bluebird/package').version module.exports = function (test, Promise, ins) { - var bluebird = Promise + const bluebird = Promise test('Promise.coroutine', function (t) { t.plan(10) @@ -39,8 +39,8 @@ module.exports = function (test, Promise, ins) { }) twice(function () { - var trans = ins.startTransaction() - var a = new PingPong(trans) + const trans = ins.startTransaction() + const a = new PingPong(trans) a.ping(0) }) }) @@ -49,7 +49,7 @@ module.exports = function (test, Promise, ins) { test('Promise.coroutine.addYieldHandler', function (t) { t.plan(10) - var Promise = bluebird.getNewLibraryCopy() + const Promise = bluebird.getNewLibraryCopy() Promise.coroutine.addYieldHandler(function (value) { return Promise.delay(value) @@ -79,8 +79,8 @@ module.exports = function (test, Promise, ins) { }) twice(function () { - var trans = ins.startTransaction() - var a = new PingPong(trans) + const trans = ins.startTransaction() + const a = new PingPong(trans) a.ping(0) }) }) @@ -91,7 +91,7 @@ module.exports = function (test, Promise, ins) { test('Promise.spawn', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() Promise.spawn(function * () { return yield Promise.resolve('foo') diff --git a/test/instrumentation/modules/bluebird/bluebird.test.js b/test/instrumentation/modules/bluebird/bluebird.test.js index 2b315a2430..b4130e937e 100644 --- a/test/instrumentation/modules/bluebird/bluebird.test.js +++ b/test/instrumentation/modules/bluebird/bluebird.test.js @@ -15,7 +15,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { // expected. require('../../../_promise_rejection').remove() -var agent = require('../../../..').start({ +const agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -23,12 +23,12 @@ var agent = require('../../../..').start({ centralConfig: false }) -var BLUEBIRD_VERSION = require('bluebird/package').version -var Promise = require('bluebird') -var semver = require('semver') -var test = require('tape') +const BLUEBIRD_VERSION = require('bluebird/package').version +const Promise = require('bluebird') +const semver = require('semver') +const test = require('tape') -var ins = agent._instrumentation +const ins = agent._instrumentation require('../../_shared-promise-tests')(test, Promise, ins) require('./_coroutine')(test, Promise, ins) @@ -36,7 +36,7 @@ require('./_coroutine')(test, Promise, ins) test('Promise.prototype.spread - all formal', function (t) { t.plan(6) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() Promise.all(['foo', 'bar']).spread(function (a, b) { t.strictEqual(a, 'foo') t.strictEqual(b, 'bar') @@ -48,8 +48,8 @@ test('Promise.prototype.spread - all formal', function (t) { test('Promise.prototype.spread - all promises', function (t) { t.plan(6) twice(function () { - var trans = ins.startTransaction() - var arr = [resolved('foo'), resolved('bar')] + const trans = ins.startTransaction() + const arr = [resolved('foo'), resolved('bar')] Promise.all(arr).spread(function (a, b) { t.strictEqual(a, 'foo') t.strictEqual(b, 'bar') @@ -61,7 +61,7 @@ test('Promise.prototype.spread - all promises', function (t) { test('Promise.prototype.spread - then formal', function (t) { t.plan(6) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() Promise.delay(1).then(function () { return ['foo', 'bar'] }).spread(function (a, b) { @@ -75,7 +75,7 @@ test('Promise.prototype.spread - then formal', function (t) { test('Promise.prototype.spread - then promises', function (t) { t.plan(6) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() Promise.delay(1).then(function () { return [resolved('foo'), resolved('bar')] }).spread(function (a, b) { @@ -86,12 +86,12 @@ test('Promise.prototype.spread - then promises', function (t) { }) }) -var CATCH_NAMES = ['catch', 'caught'] +const CATCH_NAMES = ['catch', 'caught'] CATCH_NAMES.forEach(function (fnName) { test('new Promise -> reject -> ' + fnName + ' (filtered, first type)', function (t) { t.plan(6) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() rejected(new TypeError('foo')) .then(function () { t.fail('should not resolve') @@ -110,7 +110,7 @@ CATCH_NAMES.forEach(function (fnName) { test('new Promise -> reject -> ' + fnName + ' (filtered, second type)', function (t) { t.plan(6) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() rejected(new ReferenceError('foo')) .then(function () { t.fail('should not resolve') @@ -130,7 +130,7 @@ CATCH_NAMES.forEach(function (fnName) { t.plan(6) twice(function () { setImmediate(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() rejected(new SyntaxError('foo')) .then(function () { t.fail('should not resolve') @@ -150,7 +150,7 @@ CATCH_NAMES.forEach(function (fnName) { test('new Promise -> reject -> ' + fnName + ' (filtered, multi, first type)', function (t) { t.plan(6) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() rejected(new SyntaxError('foo')) .then(function () { t.fail('should not resolve') @@ -169,7 +169,7 @@ CATCH_NAMES.forEach(function (fnName) { test('new Promise -> reject -> ' + fnName + ' (filtered, multi, second type)', function (t) { t.plan(6) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() rejected(new RangeError('foo')) .then(function () { t.fail('should not resolve') @@ -188,7 +188,7 @@ CATCH_NAMES.forEach(function (fnName) { test('new Promise -> reject -> ' + fnName + ' (filtered, multi, catch-all)', function (t) { t.plan(6) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() rejected(new URIError('foo')) .then(function () { t.fail('should not resolve') @@ -207,7 +207,7 @@ CATCH_NAMES.forEach(function (fnName) { test('new Promise -> reject -> ' + fnName + ' (filtered, predicate)', function (t) { t.plan(18) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() rejected(new URIError('foo')) .then(function () { @@ -242,8 +242,8 @@ CATCH_NAMES.forEach(function (fnName) { test('new Promise -> reject -> ' + fnName + ' (filtered, predicate shorthand)', function (t) { t.plan(6) twice(function () { - var trans = ins.startTransaction() - var err = new URIError('foo') + const trans = ins.startTransaction() + const err = new URIError('foo') err.code = 42 rejected(err) .then(function () { @@ -265,7 +265,7 @@ CATCH_NAMES.forEach(function (fnName) { test('new Promise -> reject -> error', function (t) { t.plan(6) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() rejected(new Promise.OperationalError('foo')) .then(function () { t.fail('should not resolve') @@ -279,12 +279,12 @@ test('new Promise -> reject -> error', function (t) { }) }) -var FINALLY_NAMES = ['finally', 'lastly'] +const FINALLY_NAMES = ['finally', 'lastly'] FINALLY_NAMES.forEach(function (fnName) { test('new Promise -> reject -> ' + fnName, function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() rejected('foo') .then(function () { t.fail('should not resolve') @@ -298,7 +298,7 @@ FINALLY_NAMES.forEach(function (fnName) { test('new Promise -> reject -> catch -> ' + fnName, function (t) { t.plan(6) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() rejected('foo') .then(function () { t.fail('should not resolve') @@ -314,7 +314,7 @@ FINALLY_NAMES.forEach(function (fnName) { test('new Promise -> reject -> then -> catch -> ' + fnName + ' -> new Promise -> then', function (t) { t.plan(8) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() rejected('foo') .then(function () { t.fail('should not resolve') @@ -333,8 +333,8 @@ FINALLY_NAMES.forEach(function (fnName) { test('new Promise -> resolve -> then -> ' + fnName + ' -> new Promise -> then', function (t) { t.plan(10) twice(function () { - var trans = ins.startTransaction() - var finallyCalled = false + const trans = ins.startTransaction() + let finallyCalled = false resolved('foo') .then(function (result) { t.strictEqual(result, 'foo') @@ -355,8 +355,8 @@ FINALLY_NAMES.forEach(function (fnName) { test('new Promise -> resolve -> ' + fnName + ' -> new Promise -> then', function (t) { t.plan(8) twice(function () { - var trans = ins.startTransaction() - var finallyCalled = false + const trans = ins.startTransaction() + let finallyCalled = false resolved('foo') .catch(function () { t.fail('should not reject') @@ -379,9 +379,9 @@ test('new Promise -> bind -> then', function (t) { function Obj () {} twice(function () { - var trans = ins.startTransaction() - var obj = new Obj() - var n = obj.n = Math.random() + const trans = ins.startTransaction() + const obj = new Obj() + const n = obj.n = Math.random() resolved('foo') .bind(obj) @@ -400,11 +400,11 @@ if (semver.satisfies(BLUEBIRD_VERSION, '>=2.9.0')) { function Obj () {} twice(function () { - var trans = ins.startTransaction() - var obj = new Obj() - var n = obj.n = Math.random() + const trans = ins.startTransaction() + const obj = new Obj() + const n = obj.n = Math.random() - var p = resolved('foo') + let p = resolved('foo') p = Promise.bind(obj, p) @@ -420,9 +420,9 @@ if (semver.satisfies(BLUEBIRD_VERSION, '>=2.9.0')) { test('Promise.bind - promise, without value', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() - var p = resolved('foo') + let p = resolved('foo') p = Promise.bind(p) @@ -439,11 +439,11 @@ test('Promise.bind - non-promise, without value', function (t) { function Obj () {} twice(function () { - var trans = ins.startTransaction() - var obj = new Obj() - var n = obj.n = Math.random() + const trans = ins.startTransaction() + const obj = new Obj() + const n = obj.n = Math.random() - var p = Promise.bind(obj) + const p = Promise.bind(obj) p.then(function (result) { t.strictEqual(this.n, n) @@ -456,11 +456,11 @@ test('Promise.bind - non-promise, without value', function (t) { test('Promise.join', function (t) { t.plan(8) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() - var p1 = resolved('p1') - var p2 = resolved('p2') - var p3 = resolved('p3') + const p1 = resolved('p1') + const p2 = resolved('p2') + const p3 = resolved('p3') Promise.join(p1, p2, p3, function (a, b, c) { t.strictEqual(a, 'p1') @@ -471,12 +471,12 @@ test('Promise.join', function (t) { }) }) -var TRY_NAMES = ['try', 'attempt'] +const TRY_NAMES = ['try', 'attempt'] TRY_NAMES.forEach(function (fnName) { test('Promise.' + fnName + ' -> return value', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() Promise[fnName](function () { return 'foo' }).then(function (result) { @@ -491,7 +491,7 @@ TRY_NAMES.forEach(function (fnName) { test('Promise.' + fnName + ' -> throw', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() Promise[fnName](function () { throw new Error('foo') }).then(function () { @@ -506,7 +506,7 @@ TRY_NAMES.forEach(function (fnName) { test('Promise.' + fnName + ' with args value', function (t) { t.plan(6) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() Promise[fnName](function (value) { t.strictEqual(value, 'bar') return 'foo' @@ -522,7 +522,7 @@ TRY_NAMES.forEach(function (fnName) { test('Promise.' + fnName + ' with args array', function (t) { t.plan(6) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() Promise[fnName](function () { t.deepEqual([].slice.call(arguments), [1, 2, 3]) return 'foo' @@ -538,8 +538,8 @@ TRY_NAMES.forEach(function (fnName) { test('Promise.' + fnName + ' with context', function (t) { t.plan(8) twice(function () { - var trans = ins.startTransaction() - var obj = {} + const trans = ins.startTransaction() + const obj = {} Promise[fnName](function (value) { t.strictEqual(value, undefined) t.strictEqual(this, obj) @@ -557,7 +557,7 @@ TRY_NAMES.forEach(function (fnName) { test('Promise.method -> return value', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() Promise.method(function () { return 'foo' })().then(function (result) { @@ -572,7 +572,7 @@ test('Promise.method -> return value', function (t) { test('Promise.method -> throw', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() Promise.method(function () { throw new Error('foo') })().then(function () { @@ -587,11 +587,11 @@ test('Promise.method -> throw', function (t) { test('Promise.all', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() - var p1 = resolved('p1') - var p2 = resolved('p2') - var p3 = resolved('p3') + const p1 = resolved('p1') + const p2 = resolved('p2') + const p3 = resolved('p3') Promise.all([p1, p2, p3]).then(function (result) { t.deepEqual(result, ['p1', 'p2', 'p3']) @@ -603,11 +603,11 @@ test('Promise.all', function (t) { test('new Promise -> all', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() - var p1 = resolved('p1') - var p2 = resolved('p2') - var p3 = resolved('p3') + const p1 = resolved('p1') + const p2 = resolved('p2') + const p3 = resolved('p3') resolved([p1, p2, p3]).all().then(function (result) { t.deepEqual(result, ['p1', 'p2', 'p3']) @@ -619,9 +619,9 @@ test('new Promise -> all', function (t) { test('Promise.props', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() - var props = { + const props = { p1: resolved('p1'), p2: resolved('p2'), p3: resolved('p3') @@ -637,9 +637,9 @@ test('Promise.props', function (t) { test('new Promise -> props', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() - var props = { + const props = { p1: resolved('p1'), p2: resolved('p2'), p3: resolved('p3') @@ -655,15 +655,15 @@ test('new Promise -> props', function (t) { test('Promise.any', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() - var p1 = new Promise(function (resolve, reject) { + const p1 = new Promise(function (resolve, reject) { setTimeout(function () { resolve('p1') }, 100) }) - var p2 = rejected('p2') - var p3 = resolved('p3') + const p2 = rejected('p2') + const p3 = resolved('p3') Promise.any([p1, p2, p3]).then(function (result) { t.strictEqual(result, 'p3') @@ -675,15 +675,15 @@ test('Promise.any', function (t) { test('new Promise -> any', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() - var p1 = new Promise(function (resolve, reject) { + const p1 = new Promise(function (resolve, reject) { setTimeout(function () { resolve('p1') }, 100) }) - var p2 = rejected('p2') - var p3 = resolved('p3') + const p2 = rejected('p2') + const p3 = resolved('p3') resolved([p1, p2, p3]).any().then(function (result) { t.strictEqual(result, 'p3') @@ -695,16 +695,16 @@ test('new Promise -> any', function (t) { test('Promise.some', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() - var p1 = new Promise(function (resolve, reject) { + const p1 = new Promise(function (resolve, reject) { setTimeout(function () { resolve('p1') }, 100) }) - var p2 = resolved('p2') - var p3 = rejected('p3') - var p4 = resolved('p4') + const p2 = resolved('p2') + const p3 = rejected('p3') + const p4 = resolved('p4') Promise.some([p1, p2, p3, p4], 2).then(function (result) { t.deepEqual(result, ['p2', 'p4']) @@ -716,16 +716,16 @@ test('Promise.some', function (t) { test('new Promise -> some', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() - var p1 = new Promise(function (resolve, reject) { + const p1 = new Promise(function (resolve, reject) { setTimeout(function () { resolve('p1') }, 100) }) - var p2 = resolved('p2') - var p3 = rejected('p3') - var p4 = resolved('p4') + const p2 = resolved('p2') + const p3 = rejected('p3') + const p4 = resolved('p4') resolved([p1, p2, p3, p4]).some(2).then(function (result) { t.deepEqual(result, ['p2', 'p4']) @@ -737,7 +737,7 @@ test('new Promise -> some', function (t) { test('Promise.map', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() Promise.map([1, 2, 3], function (value) { return resolved(value) @@ -751,7 +751,7 @@ test('Promise.map', function (t) { test('new Promise -> map', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() resolved([1, 2, 3]).map(function (value) { return resolved(value) @@ -765,7 +765,7 @@ test('new Promise -> map', function (t) { test('Promise.reduce', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() Promise.reduce([1, 2, 3], function (total, value) { return new Promise(function (resolve, reject) { @@ -783,7 +783,7 @@ test('Promise.reduce', function (t) { test('new Promise -> reduce', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() resolved([1, 2, 3]).reduce(function (total, value) { return new Promise(function (resolve, reject) { @@ -801,8 +801,8 @@ test('new Promise -> reduce', function (t) { test('Promise.filter', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() - var arr = [resolved(1), resolved(2), resolved(3), resolved(4)] + const trans = ins.startTransaction() + const arr = [resolved(1), resolved(2), resolved(3), resolved(4)] Promise.filter(arr, function (value) { return value > 2 @@ -816,8 +816,8 @@ test('Promise.filter', function (t) { test('new Promise -> filter', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() - var arr = [resolved(1), resolved(2), resolved(3), resolved(4)] + const trans = ins.startTransaction() + const arr = [resolved(1), resolved(2), resolved(3), resolved(4)] resolved(arr).filter(function (value) { return value > 2 @@ -834,12 +834,12 @@ test('new Promise -> filter', function (t) { test('Promise.each', function (t) { t.plan(24) twice(function () { - var trans = ins.startTransaction() - var arr = [resolved(1), resolved(2), resolved(3)] - var results = [1, 2, 3] + const trans = ins.startTransaction() + const arr = [resolved(1), resolved(2), resolved(3)] + const results = [1, 2, 3] Promise.each(arr, function (item, index, length) { - var expected = results.shift() + const expected = results.shift() t.strictEqual(item, expected) t.strictEqual(index, expected - 1, 'index should be expected - 1') t.strictEqual(length, 3, 'length should be 3') @@ -854,12 +854,12 @@ test('Promise.each', function (t) { test('new Promise -> each', function (t) { t.plan(24) twice(function () { - var trans = ins.startTransaction() - var arr = [resolved(1), resolved(2), resolved(3)] - var results = [1, 2, 3] + const trans = ins.startTransaction() + const arr = [resolved(1), resolved(2), resolved(3)] + const results = [1, 2, 3] resolved(arr).each(function (item, index, length) { - var expected = results.shift() + const expected = results.shift() t.strictEqual(item, expected) t.strictEqual(index, expected - 1, 'index should be expected - 1') t.strictEqual(length, 3, 'length should be 3') @@ -872,16 +872,16 @@ if (semver.satisfies(BLUEBIRD_VERSION, '>=3')) { test('Promise.mapSeries', function (t) { t.plan(24) twice(function () { - var trans = ins.startTransaction() - var p1 = resolved(1) - var p2 = resolved(2) - var p3 = resolved(3) - var arr = [p2, p3, p1] - var results = [2, 3, 1] - var i = 0 + const trans = ins.startTransaction() + const p1 = resolved(1) + const p2 = resolved(2) + const p3 = resolved(3) + const arr = [p2, p3, p1] + const results = [2, 3, 1] + let i = 0 Promise.mapSeries(arr, function (item, index, length) { - var expected = results.shift() + const expected = results.shift() t.strictEqual(item, expected) t.strictEqual(index, i++) t.strictEqual(length, 3, 'length should be 3') @@ -893,16 +893,16 @@ if (semver.satisfies(BLUEBIRD_VERSION, '>=3')) { test('new Promise -> mapSeries', function (t) { t.plan(24) twice(function () { - var trans = ins.startTransaction() - var p1 = resolved(1) - var p2 = resolved(2) - var p3 = resolved(3) - var arr = [p2, p3, p1] - var results = [2, 3, 1] - var i = 0 + const trans = ins.startTransaction() + const p1 = resolved(1) + const p2 = resolved(2) + const p3 = resolved(3) + const arr = [p2, p3, p1] + const results = [2, 3, 1] + let i = 0 resolved(arr).mapSeries(function (item, index, length) { - var expected = results.shift() + const expected = results.shift() t.strictEqual(item, expected) t.strictEqual(index, i++) t.strictEqual(length, 3, 'length should be 3') @@ -915,7 +915,7 @@ if (semver.satisfies(BLUEBIRD_VERSION, '>=3')) { test('Promise.using', function (t) { t.plan(6) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() Promise.using(getResource(), function (resource) { t.strictEqual(resource, 'foo') @@ -933,11 +933,11 @@ test('Promise.using', function (t) { test('Promise.promisify', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() - var readFile = Promise.promisify(require('fs').readFile) + const trans = ins.startTransaction() + const readFile = Promise.promisify(require('fs').readFile) readFile(__filename, 'utf8').then(function (contents) { - var firstLine = contents.split('\n')[0] + const firstLine = contents.split('\n')[0] t.strictEqual(firstLine, '/*', 'firstLine') t.strictEqual(ins.currTransaction().id, trans.id, 'currentTransaction().id') }) @@ -947,9 +947,9 @@ test('Promise.promisify', function (t) { test('Promise.promisifyAll', function (t) { t.plan(8) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() - var obj = { + const obj = { success (cb) { setImmediate(function () { cb(null, 'foo') @@ -982,14 +982,14 @@ test('Promise.promisifyAll', function (t) { }) }) -var fromCallbackNames = [] +const fromCallbackNames = [] if (semver.satisfies(BLUEBIRD_VERSION, '>=2.9.0')) fromCallbackNames.push('fromNode') if (semver.satisfies(BLUEBIRD_VERSION, '>=3')) fromCallbackNames.push('fromCallback') fromCallbackNames.forEach(function (fnName) { test('Promise.' + fnName + ' - resolve', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() Promise[fnName](function (cb) { setImmediate(function () { @@ -1007,7 +1007,7 @@ fromCallbackNames.forEach(function (fnName) { test('Promise.' + fnName + ' - reject', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() Promise[fnName](function (cb) { setImmediate(function () { @@ -1023,13 +1023,13 @@ fromCallbackNames.forEach(function (fnName) { }) }) -var asCallbackNames = ['nodeify'] +const asCallbackNames = ['nodeify'] if (semver.satisfies(BLUEBIRD_VERSION, '>=2.9.15')) asCallbackNames.push('asCallback') asCallbackNames.forEach(function (fnName) { test('new Promise -> ' + fnName + ' (resolve)', function (t) { t.plan(10) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() getSomething().then(function (value) { t.strictEqual(value, 'foo') @@ -1051,7 +1051,7 @@ asCallbackNames.forEach(function (fnName) { test('new Promise -> ' + fnName + ' (reject)', function (t) { t.plan(10) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() getSomething() .then(function () { @@ -1077,12 +1077,12 @@ asCallbackNames.forEach(function (fnName) { test('Promise.delay', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() - var start = Date.now() + const trans = ins.startTransaction() + const start = Date.now() Promise.delay(50).then(function () { - var expected = start + 49 // timings are hard - var now = Date.now() + const expected = start + 49 // timings are hard + const now = Date.now() t.ok(expected <= now, 'start + 49 should be <= ' + now + ' - was ' + expected) t.strictEqual(ins.currTransaction().id, trans.id) }) @@ -1092,12 +1092,12 @@ test('Promise.delay', function (t) { test('new Promise -> delay', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() - var start = Date.now() + const trans = ins.startTransaction() + const start = Date.now() Promise.resolve('foo').delay(50).then(function () { - var expected = start + 49 // timings are hard - var now = Date.now() + const expected = start + 49 // timings are hard + const now = Date.now() t.ok(expected <= now, 'start + 49 should be <= ' + now + ' - was ' + expected) t.strictEqual(ins.currTransaction().id, trans.id) }) @@ -1107,7 +1107,7 @@ test('new Promise -> delay', function (t) { test('new Promise -> timeout (resolve in time)', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() resolved('foo') .timeout(50) @@ -1124,7 +1124,7 @@ test('new Promise -> timeout (resolve in time)', function (t) { test('new Promise -> timeout (reject in time)', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() rejected('foo') .timeout(50) @@ -1145,8 +1145,8 @@ test('new Promise -> timeout (timed out)', function (t) { t.plan(6) twice(function () { - var trans = ins.startTransaction() - var start = Date.now() + const trans = ins.startTransaction() + const start = Date.now() new Promise(function (resolve, reject) { setTimeout(function () { @@ -1157,8 +1157,8 @@ test('new Promise -> timeout (timed out)', function (t) { }).catch(function (err) { // You would think elapsed would always be >=50ms, but in busy CI I have // seen slightly *less than* 50ms. - var elapsedMs = Date.now() - start - var diffMs = Math.abs(50 - elapsedMs) + const elapsedMs = Date.now() - start + const diffMs = Math.abs(50 - elapsedMs) t.ok(diffMs <= SLOP_MS, `.timeout(50) resulted in 50 +/- ${SLOP_MS}, actual elapsed was ${elapsedMs}ms`) t.ok(err instanceof Promise.TimeoutError, 'err') t.strictEqual(ins.currTransaction().id, trans.id, 'transaction.id') @@ -1169,7 +1169,7 @@ test('new Promise -> timeout (timed out)', function (t) { test('new Promise -> reject -> tap -> catch', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() rejected('foo') .tap(function () { t.fail('should not call tap') @@ -1187,7 +1187,7 @@ test('new Promise -> reject -> tap -> catch', function (t) { test('new Promise -> resolve -> tap -> then (no return)', function (t) { t.plan(6) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() resolved('foo') .tap(function (value) { t.strictEqual(value, 'foo') @@ -1202,7 +1202,7 @@ test('new Promise -> resolve -> tap -> then (no return)', function (t) { test('new Promise -> resolve -> tap -> then (return)', function (t) { t.plan(6) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() resolved('foo') .tap(function (value) { t.strictEqual(value, 'foo') @@ -1218,8 +1218,8 @@ test('new Promise -> resolve -> tap -> then (return)', function (t) { test('new Promise -> call', function (t) { t.plan(8) twice(function () { - var trans = ins.startTransaction() - var obj = { + const trans = ins.startTransaction() + const obj = { foo (a, b) { t.strictEqual(a, 1) t.strictEqual(b, 2) @@ -1238,7 +1238,7 @@ test('new Promise -> call', function (t) { test('new Promise -> get', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() resolved({ foo: 42 }) .get('foo') .then(function (value) { @@ -1248,12 +1248,12 @@ test('new Promise -> get', function (t) { }) }) -var RETURN_NAMES = ['return', 'thenReturn'] +const RETURN_NAMES = ['return', 'thenReturn'] RETURN_NAMES.forEach(function (fnName) { test('new Promise -> ' + fnName, function (t) { t.plan(8) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() resolved('foo') .then(function (value) { t.deepEqual(value, 'foo') @@ -1267,12 +1267,12 @@ RETURN_NAMES.forEach(function (fnName) { }) }) -var THROW_NAMES = ['throw', 'thenThrow'] +const THROW_NAMES = ['throw', 'thenThrow'] THROW_NAMES.forEach(function (fnName) { test('new Promise -> ' + fnName, function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() resolved('foo')[fnName](new Error('bar')) .then(function () { t.fail('should not resolve') @@ -1289,7 +1289,7 @@ if (semver.satisfies(BLUEBIRD_VERSION, '>=3')) { test('new Promise -> resolve -> catchReturn', function (t) { t.plan(8) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() resolved('foo') .then(function (value) { t.deepEqual(value, 'foo') @@ -1306,7 +1306,7 @@ if (semver.satisfies(BLUEBIRD_VERSION, '>=3')) { test('new Promise -> reject -> catchReturn', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() rejected('foo') .then(function () { t.fail('should not resolve') @@ -1322,7 +1322,7 @@ if (semver.satisfies(BLUEBIRD_VERSION, '>=3')) { test('new Promise -> resolve -> catchThrow', function (t) { t.plan(8) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() resolved('foo') .then(function (value) { t.deepEqual(value, 'foo') @@ -1342,7 +1342,7 @@ if (semver.satisfies(BLUEBIRD_VERSION, '>=3')) { test('new Promise -> reject -> catchThrow', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() rejected('foo') .then(function () { t.fail('should not resolve') @@ -1363,7 +1363,7 @@ if (semver.satisfies(BLUEBIRD_VERSION, '>=2.3.6')) { test('new Promise -> reflect', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() resolved('foo').reflect().then(function (p) { t.ok(p.isFulfilled()) t.strictEqual(ins.currTransaction().id, trans.id) @@ -1375,7 +1375,7 @@ if (semver.satisfies(BLUEBIRD_VERSION, '>=2.3.6')) { test('new Promise -> settle', function (t) { t.plan(6) twice(function () { - var trans = ins.startTransaction() + const trans = ins.startTransaction() Promise.settle([resolved('foo')]).then(function (result) { t.strictEqual(result.length, 1) t.ok(result[0].isFulfilled()) diff --git a/test/instrumentation/modules/bluebird/cancel.test.js b/test/instrumentation/modules/bluebird/cancel.test.js index 861495e0c8..c2c88e6a8e 100644 --- a/test/instrumentation/modules/bluebird/cancel.test.js +++ b/test/instrumentation/modules/bluebird/cancel.test.js @@ -11,7 +11,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -var agent = require('../../../..').start({ +const agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -19,24 +19,24 @@ var agent = require('../../../..').start({ centralConfig: false }) -var BLUEBIRD_VERSION = require('bluebird/package').version -var Promise = require('bluebird') -var semver = require('semver') -var test = require('tape') +const BLUEBIRD_VERSION = require('bluebird/package').version +const Promise = require('bluebird') +const semver = require('semver') +const test = require('tape') -var ins = agent._instrumentation +const ins = agent._instrumentation if (semver.satisfies(BLUEBIRD_VERSION, '>=3')) { Promise.config({ cancellation: true }) - var CANCEL_NAMES = ['cancel', 'break'] + const CANCEL_NAMES = ['cancel', 'break'] CANCEL_NAMES.forEach(function (fnName) { test('Promise.prototype.' + fnName, function (t) { t.plan(8) twice(function () { - var trans = ins.startTransaction() - var cancelled = false - var p = new Promise(function (resolve, reject, onCancel) { + const trans = ins.startTransaction() + let cancelled = false + const p = new Promise(function (resolve, reject, onCancel) { setTimeout(function () { resolve('foo') }, 100) @@ -65,9 +65,9 @@ if (semver.satisfies(BLUEBIRD_VERSION, '>=3')) { test('Promise.prototype.cancel', function (t) { t.plan(4) twice(function () { - var trans = ins.startTransaction() - var p = new Promise(function () {}).cancellable() - var err = new Error() + const trans = ins.startTransaction() + const p = new Promise(function () {}).cancellable() + const err = new Error() p.cancel(err) p.then(t.fail, function (e) { t.strictEqual(e, err) diff --git a/test/instrumentation/modules/elasticsearch.test.js b/test/instrumentation/modules/elasticsearch.test.js index 39860c77e1..dfc513ea39 100644 --- a/test/instrumentation/modules/elasticsearch.test.js +++ b/test/instrumentation/modules/elasticsearch.test.js @@ -12,9 +12,9 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { } process.env.ELASTIC_APM_TEST = true -var host = (process.env.ES_HOST || 'localhost') + ':9200' +const host = (process.env.ES_HOST || 'localhost') + ':9200' -var agent = require('../../..').start({ +const agent = require('../../..').start({ serviceName: 'test-elasticsearch-legacy-client', captureExceptions: false, metricsInterval: 0, @@ -24,20 +24,20 @@ var agent = require('../../..').start({ spanCompressionEnabled: false }) -var elasticsearch = require('elasticsearch') -var pkg = require('elasticsearch/package.json') -var semver = require('semver') -var test = require('tape') +const elasticsearch = require('elasticsearch') +const pkg = require('elasticsearch/package.json') +const semver = require('semver') +const test = require('tape') -var mockClient = require('../../_mock_http_client') -var findObjInArray = require('../../_utils').findObjInArray +const mockClient = require('../../_mock_http_client') +const findObjInArray = require('../../_utils').findObjInArray test('client.ping with callback', function userLandCode (t) { resetAgent(assertApmDataAndEnd(t, 'HEAD /', `http://${host}/`)) agent.startTransaction('foo') - var client = new elasticsearch.Client({ host: host }) + const client = new elasticsearch.Client({ host: host }) client.ping(function (err) { t.error(err, 'no error from client.ping') @@ -52,7 +52,7 @@ test('client.ping with promise', function userLandCode (t) { agent.startTransaction('foo') - var client = new elasticsearch.Client({ host: host }) + const client = new elasticsearch.Client({ host: host }) client.ping().then(function () { agent.endTransaction() @@ -68,8 +68,8 @@ test('client.search with callback', function userLandCode (t) { agent.startTransaction('foo') - var client = new elasticsearch.Client({ host: host }) - var query = { q: 'pants' } + const client = new elasticsearch.Client({ host: host }) + const query = { q: 'pants' } client.search(query, function (err) { t.error(err) @@ -84,10 +84,10 @@ test('client.search with abort', function userLandCode (t) { agent.startTransaction('foo') - var client = new elasticsearch.Client({ host: host }) - var query = { q: 'pants' } + const client = new elasticsearch.Client({ host: host }) + const query = { q: 'pants' } - var req = client.search(query) + const req = client.search(query) t.ok(agent.currentSpan === null, 'no currentSpan in sync code after elasticsearch client command') setImmediate(() => { @@ -99,7 +99,7 @@ test('client.search with abort', function userLandCode (t) { if (semver.satisfies(pkg.version, '>= 10')) { test('client.searchTemplate with callback', function userLandCode (t) { - var body = { + const body = { source: { query: { query_string: { @@ -121,7 +121,7 @@ if (semver.satisfies(pkg.version, '>= 10')) { agent.startTransaction('foo') - var client = new elasticsearch.Client({ host: host }) + const client = new elasticsearch.Client({ host: host }) client.searchTemplate({ body }, function (err) { t.error(err) @@ -134,7 +134,7 @@ if (semver.satisfies(pkg.version, '>= 10')) { if (semver.satisfies(pkg.version, '>= 13')) { test('client.msearch with callback', function userLandCode (t) { - var body = [ + const body = [ {}, { query: { @@ -145,13 +145,13 @@ if (semver.satisfies(pkg.version, '>= 13')) { } ] - var statement = body.map(JSON.stringify).join('\n') + '\n' + const statement = body.map(JSON.stringify).join('\n') + '\n' resetAgent(assertApmDataAndEnd(t, 'POST /_msearch', `http://${host}/_msearch`, statement)) agent.startTransaction('foo') - var client = new elasticsearch.Client({ host: host }) + const client = new elasticsearch.Client({ host: host }) client.msearch({ body }, function (err) { t.error(err) @@ -162,7 +162,7 @@ if (semver.satisfies(pkg.version, '>= 13')) { }) test('client.msearchTempate with callback', function userLandCode (t) { - var body = [ + const body = [ {}, { source: { @@ -178,13 +178,13 @@ if (semver.satisfies(pkg.version, '>= 13')) { } ] - var statement = body.map(JSON.stringify).join('\n') + '\n' + const statement = body.map(JSON.stringify).join('\n') + '\n' resetAgent(assertApmDataAndEnd(t, 'POST /_msearch/template', `http://${host}/_msearch/template`, statement)) agent.startTransaction('foo') - var client = new elasticsearch.Client({ host: host }) + const client = new elasticsearch.Client({ host: host }) client.msearchTemplate({ body }, function (err) { t.error(err) @@ -200,7 +200,7 @@ test('client.count with callback', function userLandCode (t) { agent.startTransaction('foo') - var client = new elasticsearch.Client({ host: host }) + const client = new elasticsearch.Client({ host: host }) client.count(function (err) { t.error(err) agent.endTransaction() @@ -212,7 +212,7 @@ test('client.count with callback', function userLandCode (t) { test('client with host=', function userLandCode (t) { resetAgent(assertApmDataAndEnd(t, 'HEAD /', `http://${host}/`)) agent.startTransaction('foo') - var client = new elasticsearch.Client({ host: [host] }) + const client = new elasticsearch.Client({ host: [host] }) client.ping(function (err) { t.error(err) agent.endTransaction() @@ -224,7 +224,7 @@ test('client with host=', function userLandCode (t) { test('client with hosts=', function userLandCode (t) { resetAgent(assertApmDataAndEnd(t, 'HEAD /', `http://${host}/`)) agent.startTransaction('foo') - var client = new elasticsearch.Client({ hosts: [host, host] }) + const client = new elasticsearch.Client({ hosts: [host, host] }) client.ping(function (err) { t.error(err) agent.endTransaction() @@ -240,7 +240,7 @@ test('client with hosts="http://host:port"', function userLandCode (t) { if (!hostWithProto.startsWith('http')) { hostWithProto = 'http://' + host } - var client = new elasticsearch.Client({ hosts: hostWithProto }) + const client = new elasticsearch.Client({ hosts: hostWithProto }) client.ping(function (err) { t.error(err) agent.endTransaction() @@ -253,7 +253,7 @@ test('client with host=', function userLandCode (t) { resetAgent(assertApmDataAndEnd(t, 'HEAD /', `http://${host}/`)) agent.startTransaction('foo') const [hostname, port] = host.split(':') - var client = new elasticsearch.Client({ + const client = new elasticsearch.Client({ host: [{ host: hostname, port: port }] }) client.ping(function (err) { @@ -269,7 +269,7 @@ function assertApmDataAndEnd (t, expectedName, expectedHttpUrl, expectedDbStatem t.strictEqual(data.transactions.length, 1, 'should have 1 transaction') t.strictEqual(data.spans.length, 1, 'should have 1 span') - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, 'foo', 'transaction name should be "foo"') t.strictEqual(trans.type, 'custom', 'transaction type should be "custom"') diff --git a/test/instrumentation/modules/express-queue.test.js b/test/instrumentation/modules/express-queue.test.js index 9d7700f6e2..74eedf331b 100644 --- a/test/instrumentation/modules/express-queue.test.js +++ b/test/instrumentation/modules/express-queue.test.js @@ -11,7 +11,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -var agent = require('../../..').start({ +const agent = require('../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -19,23 +19,23 @@ var agent = require('../../..').start({ centralConfig: false }) -var http = require('http') +const http = require('http') -var express = require('express') -var queue = require('express-queue') -var test = require('tape') +const express = require('express') +const queue = require('express-queue') +const test = require('tape') -var mockClient = require('../../_mock_http_client') -var findObjInArray = require('../../_utils').findObjInArray +const mockClient = require('../../_mock_http_client') +const findObjInArray = require('../../_utils').findObjInArray test('express-queue', function (t) { resetAgent(done(t, 'done')) - var app = express() + const app = express() app.use(queue({ activeLimit: 1, queuedLimit: -1 })) app.get('/', function (req, res) { setImmediate(function () { - var span = agent.startSpan('foo', 'bar') + const span = agent.startSpan('foo', 'bar') setImmediate(function () { if (span) span.end() res.end('done') @@ -44,10 +44,10 @@ test('express-queue', function (t) { }) var server = app.listen(function () { - var port = server.address().port - var path = '/' + const port = server.address().port + const path = '/' - var tasks = [] + const tasks = [] for (let i = 0; i < 5; i++) { tasks.push(request(port, path)) } @@ -63,7 +63,7 @@ test('express-queue', function (t) { function request (port, path) { return new Promise((resolve, reject) => { - var opts = { + const opts = { method: 'GET', port: port, path: path, @@ -72,8 +72,8 @@ function request (port, path) { } } - var req = http.request(opts, function (res) { - var chunks = [] + const req = http.request(opts, function (res) { + const chunks = [] res.on('error', reject) res.on('data', chunks.push.bind(chunks)) res.on('end', function () { @@ -98,7 +98,7 @@ function done (t, query) { t.strictEqual(span.name, 'foo', 'span name should be foo') t.strictEqual(span.type, 'bar', 'span name should be bar') - var offset = span.timestamp - trans.timestamp + const offset = span.timestamp - trans.timestamp t.ok(offset + span.duration * 1000 < trans.duration * 1000, 'span should have valid timings') }) diff --git a/test/instrumentation/modules/express/basic.test.js b/test/instrumentation/modules/express/basic.test.js index 96d9d916a7..df1ae86227 100644 --- a/test/instrumentation/modules/express/basic.test.js +++ b/test/instrumentation/modules/express/basic.test.js @@ -11,7 +11,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -var agent = require('../../../..').start({ +const agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: true, @@ -19,21 +19,21 @@ var agent = require('../../../..').start({ centralConfig: false }) -var http = require('http') +const http = require('http') -var express = require('express') -var test = require('tape') +const express = require('express') +const test = require('tape') -var mockClient = require('../../../_mock_http_client') +const mockClient = require('../../../_mock_http_client') -var nestedRouteTestCases = [ +const nestedRouteTestCases = [ [], // no nesting ['/', ''], ['/sub', '/sub'], ['/sub/:id', '/sub/42'] ] -var routeTestCases = [ +const routeTestCases = [ ['use', '/', 'GET', '/'], ['use', '/', 'POST', '/'], ['get', '/', 'GET', '/'], @@ -104,14 +104,14 @@ test('error intercept', function (t) { resetAgent(function (data) { t.strictEqual(data.transactions.length, 1, 'has a transaction') - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, 'GET /', 'transaction name is GET /') t.strictEqual(trans.type, 'request', 'transaction type is request') }) - var request - var error = new Error('wat') - var captureError = agent.captureError + let request + const error = new Error('wat') + const captureError = agent.captureError agent.captureError = function (err, data) { t.strictEqual(err, error, 'has the expected error') t.ok(data, 'captured data with error') @@ -121,7 +121,7 @@ test('error intercept', function (t) { agent.captureError = captureError }) - var app = express() + const app = express() app.set('env', 'production') app.get('/', function (req, res, next) { @@ -150,12 +150,12 @@ test('ignore 404 errors', function (t) { resetAgent(function (data) { t.strictEqual(data.transactions.length, 1, 'has a transaction') - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, 'GET unknown route', 'transaction name is GET unknown route') t.strictEqual(trans.type, 'request', 'transaction type is request') }) - var captureError = agent.captureError + const captureError = agent.captureError agent.captureError = function (_, data) { t.fail('it should not capture 404 errors') } @@ -163,7 +163,7 @@ test('ignore 404 errors', function (t) { agent.captureError = captureError }) - var app = express() + const app = express() app.set('env', 'production') app.use(function (req, res) { @@ -186,12 +186,12 @@ test('ignore invalid errors', function (t) { resetAgent(function (data) { t.strictEqual(data.transactions.length, 1, 'has a transaction') - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, 'GET /', 'transaction name is GET /') t.strictEqual(trans.type, 'request', 'transaction type is request') }) - var captureError = agent.captureError + const captureError = agent.captureError agent.captureError = function (_, data) { t.fail('should not capture invalid errors') } @@ -199,7 +199,7 @@ test('ignore invalid errors', function (t) { agent.captureError = captureError }) - var app = express() + const app = express() app.set('env', 'production') app.get('/', function (req, res, next) { @@ -226,12 +226,12 @@ test('do not inherit past route names', function (t) { resetAgent(function (data) { t.strictEqual(data.transactions.length, 1, 'has a transaction') - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, 'GET /', 'transaction name is GET /') t.strictEqual(trans.type, 'request', 'transaction type is request') }) - var captureError = agent.captureError + const captureError = agent.captureError agent.captureError = function (_, data) { t.fail('should not capture invalid errors') } @@ -239,7 +239,7 @@ test('do not inherit past route names', function (t) { agent.captureError = captureError }) - var app = express() + const app = express() app.set('env', 'production') app.get('/', function (req, res, next) { @@ -267,12 +267,12 @@ test('sub-routers include base path', function (t) { resetAgent(function (data) { t.strictEqual(data.transactions.length, 1, 'has a transaction') - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, 'GET /hello/:name', 'transaction name is GET /hello/:name') t.strictEqual(trans.type, 'request', 'transaction type is request') }) - var captureError = agent.captureError + const captureError = agent.captureError agent.captureError = function (_, data) { t.fail('should not capture invalid errors') } @@ -280,12 +280,12 @@ test('sub-routers include base path', function (t) { agent.captureError = captureError }) - var router = express.Router() + const router = express.Router() router.get('/:name', (req, res) => { res.end(`hello, ${req.params.name}`) }) - var app = express() + const app = express() app.set('env', 'production') app.use('/hello', router) @@ -305,24 +305,24 @@ test('sub-routers throw exception', function (t) { resetAgent(function (data) { t.strictEqual(data.transactions.length, 1, 'has a transaction') - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, 'GET /api/:name', 'transaction name is GET /api/:name') t.strictEqual(trans.type, 'request', 'transaction type is request') }) - var error = new Error('hello') - var captureError = agent.captureError + const error = new Error('hello') + const captureError = agent.captureError agent.captureError = function () {} t.on('end', function () { agent.captureError = captureError }) - var router = express.Router() + const router = express.Router() router.get('/:name', (req, res) => { throw error }) - var app = express() + const app = express() app.set('env', 'production') app.use('/api', router) @@ -340,23 +340,23 @@ test('sub-router handler calls next(exception)', function (t) { resetAgent(function (data) { t.strictEqual(data.transactions.length, 1, 'has a transaction') - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, 'GET /api/:name', 'transaction name is GET /api/:name') t.strictEqual(trans.type, 'request', 'transaction type is request') }) // Ignore captureError handling for this test. - var captureError = agent.captureError + const captureError = agent.captureError agent.captureError = function () {} t.on('end', function () { agent.captureError = captureError }) - var router = express.Router() + const router = express.Router() router.get('/:name', (_req, _res, next) => { next(new Error('boom')) }) - var app = express() + const app = express() app.set('env', 'production') app.use('/api', router) @@ -376,23 +376,23 @@ test('sub-router handler calls next(non-exception)', function (t) { resetAgent(function (data) { t.strictEqual(data.transactions.length, 1, 'has a transaction') - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, 'GET /api/:name', 'transaction name is GET /api/:name') t.strictEqual(trans.type, 'request', 'transaction type is request') }) // Ignore captureError handling for this test. - var captureError = agent.captureError + const captureError = agent.captureError agent.captureError = function () {} t.on('end', function () { agent.captureError = captureError }) - var router = express.Router() + const router = express.Router() router.get('/:name', (_req, _res, next) => { next('this is some truthy value that is not "route" or "router"') }) - var app = express() + const app = express() app.set('env', 'production') app.use('/api', router) @@ -410,26 +410,26 @@ test('sub-router handler calls next("route")', function (t) { resetAgent(function (data) { t.strictEqual(data.transactions.length, 1, 'has a transaction') - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, 'GET /api/other-endpoint', 'transaction name is GET /api/other-endpoint') t.strictEqual(trans.type, 'request', 'transaction type is request') }) // Ignore captureError handling for this test. - var captureError = agent.captureError + const captureError = agent.captureError agent.captureError = function () {} t.on('end', function () { agent.captureError = captureError }) - var router = express.Router() + const router = express.Router() router.get('/:name', (_req, _res, next) => { next('route') }) router.get('/other-endpoint', (_req, res) => { res.end('hi from other-endpoint') }) - var app = express() + const app = express() app.set('env', 'production') app.use('/api', router) @@ -488,8 +488,8 @@ function get (server, opts, cb) { Object.assign(opts, { port: server.address().port }) - var req = http.request(opts, function (res) { - var chunks = [] + const req = http.request(opts, function (res) { + const chunks = [] res.setEncoding('utf8') res.on('error', cb) res.on('data', chunks.push.bind(chunks)) diff --git a/test/instrumentation/modules/fastify/fastify.test.js b/test/instrumentation/modules/fastify/fastify.test.js index cc07c9a91d..6719113ddd 100644 --- a/test/instrumentation/modules/fastify/fastify.test.js +++ b/test/instrumentation/modules/fastify/fastify.test.js @@ -79,7 +79,7 @@ test('captureBody', function (t) { resetAgent(data => { t.strictEqual(data.transactions.length, 1) - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, 'POST /postSomeData', 'transaction.name') t.strictEqual(trans.type, 'request', 'transaction.type') t.strictEqual(trans.result, 'HTTP 2xx', 'transaction.result') diff --git a/test/instrumentation/modules/finalhandler.test.js b/test/instrumentation/modules/finalhandler.test.js index 41b8ff1786..77ed8c2db5 100644 --- a/test/instrumentation/modules/finalhandler.test.js +++ b/test/instrumentation/modules/finalhandler.test.js @@ -11,7 +11,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -var agent = require('../../..').start({ +const agent = require('../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: true, @@ -19,13 +19,13 @@ var agent = require('../../..').start({ centralConfig: false }) -var http = require('http') +const http = require('http') -var express = require('express') -var finalhandler = require('finalhandler') -var test = require('tape') +const express = require('express') +const finalhandler = require('finalhandler') +const test = require('tape') -var mockClient = require('../../_mock_http_client') +const mockClient = require('../../_mock_http_client') function makeTest (makeServer) { return function (t) { @@ -34,14 +34,14 @@ function makeTest (makeServer) { resetAgent(function (data) { t.strictEqual(data.transactions.length, 1, 'has a transaction') - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, 'GET /', 'transaction name is GET /') t.strictEqual(trans.type, 'request', 'transaction type is request') }) - var request - var error = new Error('wat') - var captureError = agent.captureError + let request + const error = new Error('wat') + const captureError = agent.captureError agent.captureError = function (err, data) { t.strictEqual(err, error, 'has the expected error') t.ok(data, 'captured data with error') @@ -51,12 +51,12 @@ function makeTest (makeServer) { agent.captureError = captureError }) - var server = makeServer(error, req => { + const server = makeServer(error, req => { request = req }) server.listen(function () { - var port = server.address().port + const port = server.address().port http.get(`http://localhost:${port}`, res => { t.strictEqual(res.statusCode, 500) res.resume() @@ -71,7 +71,7 @@ function makeTest (makeServer) { test('basic http', makeTest((error, setRequest) => { return http.createServer((req, res) => { - var done = finalhandler(req, res) + const done = finalhandler(req, res) agent.setTransactionName('GET /') setRequest(req) done(error) @@ -79,7 +79,7 @@ test('basic http', makeTest((error, setRequest) => { })) test('express done', makeTest((error, setRequest) => { - var app = express() + const app = express() app.get('/', (req, res, next) => { setRequest(req) @@ -90,7 +90,7 @@ test('express done', makeTest((error, setRequest) => { })) test('express throw', makeTest((error, setRequest) => { - var app = express() + const app = express() app.get('/', (req, res, next) => { setRequest(req) @@ -101,7 +101,7 @@ test('express throw', makeTest((error, setRequest) => { })) test('express with error handler', makeTest((error, setRequest) => { - var app = express() + const app = express() app.get('/', (req, res, next) => { setRequest(req) diff --git a/test/instrumentation/modules/generic-pool.test.js b/test/instrumentation/modules/generic-pool.test.js index 4e1377825e..abb6d6e222 100644 --- a/test/instrumentation/modules/generic-pool.test.js +++ b/test/instrumentation/modules/generic-pool.test.js @@ -11,7 +11,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -var agent = require('../../..').start({ +const agent = require('../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -19,18 +19,18 @@ var agent = require('../../..').start({ centralConfig: false }) -var genericPool = require('generic-pool') -var test = require('tape') +const genericPool = require('generic-pool') +const test = require('tape') -var ins = global.ins = agent._instrumentation +const ins = global.ins = agent._instrumentation if (genericPool.createPool) { test('v3.x', function (t) { - var active = 0 + let active = 0 - var pool = genericPool.createPool({ + const pool = genericPool.createPool({ create () { - var p = new Promise(function (resolve, reject) { + const p = new Promise(function (resolve, reject) { process.nextTick(function () { resolve({ id: ++active }) }) @@ -48,7 +48,7 @@ if (genericPool.createPool) { } }) - var t1 = ins.startTransaction() + const t1 = ins.startTransaction() pool.acquire().then(function (resource) { t.strictEqual(resource.id, 1) @@ -59,7 +59,7 @@ if (genericPool.createPool) { }) t.strictEqual(ins.currTransaction().id, t1.id) - var t2 = ins.startTransaction() + const t2 = ins.startTransaction() pool.acquire().then(function (resource) { t.strictEqual(resource.id, 1) @@ -79,9 +79,9 @@ if (genericPool.createPool) { }) } else { test('v2.x', function (t) { - var active = 0 + let active = 0 - var pool = new genericPool.Pool({ + const pool = new genericPool.Pool({ create (cb) { process.nextTick(function () { cb(null, { id: ++active }) @@ -92,7 +92,7 @@ if (genericPool.createPool) { } }) - var t1 = ins.startTransaction() + const t1 = ins.startTransaction() pool.acquire(function (err, resource) { t.error(err) @@ -102,7 +102,7 @@ if (genericPool.createPool) { }) t.strictEqual(ins.currTransaction().id, t1.id) - var t2 = ins.startTransaction() + const t2 = ins.startTransaction() pool.acquire(function (err, resource) { t.error(err) diff --git a/test/instrumentation/modules/graphql.test.js b/test/instrumentation/modules/graphql.test.js index 4163f0d126..045fa4f71f 100644 --- a/test/instrumentation/modules/graphql.test.js +++ b/test/instrumentation/modules/graphql.test.js @@ -11,7 +11,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -var agent = require('../../..').start({ +const agent = require('../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -26,10 +26,10 @@ if (semver.satisfies(graphqlVer, '>=16') && !semver.satisfies(process.version, ' process.exit() } -var graphql = require('graphql') -var test = require('tape') +const graphql = require('graphql') +const test = require('tape') -var mockClient = require('../../_mock_http_client') +const mockClient = require('../../_mock_http_client') // See explanation of these in "lib/instrumentation/modules/graphql.js". const onlySupportsPositionalArgs = semver.lt(graphqlVer, '0.10.0') @@ -40,13 +40,13 @@ if (!onlySupportsSingleArg) { test('graphql.graphql(...) - positional args', function (t) { resetAgent(done(t)) - var schema = graphql.buildSchema('type Query { hello: String }') - var rootValue = { + const schema = graphql.buildSchema('type Query { hello: String }') + const rootValue = { hello () { return 'Hello world!' } } - var query = '{ hello }' + const query = '{ hello }' agent.startTransaction('foo') @@ -64,13 +64,13 @@ if (!onlySupportsPositionalArgs) { test('graphql.graphql(...) - single GraphQLArgs arg', function (t) { resetAgent(done(t)) - var schema = graphql.buildSchema('type Query { hello: String }') - var rootValue = { + const schema = graphql.buildSchema('type Query { hello: String }') + const rootValue = { hello () { return 'Hello world!' } } - var query = '{ hello }' + const query = '{ hello }' agent.startTransaction('foo') @@ -87,13 +87,13 @@ if (!onlySupportsPositionalArgs) { test('graphql.graphql - invalid query', function (t) { resetAgent(done(t, 'Unknown Query')) - var schema = graphql.buildSchema('type Query { hello: String }') - var rootValue = { + const schema = graphql.buildSchema('type Query { hello: String }') + const rootValue = { hello () { return 'Hello world!' } } - var query = '{ hello' + const query = '{ hello' agent.startTransaction('foo') @@ -115,19 +115,19 @@ test('graphql.graphql - transaction ended', function (t) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 0) - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, 'foo') t.strictEqual(trans.type, 'custom') }) - var schema = graphql.buildSchema('type Query { hello: String }') - var rootValue = { + const schema = graphql.buildSchema('type Query { hello: String }') + const rootValue = { hello () { return 'Hello world!' } } - var query = '{ hello }' + const query = '{ hello }' agent.startTransaction('foo').end() @@ -143,15 +143,15 @@ if (!onlySupportsSingleArg) { test('graphql.execute(...) - positional args', function (t) { resetAgent(done(t)) - var schema = graphql.buildSchema('type Query { hello: String }') - var rootValue = { + const schema = graphql.buildSchema('type Query { hello: String }') + const rootValue = { hello () { return Promise.resolve('Hello world!') } } - var query = '{ hello }' - var source = new graphql.Source(query) - var documentAST = graphql.parse(source) + const query = '{ hello }' + const source = new graphql.Source(query) + const documentAST = graphql.parse(source) agent.startTransaction('foo') @@ -172,21 +172,21 @@ test('graphql.execute - transaction ended', function (t) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 0) - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, 'foo') t.strictEqual(trans.type, 'custom') }) - var schema = graphql.buildSchema('type Query { hello: String }') - var rootValue = { + const schema = graphql.buildSchema('type Query { hello: String }') + const rootValue = { hello () { return Promise.resolve('Hello world!') } } - var query = '{ hello }' - var source = new graphql.Source(query) - var document = graphql.parse(source) + const query = '{ hello }' + const source = new graphql.Source(query) + const document = graphql.parse(source) agent.startTransaction('foo').end() @@ -201,16 +201,16 @@ if (!onlySupportsPositionalArgs) { test('graphql.execute(...) - single ExecutionArgs arg', function (t) { resetAgent(done(t)) - var schema = graphql.buildSchema('type Query { hello: String }') - var rootValue = { + const schema = graphql.buildSchema('type Query { hello: String }') + const rootValue = { hello () { return Promise.resolve('Hello world!') } } - var query = '{ hello }' - var source = new graphql.Source(query) - var documentAST = graphql.parse(source) - var args = { + const query = '{ hello }' + const source = new graphql.Source(query) + const documentAST = graphql.parse(source) + const args = { schema: schema, document: documentAST, rootValue: rootValue @@ -232,19 +232,19 @@ if (semver.satisfies(graphqlVer, '>=0.12')) { test('graphql.execute sync', function (t) { resetAgent(done(t)) - var schema = graphql.buildSchema('type Query { hello: String }') - var rootValue = { + const schema = graphql.buildSchema('type Query { hello: String }') + const rootValue = { hello () { return 'Hello world!' } } - var query = '{ hello }' - var source = new graphql.Source(query) - var document = graphql.parse(source) + const query = '{ hello }' + const source = new graphql.Source(query) + const document = graphql.parse(source) agent.startTransaction('foo') - var response = graphql.execute(...buildExecuteArgs({ schema, document, rootValue })) + const response = graphql.execute(...buildExecuteArgs({ schema, document, rootValue })) t.ok(agent.currentSpan === null, 'no currentSpan in sync code after .execute(...)') agent.endTransaction() @@ -260,8 +260,8 @@ function done (t, spanNameSuffix) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 1) - var trans = data.transactions[0] - var span = data.spans[0] + const trans = data.transactions[0] + const span = data.spans[0] t.strictEqual(trans.name, 'foo') t.strictEqual(trans.type, 'custom') @@ -270,7 +270,7 @@ function done (t, spanNameSuffix) { t.strictEqual(span.subtype, 'graphql') t.strictEqual(span.action, 'execute') - var offset = span.timestamp - trans.timestamp + const offset = span.timestamp - trans.timestamp t.ok(offset + span.duration * 1000 < trans.duration * 1000) t.end() diff --git a/test/instrumentation/modules/handlebars.test.js b/test/instrumentation/modules/handlebars.test.js index 55e566d72e..4c4b73ca1c 100644 --- a/test/instrumentation/modules/handlebars.test.js +++ b/test/instrumentation/modules/handlebars.test.js @@ -13,7 +13,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.env.ELASTIC_APM_TEST = true -var agent = require('../../..').start({ +const agent = require('../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -22,18 +22,18 @@ var agent = require('../../..').start({ spanStackTraceMinDuration: 0 // Always have span stacktraces. }) -var handlebars = require('handlebars') -var test = require('tape') +const handlebars = require('handlebars') +const test = require('tape') -var mockClient = require('../../_mock_http_client') -var findObjInArray = require('../../_utils').findObjInArray +const mockClient = require('../../_mock_http_client') +const findObjInArray = require('../../_utils').findObjInArray test('handlebars compile and render', function userLandCode (t) { resetAgent(function (data) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 2) - var trans = data.transactions[0] + const trans = data.transactions[0] t.ok(/^foo\d$/.test(trans.name)) t.strictEqual(trans.type, 'custom') @@ -55,7 +55,7 @@ test('handlebars compile and render', function userLandCode (t) { agent.startTransaction('foo1') - var template = handlebars.compile('Hello, {{name}}!') + const template = handlebars.compile('Hello, {{name}}!') template({ name: 'world' }) agent.endTransaction() diff --git a/test/instrumentation/modules/hapi/set-framework-hapihapi.test.js b/test/instrumentation/modules/hapi/set-framework-hapihapi.test.js index a16d6b2c0e..a361aca72f 100644 --- a/test/instrumentation/modules/hapi/set-framework-hapihapi.test.js +++ b/test/instrumentation/modules/hapi/set-framework-hapihapi.test.js @@ -11,7 +11,7 @@ const agent = require('../../../..').start({ metricsInterval: 0 }) -var isHapiIncompat = require('../../../_is_hapi_incompat') +const isHapiIncompat = require('../../../_is_hapi_incompat') if (isHapiIncompat('@hapi/hapi')) { // Skip out of this test. console.log(`# SKIP this version of '@hapi/hapi' is incompatible with node ${process.version}`) diff --git a/test/instrumentation/modules/hapi/shared.js b/test/instrumentation/modules/hapi/shared.js index 24323fbee5..aae117ecc2 100644 --- a/test/instrumentation/modules/hapi/shared.js +++ b/test/instrumentation/modules/hapi/shared.js @@ -7,7 +7,7 @@ 'use strict' module.exports = (moduleName) => { - var agent = require('../../../..').start({ + const agent = require('../../../..').start({ serviceName: 'test-hapi', captureExceptions: false, logLevel: 'off', @@ -17,23 +17,23 @@ module.exports = (moduleName) => { captureBody: 'all' }) - var isHapiIncompat = require('../../../_is_hapi_incompat') + const isHapiIncompat = require('../../../_is_hapi_incompat') if (isHapiIncompat(moduleName)) { // Skip out of this test. console.log(`# SKIP this version of ${moduleName} is incompatible with node ${process.version}`) process.exit() } - var http = require('http') + const http = require('http') - var Hapi = require(moduleName) - var pkg = require(moduleName + '/package.json') - var semver = require('semver') - var test = require('tape') + const Hapi = require(moduleName) + const pkg = require(moduleName + '/package.json') + const semver = require('semver') + const test = require('tape') - var mockClient = require('../../../_mock_http_client') + const mockClient = require('../../../_mock_http_client') - var originalCaptureError = agent.captureError + const originalCaptureError = agent.captureError function noop () {} @@ -41,7 +41,7 @@ module.exports = (moduleName) => { resetAgent(2, function (data) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.errors.length, 1) - var request = data.errors[0].context.request + const request = data.errors[0].context.request t.strictEqual(request.method, 'GET') t.strictEqual(request.url.pathname, '/captureError') t.strictEqual(request.url.search, '?foo=bar') @@ -133,7 +133,7 @@ module.exports = (moduleName) => { resetAgent() - var server = makeServer() + const server = makeServer() initServer(server, function (err) { server.stop(noop) t.error(err, 'start error') @@ -149,7 +149,7 @@ module.exports = (moduleName) => { t.plan(6) - var customError = new Error('custom error') + const customError = new Error('custom error') resetAgent() @@ -180,7 +180,7 @@ module.exports = (moduleName) => { t.plan(6) - var customError = 'custom error' + const customError = 'custom error' resetAgent() @@ -211,7 +211,7 @@ module.exports = (moduleName) => { t.plan(6) - var customError = { + const customError = { error: 'I forgot to turn this into an actual Error' } @@ -238,7 +238,7 @@ module.exports = (moduleName) => { test('server error logging with Error', function (t) { t.plan(6) - var customError = new Error('custom error') + const customError = new Error('custom error') resetAgent() @@ -262,7 +262,7 @@ module.exports = (moduleName) => { test('server error logging with Error does not affect event tags', function (t) { t.plan(8) - var customError = new Error('custom error') + const customError = new Error('custom error') resetAgent() @@ -278,7 +278,7 @@ module.exports = (moduleName) => { var server = makeServer() - var emitter = server.events || server + const emitter = server.events || server emitter.on('log', function (event, tags) { t.deepEqual(event.tags, ['error']) }) @@ -297,7 +297,7 @@ module.exports = (moduleName) => { test('server error logging with String', function (t) { t.plan(6) - var customError = 'custom error' + const customError = 'custom error' resetAgent() @@ -321,7 +321,7 @@ module.exports = (moduleName) => { test('server error logging with Object', function (t) { t.plan(6) - var customError = { + const customError = { error: 'I forgot to turn this into an actual Error' } @@ -347,7 +347,7 @@ module.exports = (moduleName) => { test('request error logging with Error', function (t) { t.plan(13) - var customError = new Error('custom error') + const customError = new Error('custom error') resetAgent(1, function (data) { assert(t, data, { status: 'HTTP 2xx', name: 'GET /error' }) @@ -392,7 +392,7 @@ module.exports = (moduleName) => { test('request error logging with Error does not affect event tags', function (t) { t.plan(15) - var customError = new Error('custom error') + const customError = new Error('custom error') resetAgent(1, function (data) { assert(t, data, { status: 'HTTP 2xx', name: 'GET /error' }) @@ -421,7 +421,7 @@ module.exports = (moduleName) => { }) }) - var emitter = server.events || server + const emitter = server.events || server emitter.on('request', function (req, event, tags) { if (event.channel === 'internal') return t.deepEqual(event.tags, ['elastic-apm', 'error']) @@ -448,7 +448,7 @@ module.exports = (moduleName) => { test('request error logging with String', function (t) { t.plan(13) - var customError = 'custom error' + const customError = 'custom error' resetAgent(1, function (data) { assert(t, data, { status: 'HTTP 2xx', name: 'GET /error' }) @@ -493,7 +493,7 @@ module.exports = (moduleName) => { test('request error logging with Object', function (t) { t.plan(13) - var customError = { + const customError = { error: 'I forgot to turn this into an actual Error' } @@ -555,7 +555,7 @@ module.exports = (moduleName) => { http.get('http://localhost:' + port + '/error', function (res) { t.strictEqual(res.statusCode, 500) res.on('data', function (chunk) { - var data = JSON.parse(chunk.toString()) + const data = JSON.parse(chunk.toString()) t.deepEqual(data, { statusCode: 500, error: 'Internal Server Error', @@ -572,7 +572,7 @@ module.exports = (moduleName) => { function makeServer (opts) { // Specify 'localhost' to avoid Hapi default of '0.0.0.0' which ties to // IPv4. We want a later HTTP client request using 'localhost' to work. - var server + let server if (semver.satisfies(pkg.version, '<17')) { server = new Hapi.Server() opts = opts || {} @@ -610,7 +610,7 @@ module.exports = (moduleName) => { } function startServer (cb) { - var server = buildServer() + const server = buildServer() runServer(server, cb) return server } @@ -618,7 +618,7 @@ module.exports = (moduleName) => { function handler (fn) { if (semver.satisfies(pkg.version, '>=17')) return fn return function (request, reply) { - var p = new Promise(function (resolve, reject) { + const p = new Promise(function (resolve, reject) { resolve(fn(request)) }) p.then(reply, reply) @@ -626,7 +626,7 @@ module.exports = (moduleName) => { } function buildServer () { - var server = makeServer() + const server = makeServer() server.route({ method: 'GET', @@ -668,7 +668,7 @@ module.exports = (moduleName) => { t.strictEqual(data.transactions.length, 1) - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, results.name) t.strictEqual(trans.type, 'request') diff --git a/test/instrumentation/modules/http/_assert.js b/test/instrumentation/modules/http/_assert.js index cfe7d05373..b1c0f7e751 100644 --- a/test/instrumentation/modules/http/_assert.js +++ b/test/instrumentation/modules/http/_assert.js @@ -12,7 +12,7 @@ function assert (t, data) { t.strictEqual(data.transactions.length, 1, 'should have one transaction') t.strictEqual(data.spans.length, 0, 'should have zero spans') - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, 'GET unknown route', 'should have expected transaction name') t.strictEqual(trans.type, 'request', 'should have expected transaction type') diff --git a/test/instrumentation/modules/http/_echo_server.js b/test/instrumentation/modules/http/_echo_server.js index aeaec537ce..de4104a389 100644 --- a/test/instrumentation/modules/http/_echo_server.js +++ b/test/instrumentation/modules/http/_echo_server.js @@ -6,20 +6,20 @@ 'use strict' -var http = require('http') -var https = require('https') -var zlib = require('zlib') +const http = require('http') +const https = require('https') +const zlib = require('zlib') -var pem = require('https-pem') +const pem = require('https-pem') process.title = 'echo-server' -var server = process.argv[2] === 'https' +const server = process.argv[2] === 'https' ? https.createServer(pem) : http.createServer() server.on('request', function (req, res) { - var acceptEncoding = req.headers['accept-encoding'] || '' + const acceptEncoding = req.headers['accept-encoding'] || '' if (/\bdeflate\b/.test(acceptEncoding)) { res.writeHead(200, { 'Content-Encoding': 'deflate' }) diff --git a/test/instrumentation/modules/http/_echo_server_util.js b/test/instrumentation/modules/http/_echo_server_util.js index 5fd9290d24..1ed259d3ed 100644 --- a/test/instrumentation/modules/http/_echo_server_util.js +++ b/test/instrumentation/modules/http/_echo_server_util.js @@ -6,18 +6,18 @@ 'use strict' -var exec = require('child_process').exec -var path = require('path') +const exec = require('child_process').exec +const path = require('path') exports.echoServer = echoServer function echoServer (type, cb) { if (typeof type === 'function') return echoServer('http', type) - var script = path.join(__dirname, '_echo_server.js') - var cp = exec(`node "${script}" ${type}`) + const script = path.join(__dirname, '_echo_server.js') + const cp = exec(`node "${script}" ${type}`) cp.stderr.pipe(process.stderr) cp.stdout.once('data', function (chunk) { - var port = chunk.trim().split('\n')[0] + const port = chunk.trim().split('\n')[0] cb(cp, port) }) } diff --git a/test/instrumentation/modules/http/aborted-requests-disabled.test.js b/test/instrumentation/modules/http/aborted-requests-disabled.test.js index a1bd167242..c9962334db 100644 --- a/test/instrumentation/modules/http/aborted-requests-disabled.test.js +++ b/test/instrumentation/modules/http/aborted-requests-disabled.test.js @@ -18,15 +18,15 @@ const agent = require('../../../..').start({ errorOnAbortedRequests: false }) -var http = require('http') +const http = require('http') -var test = require('tape') +const test = require('tape') -var mockClient = require('../../../_mock_http_client') +const mockClient = require('../../../_mock_http_client') test('client-side abort - call end', function (t) { resetAgent() - var clientReq + let clientReq t.strictEqual(agent._apmClient._writes.length, 0, 'should not have any samples to begin with') @@ -62,7 +62,7 @@ test('client-side abort - call end', function (t) { }) server.listen(function () { - var port = server.address().port + const port = server.address().port clientReq = http.get('http://localhost:' + port, function (res) { t.fail('should not call http.get callback') }) @@ -74,7 +74,7 @@ test('client-side abort - call end', function (t) { test('client-side abort - don\'t call end', function (t) { resetAgent() - var clientReq + let clientReq t.strictEqual(agent._apmClient._writes.length, 0, 'should not have any samples to begin with') @@ -94,7 +94,7 @@ test('client-side abort - don\'t call end', function (t) { }) server.listen(function () { - var port = server.address().port + const port = server.address().port clientReq = http.get('http://localhost:' + port, function (res) { t.fail('should not call http.get callback') }) @@ -106,8 +106,8 @@ test('client-side abort - don\'t call end', function (t) { test('server-side abort - call end', function (t) { resetAgent() - var timedout = false - var closeEvent = false + let timedout = false + let closeEvent = false t.strictEqual(agent._apmClient._writes.length, 0, 'should not have any samples to begin with') @@ -132,8 +132,8 @@ test('server-side abort - call end', function (t) { server.setTimeout(100) server.listen(function () { - var port = server.address().port - var clientReq = http.get('http://localhost:' + port, function (res) { + const port = server.address().port + const clientReq = http.get('http://localhost:' + port, function (res) { t.fail('should not call http.get callback') }) clientReq.on('error', function (err) { @@ -145,8 +145,8 @@ test('server-side abort - call end', function (t) { test('server-side abort - don\'t call end', function (t) { resetAgent() - var timedout = false - var closeEvent = false + let timedout = false + let closeEvent = false t.strictEqual(agent._apmClient._writes.length, 0, 'should not have any samples to begin with') @@ -167,8 +167,8 @@ test('server-side abort - don\'t call end', function (t) { server.setTimeout(100) server.listen(function () { - var port = server.address().port - var clientReq = http.get('http://localhost:' + port, function (res) { + const port = server.address().port + const clientReq = http.get('http://localhost:' + port, function (res) { t.fail('should not call http.get callback') }) clientReq.on('error', function (err) { diff --git a/test/instrumentation/modules/http/aborted-requests-enabled.test.js b/test/instrumentation/modules/http/aborted-requests-enabled.test.js index f0ca18a553..a29fe86f35 100644 --- a/test/instrumentation/modules/http/aborted-requests-enabled.test.js +++ b/test/instrumentation/modules/http/aborted-requests-enabled.test.js @@ -19,17 +19,17 @@ const agent = require('../../../..').start({ errorOnAbortedRequests: true }) -var http = require('http') +const http = require('http') -var test = require('tape') +const test = require('tape') -var assert = require('./_assert') -var mockClient = require('../../../_mock_http_client') +const assert = require('./_assert') +const mockClient = require('../../../_mock_http_client') -var addEndedTransaction = agent._instrumentation.addEndedTransaction +const addEndedTransaction = agent._instrumentation.addEndedTransaction test('client-side abort below error threshold - call end', { timeout: 10000 }, function (t) { - var clientReq + let clientReq t.plan(9) t.on('end', function () { @@ -81,7 +81,7 @@ test('client-side abort below error threshold - call end', { timeout: 10000 }, f }) server.listen(function () { - var port = server.address().port + const port = server.address().port clientReq = get('http://localhost:' + port, function (res) { t.fail('should not call http.get callback') }) @@ -92,7 +92,7 @@ test('client-side abort below error threshold - call end', { timeout: 10000 }, f }) test('client-side abort above error threshold - call end', function (t) { - var clientReq + let clientReq t.plan(10) resetAgent(function (data) { @@ -126,7 +126,7 @@ test('client-side abort above error threshold - call end', function (t) { }) server.listen(function () { - var port = server.address().port + const port = server.address().port clientReq = get('http://localhost:' + port, function (res) { t.fail('should not call http.get callback') }) @@ -137,7 +137,7 @@ test('client-side abort above error threshold - call end', function (t) { }) test('client-side abort below error threshold - don\'t call end', function (t) { - var clientReq + let clientReq resetAgent(function () { t.fail('should not send any data') }) @@ -165,7 +165,7 @@ test('client-side abort below error threshold - don\'t call end', function (t) { }) server.listen(function () { - var port = server.address().port + const port = server.address().port clientReq = get('http://localhost:' + port, function (res) { t.fail('should not call http.get callback') }) @@ -176,7 +176,7 @@ test('client-side abort below error threshold - don\'t call end', function (t) { }) test('client-side abort above error threshold - don\'t call end', function (t) { - var clientReq + let clientReq resetAgent(function () { t.fail('should not send any data') }) @@ -203,7 +203,7 @@ test('client-side abort above error threshold - don\'t call end', function (t) { }) server.listen(function () { - var port = server.address().port + const port = server.address().port clientReq = get('http://localhost:' + port, function (res) { t.fail('should not call http.get callback') }) @@ -214,8 +214,8 @@ test('client-side abort above error threshold - don\'t call end', function (t) { }) test('server-side abort below error threshold and socket closed - call end', function (t) { - var timedout = false - var ended = false + let timedout = false + let ended = false t.plan(11) resetAgent(assert.bind(null, t)) @@ -245,8 +245,8 @@ test('server-side abort below error threshold and socket closed - call end', fun server.setTimeout((agent._conf.abortedErrorThreshold * 1000) / 2) server.listen(function () { - var port = server.address().port - var clientReq = get('http://localhost:' + port, function (res) { + const port = server.address().port + const clientReq = get('http://localhost:' + port, function (res) { t.fail('should not call http.get callback') }) clientReq.on('error', function (err) { @@ -257,8 +257,8 @@ test('server-side abort below error threshold and socket closed - call end', fun }) test('server-side abort above error threshold and socket closed - call end', function (t) { - var timedout = false - var ended = false + let timedout = false + let ended = false t.plan(13) resetAgent(assert.bind(null, t)) @@ -289,8 +289,8 @@ test('server-side abort above error threshold and socket closed - call end', fun server.setTimeout((agent._conf.abortedErrorThreshold * 1000) + 10) server.listen(function () { - var port = server.address().port - var clientReq = get('http://localhost:' + port, function (res) { + const port = server.address().port + const clientReq = get('http://localhost:' + port, function (res) { t.fail('should not call http.get callback') }) clientReq.on('error', function (err) { @@ -301,8 +301,8 @@ test('server-side abort above error threshold and socket closed - call end', fun }) test('server-side abort below error threshold and socket closed - don\'t call end', function (t) { - var timedout = false - var ended = false + let timedout = false + const ended = false t.plan(3) resetAgent(function () { @@ -329,8 +329,8 @@ test('server-side abort below error threshold and socket closed - don\'t call en server.setTimeout((agent._conf.abortedErrorThreshold * 1000) / 2) server.listen(function () { - var port = server.address().port - var clientReq = get('http://localhost:' + port, function (res) { + const port = server.address().port + const clientReq = get('http://localhost:' + port, function (res) { t.fail('should not call http.get callback') }) clientReq.on('error', function (err) { @@ -341,8 +341,8 @@ test('server-side abort below error threshold and socket closed - don\'t call en }) test('server-side abort above error threshold and socket closed - don\'t call end', function (t) { - var timedout = false - var ended = false + let timedout = false + const ended = false t.plan(5) resetAgent(function () { @@ -370,8 +370,8 @@ test('server-side abort above error threshold and socket closed - don\'t call en server.setTimeout((agent._conf.abortedErrorThreshold * 1000) + 50) server.listen(function () { - var port = server.address().port - var clientReq = get('http://localhost:' + port, function (res) { + const port = server.address().port + const clientReq = get('http://localhost:' + port, function (res) { t.fail('should not call http.get callback') }) clientReq.on('error', function (err) { @@ -409,7 +409,7 @@ test('server-side abort below error threshold but socket not closed - call end', server.setTimeout((agent._conf.abortedErrorThreshold * 1000) / 2) server.listen(function () { - var port = server.address().port + const port = server.address().port get('http://localhost:' + port, function (res) { res.on('end', function () { t.strictEqual(agent._apmClient._writes.length, 1, 'should send transactions') @@ -447,7 +447,7 @@ test('server-side abort above error threshold but socket not closed - call end', server.setTimeout((agent._conf.abortedErrorThreshold * 1000) + 10) server.listen(function () { - var port = server.address().port + const port = server.address().port get('http://localhost:' + port, function (res) { res.on('end', function () { t.strictEqual(agent._apmClient._writes.length, 1, 'should send transactions') diff --git a/test/instrumentation/modules/http/basic.test.js b/test/instrumentation/modules/http/basic.test.js index 1ab6ba8e34..f198560b49 100644 --- a/test/instrumentation/modules/http/basic.test.js +++ b/test/instrumentation/modules/http/basic.test.js @@ -16,13 +16,13 @@ const agent = require('../../../..').start({ spanStackTraceMinDuration: 0 // Always have span stacktraces. }) -var http = require('http') +const http = require('http') -var test = require('tape') +const test = require('tape') -var assert = require('./_assert') -var mockClient = require('../../../_mock_http_client') -var { TraceParent } = require('../../../../lib/tracecontext/traceparent') +const assert = require('./_assert') +const mockClient = require('../../../_mock_http_client') +const { TraceParent } = require('../../../../lib/tracecontext/traceparent') test('http.createServer', function (t) { t.test('direct callback', function (t) { @@ -112,8 +112,8 @@ test('new http.Server', function (t) { function sendRequest (server, timeout, useElasticHeader) { server.listen(function () { - var port = server.address().port - var context = TraceParent.startOrResume(null, { + const port = server.address().port + const context = TraceParent.startOrResume(null, { transactionSampleRate: 1.0 }) @@ -125,7 +125,7 @@ function sendRequest (server, timeout, useElasticHeader) { headers.traceparent = contextValue } - var req = http.request({ + const req = http.request({ hostname: 'localhost', port: port, path: '/', @@ -147,9 +147,9 @@ function sendRequest (server, timeout, useElasticHeader) { function onRequest (t, useElasticHeader) { return function onRequestHandler (req, res) { - var traceparent = useElasticHeader ? req.headers['elastic-apm-traceparent'] : req.headers.traceparent - var parent = TraceParent.fromString(traceparent) - var traceContext = agent.currentTransaction._context + const traceparent = useElasticHeader ? req.headers['elastic-apm-traceparent'] : req.headers.traceparent + const parent = TraceParent.fromString(traceparent) + const traceContext = agent.currentTransaction._context t.strictEqual(parent.traceId, traceContext.traceparent.traceId, 'traceContext trace id matches parent trace id') t.notEqual(parent.id, traceContext.traceparent.id, 'traceContext id does not match parent id') t.strictEqual(parent.flags, traceContext.traceparent.flags, 'traceContext flags matches parent flags') diff --git a/test/instrumentation/modules/http/bind-write-head-to-transaction.test.js b/test/instrumentation/modules/http/bind-write-head-to-transaction.test.js index 9160b04658..0c5d952fbb 100644 --- a/test/instrumentation/modules/http/bind-write-head-to-transaction.test.js +++ b/test/instrumentation/modules/http/bind-write-head-to-transaction.test.js @@ -16,29 +16,29 @@ const agent = require('../../../..').start({ spanStackTraceMinDuration: 0 // Always have span stacktraces. }) -var http = require('http') +const http = require('http') -var test = require('tape') +const test = require('tape') -var mockClient = require('../../../_mock_http_client') +const mockClient = require('../../../_mock_http_client') test('response writeHead is bound to transaction', function (t) { resetAgent(data => { t.strictEqual(data.transactions.length, 1, 'has a transaction') - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.result, 'HTTP 2xx', 'has correct result') t.end() }) - var server = http.createServer(function (req, res) { + const server = http.createServer(function (req, res) { agent._instrumentation.supersedeWithEmptyRunContext() res.end() }) server.listen(function () { - var port = server.address().port + const port = server.address().port http.get(`http://localhost:${port}`, function (res) { res.resume() res.on('end', () => { diff --git a/test/instrumentation/modules/http/github-179.test.js b/test/instrumentation/modules/http/github-179.test.js index 05f69c55e5..a148f9b19b 100644 --- a/test/instrumentation/modules/http/github-179.test.js +++ b/test/instrumentation/modules/http/github-179.test.js @@ -6,35 +6,35 @@ 'use strict' -var agent = require('../../../..').start({ +const agent = require('../../../..').start({ serviceName: 'test', captureExceptions: false, metricsInterval: 0, centralConfig: false }) -var zlib = require('zlib') -var http = require('http') -var PassThrough = require('stream').PassThrough +const zlib = require('zlib') +const http = require('http') +const PassThrough = require('stream').PassThrough -var mimicResponse = require('mimic-response') -var test = require('tape') +const mimicResponse = require('mimic-response') +const test = require('tape') -var echoServer = require('./_echo_server_util').echoServer +const echoServer = require('./_echo_server_util').echoServer test('https://github.com/opbeat/opbeat-node/issues/179', function (t) { echoServer(function (cp, port) { - var opts = { + const opts = { port: port, headers: { 'Accept-Encoding': 'gzip' } } agent.startTransaction() - var req = http.request(opts, function (res) { + const req = http.request(opts, function (res) { process.nextTick(function () { - var unzip = zlib.createUnzip() - var stream = new PassThrough() + const unzip = zlib.createUnzip() + const stream = new PassThrough() // This would previously copy res.emit to the stream object which // shouldn't happen since res.emit is supposed to be on the res.prototype diff --git a/test/instrumentation/modules/http/github-423.test.js b/test/instrumentation/modules/http/github-423.test.js index e74e2fe50f..c31aee7d79 100644 --- a/test/instrumentation/modules/http/github-423.test.js +++ b/test/instrumentation/modules/http/github-423.test.js @@ -13,8 +13,8 @@ require('../../../..').start({ centralConfig: false }) -var gotVer = require('got/package.json').version -var semver = require('semver') +const gotVer = require('got/package.json').version +const semver = require('semver') if (semver.gte(gotVer, '10.0.0') && semver.lt(process.version, '10.16.0')) { // got@10 requires node v10 for JS syntax, and v10.16.0 for the added // zlib.brotliCompress. @@ -30,28 +30,28 @@ if (semver.gte(gotVer, '11.0.0') && semver.satisfies(process.version, '>=14.0.0 process.exit() } -var http = require('http') -var zlib = require('zlib') -var fs = require('fs') +const http = require('http') +const zlib = require('zlib') +const fs = require('fs') -var got = require('got') -var test = require('tape') +const got = require('got') +const test = require('tape') -var fileSize = fs.readFileSync(__filename, 'utf8').length +const fileSize = fs.readFileSync(__filename, 'utf8').length test('https://github.com/elastic/apm-agent-nodejs/issues/423', function (t) { // Start dummy remote server to fetch gzip'ed data from - var remote = http.createServer(function (req, res) { + const remote = http.createServer(function (req, res) { res.setHeader('Content-Encoding', 'gzip') fs.createReadStream(__filename).pipe(zlib.createGzip()).pipe(res) }) remote.listen(function () { - var port = remote.address().port - var url = 'http://localhost:' + port + const port = remote.address().port + const url = 'http://localhost:' + port // Start simple server that performs got-request on every request - var server = http.createServer(function (req, res) { + const server = http.createServer(function (req, res) { got(url).then(function (response) { t.strictEqual(response.body.length, fileSize, 'body should be expected size') t.ok(response.body.includes('Copyright Elasticsearch'), 'body should be uncompressed') @@ -60,8 +60,8 @@ test('https://github.com/elastic/apm-agent-nodejs/issues/423', function (t) { }) server.listen(function () { - var port = server.address().port - var url = 'http://localhost:' + port + const port = server.address().port + const url = 'http://localhost:' + port http.get(url, function (res) { res.resume() diff --git a/test/instrumentation/modules/http/ignore-url-does-not-leak-trans.test.js b/test/instrumentation/modules/http/ignore-url-does-not-leak-trans.test.js index 6d11ac6c1a..406c9b8c50 100644 --- a/test/instrumentation/modules/http/ignore-url-does-not-leak-trans.test.js +++ b/test/instrumentation/modules/http/ignore-url-does-not-leak-trans.test.js @@ -47,15 +47,15 @@ if (Number(process.versions.node.split('.')[0]) <= 8 && process.exit() } -var http = require('http') -var test = require('tape') +const http = require('http') +const test = require('tape') test('an ignored incoming http URL does not leak previous transaction', function (t) { // Start an outer transaction that should not "leak" into the server handler // for ignored URLs. - var prevTrans = apm.startTransaction('prevTrans') + const prevTrans = apm.startTransaction('prevTrans') - var server = http.createServer(function (req, res) { + const server = http.createServer(function (req, res) { t.equal(apm.currentTransaction, null, 'current transaction in ignored URL handler is null') const span = apm.startSpan('aSpan') t.ok(span === null, 'no spans are created in ignored URL handler') @@ -66,7 +66,7 @@ test('an ignored incoming http URL does not leak previous transaction', function }) server.listen(function onListen () { - var opts = { + const opts = { port: server.address().port, path: '/ignore-this-path' } diff --git a/test/instrumentation/modules/http/ignoring.test.js b/test/instrumentation/modules/http/ignoring.test.js index ebd1567fae..7277b31e71 100644 --- a/test/instrumentation/modules/http/ignoring.test.js +++ b/test/instrumentation/modules/http/ignoring.test.js @@ -16,11 +16,11 @@ const agent = require('../../../..').start({ spanStackTraceMinDuration: 0 // Always have span stacktraces. }) -var http = require('http') +const http = require('http') -var test = require('tape') +const test = require('tape') -var mockClient = require('../../../_mock_http_client') +const mockClient = require('../../../_mock_http_client') const { WildcardMatcher } = require('../../../../lib/wildcard-matcher') @@ -137,12 +137,12 @@ function assertNoMatch (t, data) { } function request (path, headers, cb) { - var server = http.createServer(function (req, res) { + const server = http.createServer(function (req, res) { res.end() }) server.listen(function () { - var opts = { + const opts = { port: server.address().port, path: path, headers: headers diff --git a/test/instrumentation/modules/http/node-prefixed-http-require.test.js b/test/instrumentation/modules/http/node-prefixed-http-require.test.js index dd8ba3ef1e..3073b1e81b 100644 --- a/test/instrumentation/modules/http/node-prefixed-http-require.test.js +++ b/test/instrumentation/modules/http/node-prefixed-http-require.test.js @@ -33,7 +33,7 @@ const test = require('tape') const { findObjInArray } = require('../../../_utils') test('node:http instrumentation works', function (t) { - var server = http.createServer(function (req, res) { + const server = http.createServer(function (req, res) { res.end('pong') }) diff --git a/test/instrumentation/modules/http/outgoing.test.js b/test/instrumentation/modules/http/outgoing.test.js index 1c8273535c..9ff46bf442 100644 --- a/test/instrumentation/modules/http/outgoing.test.js +++ b/test/instrumentation/modules/http/outgoing.test.js @@ -16,38 +16,38 @@ const agent = require('../../../..').start({ spanStackTraceMinDuration: 0 // Always have span stacktraces. }) -var http = require('http') -var https = require('https') +const http = require('http') +const https = require('https') const { URL } = require('url') -var endOfStream = require('end-of-stream') -var semver = require('semver') -var test = require('tape') +const endOfStream = require('end-of-stream') +const semver = require('semver') +const test = require('tape') -var echoServer = require('./_echo_server_util').echoServer -var mockClient = require('../../../_mock_http_client') -var { TraceParent } = require('../../../../lib/tracecontext/traceparent') +const echoServer = require('./_echo_server_util').echoServer +const mockClient = require('../../../_mock_http_client') +const { TraceParent } = require('../../../../lib/tracecontext/traceparent') -var methods = ['request', 'get'] +const methods = ['request', 'get'] const nodeHttpRequestSupportsSeparateUrlArg = semver.gte(process.version, '10.9.0') // // http // test('http.request(options)', echoTest('http', {}, (port, cb) => { - var options = { port } - var req = http.request(options) + const options = { port } + const req = http.request(options) req.on('response', cb) return req })) test('http.request(options, callback)', echoTest('http', {}, (port, cb) => { - var options = { port } + const options = { port } return http.request(options, cb) })) test('http: consider useElasticTraceparentHeader config option', echoTest('http', { useElasticTraceparentHeader: false }, (port, cb) => { - var options = { port } + const options = { port } return http.request(options, cb) })) @@ -87,28 +87,28 @@ test('http.request(options, callback) - aborted on data', abortTest('http', (por methods.forEach(function (name) { test(`http.${name}(urlString)`, echoTest('http', {}, (port, cb) => { - var urlString = `http://localhost:${port}` - var req = http[name](urlString) + const urlString = `http://localhost:${port}` + const req = http[name](urlString) req.on('response', cb) return req })) test(`http.${name}(urlString, callback)`, echoTest('http', {}, (port, cb) => { - var urlString = `http://localhost:${port}` + const urlString = `http://localhost:${port}` return http[name](urlString, cb) })) test(`http.${name}(urlObject)`, echoTest('http', {}, (port, cb) => { - var urlString = `http://localhost:${port}` - var urlObject = new URL(urlString) - var req = http[name](urlObject) + const urlString = `http://localhost:${port}` + const urlObject = new URL(urlString) + const req = http[name](urlObject) req.on('response', cb) return req })) test(`http.${name}(urlObject, callback)`, echoTest('http', {}, (port, cb) => { - var urlString = `http://localhost:${port}` - var urlObject = new URL(urlString) + const urlString = `http://localhost:${port}` + const urlObject = new URL(urlString) return http[name](urlObject, cb) })) }) @@ -192,51 +192,51 @@ test('http.request(..., bogusCb) errors on the bogusCb', { timeout: 5000 }, t => // https // test('https.request(options)', echoTest('https', {}, (port, cb) => { - var options = { port, rejectUnauthorized: false } - var req = https.request(options) + const options = { port, rejectUnauthorized: false } + const req = https.request(options) req.on('response', cb) return req })) test('https.request(options, callback)', echoTest('https', {}, (port, cb) => { - var options = { port, rejectUnauthorized: false } + const options = { port, rejectUnauthorized: false } return https.request(options, cb) })) test('https: consider useElasticTraceparentHeader config option', echoTest('https', { useElasticTraceparentHeader: false }, (port, cb) => { - var options = { port, rejectUnauthorized: false } + const options = { port, rejectUnauthorized: false } return https.request(options, cb) })) methods.forEach(function (name) { if (nodeHttpRequestSupportsSeparateUrlArg) { test(`https.${name}(urlString, options)`, echoTest('https', {}, (port, cb) => { - var urlString = `https://localhost:${port}` - var options = { rejectUnauthorized: false } - var req = https[name](urlString, options) + const urlString = `https://localhost:${port}` + const options = { rejectUnauthorized: false } + const req = https[name](urlString, options) req.on('response', cb) return req })) test(`https.${name}(urlString, options, callback)`, echoTest('https', {}, (port, cb) => { - var urlString = `https://localhost:${port}` - var options = { rejectUnauthorized: false } + const urlString = `https://localhost:${port}` + const options = { rejectUnauthorized: false } return https[name](urlString, options, cb) })) test(`https.${name}(urlObject, options)`, echoTest('https', {}, (port, cb) => { - var urlString = `https://localhost:${port}` - var urlObject = new URL(urlString) - var options = { rejectUnauthorized: false } - var req = https[name](urlObject, options) + const urlString = `https://localhost:${port}` + const urlObject = new URL(urlString) + const options = { rejectUnauthorized: false } + const req = https[name](urlObject, options) req.on('response', cb) return req })) test(`https.${name}(urlObject, options, callback)`, echoTest('https', {}, (port, cb) => { - var urlString = `https://localhost:${port}` - var urlObject = new URL(urlString) - var options = { rejectUnauthorized: false } + const urlString = `https://localhost:${port}` + const urlObject = new URL(urlString) + const options = { rejectUnauthorized: false } return https[name](urlObject, options, cb) })) } @@ -272,15 +272,15 @@ function echoTest (type, opts, handler) { cp.kill() }) - var trans = agent.startTransaction() - var req = handler(port, res => { + const trans = agent.startTransaction() + const req = handler(port, res => { res.on('end', function () { agent.endTransaction() }) res.resume() }) - var traceparent = req.getHeader('traceparent') + const traceparent = req.getHeader('traceparent') t.ok(traceparent, 'should have traceparent header') if (opts && opts.useElasticTraceparentHeader === false) { t.strictEqual(req.getHeader('elastic-apm-traceparent'), undefined) @@ -288,8 +288,8 @@ function echoTest (type, opts, handler) { t.ok(req.getHeader('elastic-apm-traceparent'), 'should have elastic-apm-traceparent header') } - var expected = TraceParent.fromString(trans._context.toString()) - var received = TraceParent.fromString(traceparent) + const expected = TraceParent.fromString(trans._context.toString()) + const received = TraceParent.fromString(traceparent) t.strictEqual(received.version, expected.version, 'traceparent header has matching version') t.strictEqual(received.traceId, expected.traceId, 'traceparent header has matching traceId') t.ok(/^[\da-f]{16}$/.test(expected.id), 'traceparent header has valid id') diff --git a/test/instrumentation/modules/http/request.test.js b/test/instrumentation/modules/http/request.test.js index 197fd66756..4881506a13 100644 --- a/test/instrumentation/modules/http/request.test.js +++ b/test/instrumentation/modules/http/request.test.js @@ -16,24 +16,24 @@ const agent = require('../../../..').start({ spanStackTraceMinDuration: 0 // Always have span stacktraces. }) -var http = require('http') +const http = require('http') -var test = require('tape') -var express = require('express') -var request = require('request') +const test = require('tape') +const express = require('express') +const request = require('request') -var mockClient = require('../../../_mock_http_client') -var findObjInArray = require('../../../_utils').findObjInArray +const mockClient = require('../../../_mock_http_client') +const findObjInArray = require('../../../_utils').findObjInArray test('request', function (t) { resetAgent(function (data) { t.strictEqual(data.transactions.length, 2) t.strictEqual(data.spans.length, 1) - var sub = data.transactions[0] + const sub = data.transactions[0] t.strictEqual(sub.name, 'GET /test') - var root = data.transactions[1] + const root = data.transactions[1] t.strictEqual(root.name, 'GET /') t.strictEqual(root.outcome, 'success') const span = findObjInArray(data.spans, 'transaction_id', root.id) @@ -44,7 +44,7 @@ test('request', function (t) { t.end() }) - var app = express() + const app = express() var server = http.createServer(app) app.get('/test', (req, res) => { @@ -63,7 +63,7 @@ test('Outcome', function (t) { t.strictEqual(data.transactions.length, 2) t.strictEqual(data.spans.length, 1) - var root = data.transactions[1] + const root = data.transactions[1] t.strictEqual(root.name, 'GET /') t.strictEqual(root.outcome, 'failure') const span = findObjInArray(data.spans, 'transaction_id', root.id) @@ -74,7 +74,7 @@ test('Outcome', function (t) { t.end() }) - var app = express() + const app = express() var server = http.createServer(app) app.get('/test', (req, res) => { @@ -96,8 +96,8 @@ function resetAgent (cb) { function sendRequest (server, timeout) { server.listen(function () { - var port = server.address().port - var req = http.get('http://localhost:' + port, function (res) { + const port = server.address().port + const req = http.get('http://localhost:' + port, function (res) { if (timeout) throw new Error('should not get to here') res.resume() }) diff --git a/test/instrumentation/modules/http/sse.test.js b/test/instrumentation/modules/http/sse.test.js index 741e390103..556ee00c9b 100644 --- a/test/instrumentation/modules/http/sse.test.js +++ b/test/instrumentation/modules/http/sse.test.js @@ -16,11 +16,11 @@ const agent = require('../../../..').start({ spanStackTraceMinDuration: 0 // Always have span stacktraces. }) -var http = require('http') +const http = require('http') -var test = require('tape') +const test = require('tape') -var mockClient = require('../../../_mock_http_client') +const mockClient = require('../../../_mock_http_client') test('normal response', function (t) { resetAgent(2, function (data) { @@ -28,8 +28,8 @@ test('normal response', function (t) { t.end() }) - var server = http.createServer(function (req, res) { - var span = agent.startSpan('foo', 'bar') + const server = http.createServer(function (req, res) { + const span = agent.startSpan('foo', 'bar') setTimeout(function () { if (span) span.end() res.end() @@ -45,9 +45,9 @@ test('SSE response with explicit headers', function (t) { t.end() }) - var server = http.createServer(function (req, res) { + const server = http.createServer(function (req, res) { res.writeHead(200, { 'Content-Type': 'text/event-stream' }) - var span = agent.startSpan('foo', 'bar') + const span = agent.startSpan('foo', 'bar') setTimeout(function () { if (span) span.end() res.end() @@ -63,10 +63,10 @@ test('SSE response with implicit headers', function (t) { t.end() }) - var server = http.createServer(function (req, res) { + const server = http.createServer(function (req, res) { res.setHeader('Content-type', 'text/event-stream; foo') res.write('data: hello world\n\n') - var span = agent.startSpan('foo', 'bar') + const span = agent.startSpan('foo', 'bar') setTimeout(function () { if (span) span.end() res.end() @@ -80,8 +80,8 @@ function assertNonSSEResponse (t, data) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 1) - var trans = data.transactions[0] - var span = data.spans[0] + const trans = data.transactions[0] + const span = data.spans[0] t.strictEqual(trans.name, 'GET unknown route') t.strictEqual(trans.context.request.method, 'GET') @@ -93,7 +93,7 @@ function assertSSEResponse (t, data) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 0) - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, 'GET unknown route') t.strictEqual(trans.context.request.method, 'GET') @@ -101,7 +101,7 @@ function assertSSEResponse (t, data) { function request (server) { server.listen(function () { - var port = server.address().port + const port = server.address().port http.request({ port: port }, function (res) { res.on('end', function () { server.close() diff --git a/test/instrumentation/modules/http2.test.js b/test/instrumentation/modules/http2.test.js index e2b549fabb..bdf2700731 100644 --- a/test/instrumentation/modules/http2.test.js +++ b/test/instrumentation/modules/http2.test.js @@ -6,25 +6,25 @@ 'use strict' -var agent = require('../../..').start({ +const agent = require('../../..').start({ serviceName: 'test', captureExceptions: false, metricsInterval: 0, centralConfig: false, cloudProvider: 'none' }) -var ins = agent._instrumentation +const ins = agent._instrumentation -var fs = require('fs') -var https = require('https') -var http2 = require('http2') +const fs = require('fs') +const https = require('https') +const http2 = require('http2') -var semver = require('semver') -var pem = require('https-pem') -var test = require('tape') +const semver = require('semver') +const pem = require('https-pem') +const test = require('tape') -var mockClient = require('../../_mock_http_client') -var findObjInArray = require('../../_utils').findObjInArray +const mockClient = require('../../_mock_http_client') +const findObjInArray = require('../../_utils').findObjInArray const constants = require('../../../lib/constants') if (semver.satisfies(process.version, '8.x')) { @@ -32,9 +32,9 @@ if (semver.satisfies(process.version, '8.x')) { process.exit() } -var isSecure = [false, true] +const isSecure = [false, true] isSecure.forEach(secure => { - var method = secure ? 'createSecureServer' : 'createServer' + const method = secure ? 'createSecureServer' : 'createServer' test(`http2.${method} compatibility mode`, t => { t.plan(16) @@ -49,7 +49,7 @@ isSecure.forEach(secure => { }) function onRequest (req, res) { - var trans = ins.currTransaction() + const trans = ins.currTransaction() t.ok(trans, 'have current transaction') t.strictEqual(trans.type, 'request') @@ -59,22 +59,22 @@ isSecure.forEach(secure => { res.end('foo') } - var port + let port var server = secure ? http2.createSecureServer(pem, onRequest) : http2.createServer(onRequest) - var onError = err => t.error(err) + const onError = err => t.error(err) server.on('error', onError) server.on('socketError', onError) server.listen(() => { port = server.address().port - var client = connect(secure, port) + const client = connect(secure, port) client.on('error', onError) client.on('socketError', onError) - var req = client.request({ ':path': '/' }) + const req = client.request({ ':path': '/' }) assertResponse(t, req, 'foo') req.resume() req.on('end', () => client.destroy()) @@ -90,17 +90,17 @@ isSecure.forEach(secure => { server.close() }) - var port + let port var server = secure ? http2.createSecureServer(pem) : http2.createServer() - var onError = err => t.error(err) + const onError = err => t.error(err) server.on('error', onError) server.on('socketError', onError) server.on('stream', function (stream, headers) { - var trans = ins.currTransaction() + const trans = ins.currTransaction() t.ok(trans, 'have current transaction') t.strictEqual(trans.type, 'request') @@ -113,11 +113,11 @@ isSecure.forEach(secure => { server.listen(() => { port = server.address().port - var client = connect(secure, port) + const client = connect(secure, port) client.on('error', onError) client.on('socketError', onError) - var req = client.request({ ':path': '/' }) + const req = client.request({ ':path': '/' }) assertResponse(t, req, 'foo') req.resume() req.on('end', () => client.destroy()) @@ -133,17 +133,17 @@ isSecure.forEach(secure => { server.close() }) - var port + let port var server = secure ? http2.createSecureServer(pem) : http2.createServer() - var onError = err => t.error(err) + const onError = err => t.error(err) server.on('error', onError) server.on('socketError', onError) server.on('stream', function (stream, headers) { - var trans = ins.currTransaction() + const trans = ins.currTransaction() t.ok(trans, 'have current transaction') t.strictEqual(trans.type, 'request') @@ -163,11 +163,11 @@ isSecure.forEach(secure => { server.listen(() => { port = server.address().port - var client = connect(secure, port) + const client = connect(secure, port) client.on('error', onError) client.on('socketError', onError) - var req = client.request({ ':path': '/' }) + const req = client.request({ ':path': '/' }) assertResponse(t, req, '') // Do not expect 'foo' to get through. req.resume() req.on('end', () => client.destroy()) @@ -183,17 +183,17 @@ isSecure.forEach(secure => { server.close() }) - var port + let port var server = secure ? http2.createSecureServer(pem) : http2.createServer() - var onError = err => t.error(err) + const onError = err => t.error(err) server.on('error', onError) server.on('socketError', onError) server.on('stream', function (stream, headers) { - var trans = ins.currTransaction() + const trans = ins.currTransaction() t.ok(trans, 'have current transaction') t.strictEqual(trans.type, 'request') @@ -213,11 +213,11 @@ isSecure.forEach(secure => { server.listen(() => { port = server.address().port - var client = connect(secure, port) + const client = connect(secure, port) client.on('error', onError) client.on('socketError', onError) - var req = client.request({ ':path': '/' }) + const req = client.request({ ':path': '/' }) assertResponse(t, req, fs.readFileSync(__filename).toString()) req.resume() req.on('end', () => client.destroy()) @@ -233,17 +233,17 @@ isSecure.forEach(secure => { server.close() }) - var port + let port var server = secure ? http2.createSecureServer(pem) : http2.createServer() - var onError = err => t.error(err) + const onError = err => t.error(err) server.on('error', onError) server.on('socketError', onError) server.on('stream', function (stream, headers) { - var trans = ins.currTransaction() + const trans = ins.currTransaction() t.ok(trans, 'have current transaction') t.strictEqual(trans.type, 'request') @@ -255,11 +255,11 @@ isSecure.forEach(secure => { server.listen(() => { port = server.address().port - var client = connect(secure, port) + const client = connect(secure, port) client.on('error', onError) client.on('socketError', onError) - var req = client.request({ ':path': '/' }) + const req = client.request({ ':path': '/' }) assertResponse(t, req, fs.readFileSync(__filename).toString()) req.resume() req.on('end', () => client.destroy()) @@ -270,7 +270,7 @@ isSecure.forEach(secure => { test(`http2.${method} ignore push streams`, t => { addShouldCall(t) - var done = after(3, () => { + const done = after(3, () => { client.destroy() t.end() }) @@ -281,18 +281,18 @@ isSecure.forEach(secure => { done() }) - var port - var client + let port + let client var server = secure ? http2.createSecureServer(pem) : http2.createServer() - var onError = err => t.error(err) + const onError = err => t.error(err) server.on('error', onError) server.on('socketError', onError) server.on('stream', function (stream, headers) { - var trans = ins.currTransaction() + const trans = ins.currTransaction() t.ok(trans, 'have current transaction') t.strictEqual(trans.type, 'request') @@ -333,7 +333,7 @@ isSecure.forEach(secure => { assertResponse(t, stream, 'some pushed data', done) })) - var req = client.request({ ':path': '/' }) + const req = client.request({ ':path': '/' }) assertResponse(t, req, 'foo') req.end() }) @@ -346,13 +346,13 @@ isSecure.forEach(secure => { t.strictEqual(data.transactions.length, 2) t.strictEqual(data.spans.length, 1) - var sub = data.transactions[0] + const sub = data.transactions[0] assertPath(t, sub, secure, port, '/sub', '2.0') - var root = data.transactions[1] + const root = data.transactions[1] assertPath(t, root, secure, port, '/', '2.0') - var span = findObjInArray(data.spans, 'transaction_id', root.id) + const span = findObjInArray(data.spans, 'transaction_id', root.id) t.ok(span, 'root transaction should have span') t.strictEqual(span.type, 'external') t.strictEqual(span.subtype, 'http') @@ -380,22 +380,22 @@ isSecure.forEach(secure => { server.close() }) - var port + let port var server = secure ? http2.createSecureServer(pem) : http2.createServer() - var onError = err => t.error(err) + const onError = err => t.error(err) server.on('error', onError) server.on('socketError', onError) server.on('stream', function (stream, headers) { - var trans = ins.currTransaction() + const trans = ins.currTransaction() t.ok(trans, 'have current transaction') t.strictEqual(trans.type, 'request') if (headers[':path'] === '/') { - var client = connect(secure, port) + const client = connect(secure, port) client.on('error', onError) client.on('socketError', onError) @@ -404,7 +404,7 @@ isSecure.forEach(secure => { ':status': 200 }) - var req = client.request({ ':path': '/sub' }) + const req = client.request({ ':path': '/sub' }) t.ok(agent.currentSpan === null, 'the http2 span should not spill into user code') req.on('end', () => { t.ok(agent.currentSpan === null, 'the http2 span should *not* be the currentSpan in user event handlers') @@ -422,11 +422,11 @@ isSecure.forEach(secure => { server.listen(() => { port = server.address().port - var client = connect(secure, port) + const client = connect(secure, port) client.on('error', onError) client.on('socketError', onError) - var req = client.request({ ':path': '/' }) + const req = client.request({ ':path': '/' }) assertResponse(t, req, 'foo') req.resume() req.on('end', () => client.destroy()) @@ -446,11 +446,11 @@ test('handling HTTP/1.1 request to http2.createSecureServer with allowHTTP1:true tx = data.transactions[0] }) - var port - var serverOpts = Object.assign({ allowHTTP1: true }, pem) - var server = http2.createSecureServer(serverOpts) + let port + const serverOpts = Object.assign({ allowHTTP1: true }, pem) + const server = http2.createSecureServer(serverOpts) server.on('request', function onRequest (req, res) { - var trans = ins.currTransaction() + const trans = ins.currTransaction() t.ok(trans, 'have current transaction') t.strictEqual(trans.type, 'request') res.writeHead(200, { 'content-type': 'text/plain' }) @@ -463,7 +463,7 @@ test('handling HTTP/1.1 request to http2.createSecureServer with allowHTTP1:true port = server.address().port // Make an HTTP/1.1 request. - var getOpts = { + const getOpts = { agent: new https.Agent(), protocol: 'https:', host: 'localhost', @@ -472,7 +472,7 @@ test('handling HTTP/1.1 request to http2.createSecureServer with allowHTTP1:true ALPNProtocols: ['http/1.1'], rejectUnauthorized: false } - var req = https.get(getOpts, function (res) { + const req = https.get(getOpts, function (res) { assertResponse(t, res, 'foo', function () { // Assert the APM transaction is as expected for an HTTP/1.x request. t.ok(tx, 'got the transaction') @@ -488,7 +488,7 @@ test('handling HTTP/1.1 request to http2.createSecureServer with allowHTTP1:true }) }) -var matchId = /^[\da-f]{16}$/ +const matchId = /^[\da-f]{16}$/ function assertPath (t, trans, secure, port, path, httpVersion) { t.ok(trans) @@ -593,7 +593,7 @@ function assert (t, data, secure, port) { // Top-level props of the transaction need to be checked individually // because there are a few dynamic properties - var trans = data.transactions[0] + const trans = data.transactions[0] assertPath(t, trans, secure, port, '/', '2.0') } @@ -609,8 +609,8 @@ function assertResponse (t, stream, expected, done) { } function connect (secure, port) { - var proto = secure ? 'https' : 'http' - var opts = { rejectUnauthorized: false } + const proto = secure ? 'https' : 'http' + const opts = { rejectUnauthorized: false } return http2.connect(`${proto}://localhost:${port}`, opts) } @@ -621,18 +621,18 @@ function resetAgent (expected, cb) { } function addShouldCall (t) { - var calls = [] - var realEnd = t.end + const calls = [] + const realEnd = t.end t.end = function end () { - for (var i = 0; i < calls.length; i++) { + for (let i = 0; i < calls.length; i++) { t.strictEqual(calls[i].called, true, 'should have called function') } return realEnd.apply(this, arguments) } t.shouldCall = function shouldCall (fn) { - var record = { called: false } + const record = { called: false } calls.push(record) return function shouldCallWrap () { record.called = true diff --git a/test/instrumentation/modules/ioredis.test.js b/test/instrumentation/modules/ioredis.test.js index aab52d3d0a..2309811a7f 100644 --- a/test/instrumentation/modules/ioredis.test.js +++ b/test/instrumentation/modules/ioredis.test.js @@ -11,7 +11,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -var agent = require('../../..').start({ +const agent = require('../../..').start({ serviceName: 'test-ioredis', captureExceptions: false, metricsInterval: 0, @@ -20,27 +20,27 @@ var agent = require('../../..').start({ spanCompressionEnabled: false }) -var ioredisVer = require('ioredis/package.json').version -var semver = require('semver') +const ioredisVer = require('ioredis/package.json').version +const semver = require('semver') if (semver.gte(ioredisVer, '5.0.0') && semver.lt(process.version, '12.22.0')) { console.log(`# SKIP ioredis@${ioredisVer} does not support node ${process.version}`) process.exit() } -var Redis = require('ioredis') -var test = require('tape') +const Redis = require('ioredis') +const test = require('tape') -var findObjInArray = require('../../_utils').findObjInArray -var mockClient = require('../../_mock_http_client') +const findObjInArray = require('../../_utils').findObjInArray +const mockClient = require('../../_mock_http_client') test('not nested', function (t) { resetAgent(done(t)) - var redis = new Redis(process.env.REDIS_HOST) + const redis = new Redis(process.env.REDIS_HOST) agent.startTransaction('foo', 'bar') - var calls = 0 + let calls = 0 redis.flushall(function (err, reply) { t.error(err) @@ -79,14 +79,14 @@ test('not nested', function (t) { test('nested', function (t) { resetAgent(done(t)) - var redis = new Redis(process.env.REDIS_HOST) + const redis = new Redis(process.env.REDIS_HOST) agent.startTransaction('foo', 'bar') redis.flushall(function (err, reply) { t.error(err) t.strictEqual(reply, 'OK') - var calls = 0 + let calls = 0 redis.set('foo', 'bar') redis.get('foo', function (err, result) { @@ -142,7 +142,7 @@ test('error capture, no unhandledRejection on command error is introduced', func }, 0) }) - var redis = new Redis(process.env.REDIS_HOST) + const redis = new Redis(process.env.REDIS_HOST) const trans = agent.startTransaction('foo', 'bar') redis.hset('a', 'b', 'c') redis.get('a', function (err, result) { @@ -155,7 +155,7 @@ test('error capture, no unhandledRejection on command error is introduced', func function done (t) { return function (data, cb) { - var groups = [ + const groups = [ 'FLUSHALL', 'SET', 'GET', @@ -169,7 +169,7 @@ function done (t) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, groups.length) - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, 'foo') t.strictEqual(trans.type, 'bar') diff --git a/test/instrumentation/modules/koa-router/shared.js b/test/instrumentation/modules/koa-router/shared.js index c921d2e79e..e4f9863506 100644 --- a/test/instrumentation/modules/koa-router/shared.js +++ b/test/instrumentation/modules/koa-router/shared.js @@ -7,7 +7,7 @@ 'use strict' module.exports = (moduleName) => { - var agent = require('../../../..').start({ + const agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -25,14 +25,14 @@ module.exports = (moduleName) => { process.exit() } - var http = require('http') + const http = require('http') - var Koa = require('koa') - var test = require('tape') + const Koa = require('koa') + const test = require('tape') - var Router = require(moduleName) + const Router = require(moduleName) - var mockClient = require('../../../_mock_http_client') + const mockClient = require('../../../_mock_http_client') test('route naming', function (t) { t.plan(8) @@ -107,7 +107,7 @@ module.exports = (moduleName) => { }) function startServer (cb) { - var server = buildServer() + const server = buildServer() server.listen(function () { cb(server.address().port) }) @@ -115,10 +115,10 @@ module.exports = (moduleName) => { } function buildServer () { - var app = new Koa() - var router = new Router() - var parentRouter = new Router() - var childRouter = new Router({ + const app = new Koa() + const router = new Router() + const parentRouter = new Router() + const childRouter = new Router({ prefix: '/prefix2' }) @@ -152,7 +152,7 @@ module.exports = (moduleName) => { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 0) - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, results.name) t.strictEqual(trans.type, 'request') diff --git a/test/instrumentation/modules/memcached.test.js b/test/instrumentation/modules/memcached.test.js index fa2b0b49ad..69876cdaf3 100644 --- a/test/instrumentation/modules/memcached.test.js +++ b/test/instrumentation/modules/memcached.test.js @@ -12,7 +12,7 @@ if (process.platform === 'win32') { process.exit() } -var agent = require('../../..').start({ +const agent = require('../../..').start({ serviceName: 'test-memcached', captureExceptions: false, metricsInterval: '0s', @@ -21,10 +21,10 @@ var agent = require('../../..').start({ spanCompressionEnabled: false }) -var test = require('tape') -var mockClient = require('../../_mock_http_client') +const test = require('tape') +const mockClient = require('../../_mock_http_client') -var host = process.env.MEMCACHED_HOST || '127.0.0.1' +const host = process.env.MEMCACHED_HOST || '127.0.0.1' test('memcached', function (t) { resetAgent(function (data) { @@ -86,8 +86,8 @@ test('memcached', function (t) { t.end() }) - var Memcached = require('memcached') - var cache = new Memcached(`${host}:11211`, { timeout: 500 }) + const Memcached = require('memcached') + const cache = new Memcached(`${host}:11211`, { timeout: 500 }) agent.startTransaction('myTrans') cache.set('foo', 'bar', 300, (err) => { t.ok(agent.currentSpan === null, 'memcached span should not be currentSpan in callback') diff --git a/test/instrumentation/modules/mimic-response.test.js b/test/instrumentation/modules/mimic-response.test.js index cf927f76d5..9f5c5d5fd7 100644 --- a/test/instrumentation/modules/mimic-response.test.js +++ b/test/instrumentation/modules/mimic-response.test.js @@ -11,18 +11,18 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -var agent = require('../../..').start({ +const agent = require('../../..').start({ serviceName: 'test', captureExceptions: false, metricsInterval: 0, centralConfig: false }) -var stream = require('stream') -var mimicResponse = require('mimic-response') -var test = require('tape') +const stream = require('stream') +const mimicResponse = require('mimic-response') +const test = require('tape') -var cases = [ +const cases = [ { name: 'none bound', source: false, target: false }, { name: 'source bound', source: true, target: false }, { name: 'target bound', source: false, target: true }, diff --git a/test/instrumentation/modules/mongodb-core.test.js b/test/instrumentation/modules/mongodb-core.test.js index f2bdb63e40..bc045aaf8c 100644 --- a/test/instrumentation/modules/mongodb-core.test.js +++ b/test/instrumentation/modules/mongodb-core.test.js @@ -11,7 +11,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -var agent = require('../../..').start({ +const agent = require('../../..').start({ serviceName: 'test-mongodb-core', captureExceptions: false, metricsInterval: 0, @@ -20,19 +20,19 @@ var agent = require('../../..').start({ spanCompressionEnabled: false }) -var Server = require('mongodb-core').Server -var semver = require('semver') -var test = require('tape') -var mongodbCoreVersion = require('mongodb-core/package').version +const Server = require('mongodb-core').Server +const semver = require('semver') +const test = require('tape') +const mongodbCoreVersion = require('mongodb-core/package').version -var mockClient = require('../../_mock_http_client') +const mockClient = require('../../_mock_http_client') test('instrument simple command', function (t) { // Because a variable number of events to the APM server is possible (see // the "Note ... additional spans" below), we cannot use the 'expected' arg // to `mockClient` here. resetAgent(function (data) { - var expectedSpanNamesInOrder = [ + const expectedSpanNamesInOrder = [ 'system.$cmd.ismaster', 'elasticapm.test.insert', 'elasticapm.test.update', @@ -42,7 +42,7 @@ test('instrument simple command', function (t) { ] t.strictEqual(data.transactions.length, 1) - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, 'foo', 'transaction.name') t.strictEqual(trans.type, 'bar', 'transaction.type') t.strictEqual(trans.result, 'success', 'transaction.result') @@ -61,7 +61,7 @@ test('instrument simple command', function (t) { // `contextManager != "patch"`. // - mongodb-core@1.x includes `elasticapm.$cmd.command` spans after the // insert, update, and remove commands. - for (var i = 0; i < data.spans.length; i++) { + for (let i = 0; i < data.spans.length; i++) { const span = data.spans[i] if (semver.lt(mongodbCoreVersion, '2.0.0')) { if (span.name === 'admin.$cmd.ismaster' && i === 0) { @@ -82,7 +82,7 @@ test('instrument simple command', function (t) { t.strictEqual(span.subtype, 'mongodb', 'span has expected subtype') t.strictEqual(span.action, 'query', 'span has expected action') t.strictEqual(span.parent_id, trans.id, 'span is a direct child of transaction') - var offset = span.timestamp - trans.timestamp + const offset = span.timestamp - trans.timestamp t.ok(offset + span.duration * 1000 < trans.duration * 1000, `span ends (${span.timestamp / 1000 + span.duration}ms) before the transaction (${trans.timestamp / 1000 + trans.duration}ms)`) const dbInstance = expectedSpanNamesInOrder[0].slice(0, expectedSpanNamesInOrder[0].lastIndexOf('.')) @@ -110,7 +110,7 @@ test('instrument simple command', function (t) { t.end() }) - var server = new Server({ host: process.env.MONGODB_HOST }) + const server = new Server({ host: process.env.MONGODB_HOST }) agent.startTransaction('foo', 'bar') @@ -132,7 +132,7 @@ test('instrument simple command', function (t) { t.error(err, 'no error from remove') t.strictEqual(results.result.n, 1) - var cursor = _server.cursor('elasticapm.test', { find: 'elasticapm.test', query: {} }) + const cursor = _server.cursor('elasticapm.test', { find: 'elasticapm.test', query: {} }) cursor.next(function (err, doc) { t.error(err, 'no error from cursor.next') t.strictEqual(doc.a, 2, 'doc.a') diff --git a/test/instrumentation/modules/mysql/_utils.js b/test/instrumentation/modules/mysql/_utils.js index de0741d3c7..27cac2caa9 100644 --- a/test/instrumentation/modules/mysql/_utils.js +++ b/test/instrumentation/modules/mysql/_utils.js @@ -6,12 +6,12 @@ 'use strict' -var mysql = require('mysql') +const mysql = require('mysql') exports.reset = reset exports.credentials = credentials -var DEFAULTS = { +const DEFAULTS = { host: process.env.MYSQL_HOST || 'localhost', user: process.env.MYSQL_USER || 'root', password: process.env.MYSQL_PASSWORD, @@ -27,7 +27,7 @@ function credentials (conf) { } function reset (cb) { - var client = mysql.createConnection(credentials({ database: 'mysql' })) + const client = mysql.createConnection(credentials({ database: 'mysql' })) client.connect(function (err) { if (err) throw err diff --git a/test/instrumentation/modules/mysql/mysql.test.js b/test/instrumentation/modules/mysql/mysql.test.js index bd63205649..1913837caa 100644 --- a/test/instrumentation/modules/mysql/mysql.test.js +++ b/test/instrumentation/modules/mysql/mysql.test.js @@ -11,7 +11,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -var agent = require('../../../..').start({ +const agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -20,18 +20,18 @@ var agent = require('../../../..').start({ spanCompressionEnabled: false }) -var mysql = require('mysql') -var mysqlVersion = require('mysql/package.json').version -var semver = require('semver') -var test = require('tape') +const mysql = require('mysql') +const mysqlVersion = require('mysql/package.json').version +const semver = require('semver') +const test = require('tape') -var utils = require('./_utils') -var mockClient = require('../../../_mock_http_client') -var findObjInArray = require('../../../_utils').findObjInArray +const utils = require('./_utils') +const mockClient = require('../../../_mock_http_client') +const findObjInArray = require('../../../_utils').findObjInArray -var queryable -var connectionOptions = utils.credentials() -var factories = [ +let queryable +const connectionOptions = utils.credentials() +const factories = [ [createConnection, 'connection'], [createPool, 'pool'], [createPoolAndGetConnection, 'pool > connection'], @@ -40,16 +40,16 @@ var factories = [ ] factories.forEach(function (f) { - var factory = f[0] - var type = f[1] + const factory = f[0] + const type = f[1] // Prior to mysql v2.4 pool.query would not return a Query object. // See: https://github.com/mysqljs/mysql/pull/830 - var skipStreamTest = type === 'pool' && semver.satisfies(mysqlVersion, '<2.4.0') + const skipStreamTest = type === 'pool' && semver.satisfies(mysqlVersion, '<2.4.0') // Prior to mysql v2.2 pool.query required a callback. // See: https://github.com/mysqljs/mysql/pull/585 - var skipNoCallbackTest = type === 'pool' && semver.satisfies(mysqlVersion, '<2.2.0') + const skipNoCallbackTest = type === 'pool' && semver.satisfies(mysqlVersion, '<2.2.0') test('mysql.' + factory.name, function (t) { t.on('end', teardown) @@ -114,7 +114,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + 1 AS solution' factory(function () { agent.startTransaction('foo') - var query = mysql.createQuery(sql, basicQueryCallback(t)) + const query = mysql.createQuery(sql, basicQueryCallback(t)) queryable.query(query) t.equal(agent.currentSpan, null, 'mysql span should not bleed into calling code') }) @@ -128,7 +128,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + ? AS solution' factory(function () { agent.startTransaction('foo') - var query = mysql.createQuery(sql, [1], basicQueryCallback(t)) + const query = mysql.createQuery(sql, [1], basicQueryCallback(t)) queryable.query(query) t.equal(agent.currentSpan, null, 'mysql span should not bleed into calling code') }) @@ -143,7 +143,7 @@ factories.forEach(function (f) { }) var sql = 'SELECT 1 + 1 AS solution' factory(function () { - var trans = agent.startTransaction('foo') + const trans = agent.startTransaction('foo') queryable.query(sql) t.equal(agent.currentSpan, null, 'mysql span should not bleed into calling code') setTimeout(function () { @@ -164,7 +164,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + 1 AS solution' factory(function () { agent.startTransaction('foo') - var stream = queryable.query(sql) + const stream = queryable.query(sql) t.equal(agent.currentSpan, null, 'mysql span should not bleed into calling code') basicQueryStream(stream, t) }) @@ -178,7 +178,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + ? AS solution' factory(function () { agent.startTransaction('foo') - var stream = queryable.query(sql, [1]) + const stream = queryable.query(sql, [1]) t.equal(agent.currentSpan, null, 'mysql span should not bleed into calling code') basicQueryStream(stream, t) }) @@ -192,7 +192,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + 1 AS solution' factory(function () { agent.startTransaction('foo') - var stream = queryable.query({ sql: sql }) + const stream = queryable.query({ sql: sql }) t.equal(agent.currentSpan, null, 'mysql span should not bleed into calling code') basicQueryStream(stream, t) }) @@ -206,7 +206,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + ? AS solution' factory(function () { agent.startTransaction('foo') - var stream = queryable.query({ sql: sql }, [1]) + const stream = queryable.query({ sql: sql }, [1]) t.equal(agent.currentSpan, null, 'mysql span should not bleed into calling code') basicQueryStream(stream, t) }) @@ -220,8 +220,8 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + 1 AS solution' factory(function () { agent.startTransaction('foo') - var query = mysql.createQuery(sql) - var stream = queryable.query(query) + const query = mysql.createQuery(sql) + const stream = queryable.query(query) t.equal(agent.currentSpan, null, 'mysql span should not bleed into calling code') basicQueryStream(stream, t) }) @@ -235,8 +235,8 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + ? AS solution' factory(function () { agent.startTransaction('foo') - var query = mysql.createQuery(sql, [1]) - var stream = queryable.query(query) + const query = mysql.createQuery(sql, [1]) + const stream = queryable.query(query) t.equal(agent.currentSpan, null, 'mysql span should not bleed into calling code') basicQueryStream(stream, t) }) @@ -249,7 +249,7 @@ factories.forEach(function (f) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 3) - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, 'foo') @@ -264,8 +264,8 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + ? AS solution' factory(function () { - var n = 0 - var trans = agent.startTransaction('foo') + let n = 0 + const trans = agent.startTransaction('foo') queryable.query(sql, [1], function (err, rows, fields) { t.error(err) @@ -294,7 +294,7 @@ factories.forEach(function (f) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 3) - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, 'foo') @@ -309,8 +309,8 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + ? AS solution' createPool(function () { - var n = 0 - var trans = agent.startTransaction('foo') + let n = 0 + const trans = agent.startTransaction('foo') queryable.getConnection(function (err, conn) { t.error(err) @@ -348,7 +348,7 @@ factories.forEach(function (f) { resetAgent(6, function (data) { t.strictEqual(data.transactions.length, 3) t.strictEqual(data.spans.length, 3) - var names = data.transactions.map(function (trans) { + const names = data.transactions.map(function (trans) { return trans.name }).sort() t.deepEqual(names, ['bar', 'baz', 'foo']) @@ -366,7 +366,7 @@ factories.forEach(function (f) { factory(function () { setImmediate(function () { - var trans = agent.startTransaction('foo') + const trans = agent.startTransaction('foo') queryable.query(sql, [1], function (err, rows, fields) { t.error(err) t.strictEqual(rows[0].solution, 2) @@ -375,7 +375,7 @@ factories.forEach(function (f) { }) setImmediate(function () { - var trans = agent.startTransaction('bar') + const trans = agent.startTransaction('bar') queryable.query(sql, [2], function (err, rows, fields) { t.error(err) t.strictEqual(rows[0].solution, 3) @@ -384,7 +384,7 @@ factories.forEach(function (f) { }) setImmediate(function () { - var trans = agent.startTransaction('baz') + const trans = agent.startTransaction('baz') queryable.query(sql, [3], function (err, rows, fields) { t.error(err) t.strictEqual(rows[0].solution, 4) @@ -432,7 +432,7 @@ function basicQueryCallback (t) { } function basicQueryStream (stream, t) { - var results = 0 + let results = 0 stream.on('error', function (err) { t.equal(agent.currentSpan, null, 'mysql span should not be active in user code') t.error(err) @@ -453,8 +453,8 @@ function assertBasicQuery (t, sql, data) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 1) - var trans = data.transactions[0] - var span = data.spans[0] + const trans = data.transactions[0] + const span = data.spans[0] t.strictEqual(trans.name, 'foo') assertSpan(t, span, sql) diff --git a/test/instrumentation/modules/mysql/pool-release-1.test.js b/test/instrumentation/modules/mysql/pool-release-1.test.js index e625c429df..562a80d549 100644 --- a/test/instrumentation/modules/mysql/pool-release-1.test.js +++ b/test/instrumentation/modules/mysql/pool-release-1.test.js @@ -11,7 +11,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -var agent = require('../../../..').start({ +const agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -19,10 +19,10 @@ var agent = require('../../../..').start({ centralConfig: false }) -var mysql = require('mysql') -var test = require('tape') +const mysql = require('mysql') +const test = require('tape') -var utils = require('./_utils') +const utils = require('./_utils') test('release connection prior to transaction', function (t) { createPool(function (pool) { diff --git a/test/instrumentation/modules/mysql2/_utils.js b/test/instrumentation/modules/mysql2/_utils.js index 3cd1b1d766..4fecb287bd 100644 --- a/test/instrumentation/modules/mysql2/_utils.js +++ b/test/instrumentation/modules/mysql2/_utils.js @@ -6,12 +6,12 @@ 'use strict' -var mysql = require('mysql2') +const mysql = require('mysql2') exports.reset = reset exports.credentials = credentials -var DEFAULTS = { +const DEFAULTS = { host: process.env.MYSQL_HOST || 'localhost', user: process.env.MYSQL_USER || 'root', password: process.env.MYSQL_PASSWORD, @@ -27,7 +27,7 @@ function credentials (conf) { } function reset (cb) { - var client = mysql.createConnection(credentials({ database: 'mysql' })) + const client = mysql.createConnection(credentials({ database: 'mysql' })) client.connect(function (err) { if (err) throw err diff --git a/test/instrumentation/modules/mysql2/mysql.test.js b/test/instrumentation/modules/mysql2/mysql.test.js index 340a787135..f949eefa22 100644 --- a/test/instrumentation/modules/mysql2/mysql.test.js +++ b/test/instrumentation/modules/mysql2/mysql.test.js @@ -19,7 +19,7 @@ if (semver.gte(mysql2Ver, '3.0.0') && semver.lt(process.version, '14.6.0')) { process.exit() } -var agent = require('../../../..').start({ +const agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -28,30 +28,30 @@ var agent = require('../../../..').start({ spanCompressionEnabled: false }) -var mysql = require('mysql2') -var mysqlPromise = require('mysql2/promise') -var test = require('tape') +const mysql = require('mysql2') +const mysqlPromise = require('mysql2/promise') +const test = require('tape') -var utils = require('./_utils') -var mockClient = require('../../../_mock_http_client') -var findObjInArray = require('../../../_utils').findObjInArray +const utils = require('./_utils') +const mockClient = require('../../../_mock_http_client') +const findObjInArray = require('../../../_utils').findObjInArray -var connectionOptions = utils.credentials() -var queryable -var queryablePromise -var factories = [ +const connectionOptions = utils.credentials() +let queryable +let queryablePromise +const factories = [ [createConnection, 'connection', true], [createPool, 'pool', true], [createPoolAndGetConnection, 'pool > connection', true], [createPoolClusterAndGetConnection, 'poolCluster > connection', false], [createPoolClusterAndGetConnectionViaOf, 'poolCluster > of > connection', false] ] -var executors = [ +const executors = [ 'query', 'execute' ] -var universalArgumentSets = [ +const universalArgumentSets = [ { names: ['sql'], query: 'SELECT 1 + 1 AS solution', @@ -74,7 +74,7 @@ var universalArgumentSets = [ } ] -var callbackArgumentSets = [ +const callbackArgumentSets = [ { names: ['query'], query: 'SELECT 1 + 1 AS solution', @@ -88,27 +88,27 @@ var callbackArgumentSets = [ ] factories.forEach(function (f) { - var factory = f[0] - var type = f[1] - var hasPromises = f[2] + const factory = f[0] + const type = f[1] + const hasPromises = f[2] test('mysql2.' + factory.name, function (t) { t.on('end', teardown) executors.forEach(function (executor) { t.test(executor, function (t) { - var isQuery = executor === 'query' - var argumentSets = isQuery && type !== 'pool' + const isQuery = executor === 'query' + const argumentSets = isQuery && type !== 'pool' ? universalArgumentSets.concat(callbackArgumentSets) : universalArgumentSets t.test('callback', function (t) { argumentSets.forEach(function (argumentSet) { - var query = argumentSet.query - var names = argumentSet.names - var values = argumentSet.values + const query = argumentSet.query + const names = argumentSet.names + const values = argumentSet.values - var name = `${type}.${executor}(${names.join(', ')}, callback)` - var args = values(query, basicQueryCallback(t)) + const name = `${type}.${executor}(${names.join(', ')}, callback)` + const args = values(query, basicQueryCallback(t)) t.test(name, function (t) { resetAgent(function (data) { @@ -127,12 +127,12 @@ factories.forEach(function (f) { if (hasPromises) { t.test('promise', function (t) { universalArgumentSets.forEach(function (argumentSet) { - var query = argumentSet.query - var names = argumentSet.names - var values = argumentSet.values + const query = argumentSet.query + const names = argumentSet.names + const values = argumentSet.values - var name = `${type}.${executor}(${names.join(', ')})` - var args = values(query) + const name = `${type}.${executor}(${names.join(', ')})` + const args = values(query) t.test(name, function (t) { resetAgent(function (data) { @@ -141,7 +141,7 @@ factories.forEach(function (f) { }) factory(function () { agent.startTransaction('foo') - var promise = queryablePromise[executor].apply(queryablePromise, args) + const promise = queryablePromise[executor].apply(queryablePromise, args) t.ok(agent.currentSpan === null, 'mysql2 span should not spill into calling code') basicQueryPromise(t, promise) }) @@ -153,12 +153,12 @@ factories.forEach(function (f) { if (isQuery) { t.test('streaming', function (t) { argumentSets.forEach(function (argumentSet) { - var query = argumentSet.query - var names = argumentSet.names - var values = argumentSet.values + const query = argumentSet.query + const names = argumentSet.names + const values = argumentSet.values - var name = `${type}.${executor}(${names.join(', ')})` - var args = values(query) + const name = `${type}.${executor}(${names.join(', ')})` + const args = values(query) t.test(name, function (t) { resetAgent(function (data) { @@ -167,7 +167,7 @@ factories.forEach(function (f) { }) factory(function () { agent.startTransaction('foo') - var stream = queryable[executor].apply(queryable, args) + const stream = queryable[executor].apply(queryable, args) t.ok(agent.currentSpan === null, 'mysql2 span should not spill into calling code') basicQueryStream(stream, t) }) @@ -184,7 +184,7 @@ factories.forEach(function (f) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 3) - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, 'foo') @@ -199,8 +199,8 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + ? AS solution' factory(function () { - var n = 0 - var trans = agent.startTransaction('foo') + let n = 0 + const trans = agent.startTransaction('foo') queryable.query(sql, [1], function (err, rows, fields) { t.error(err) @@ -229,7 +229,7 @@ factories.forEach(function (f) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 3) - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, 'foo') @@ -244,8 +244,8 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + ? AS solution' createPool(function () { - var n = 0 - var trans = agent.startTransaction('foo') + let n = 0 + const trans = agent.startTransaction('foo') queryable.getConnection(function (err, conn) { t.error(err) @@ -283,7 +283,7 @@ factories.forEach(function (f) { resetAgent(6, function (data) { t.strictEqual(data.transactions.length, 3) t.strictEqual(data.spans.length, 3) - var names = data.transactions.map(function (trans) { + const names = data.transactions.map(function (trans) { return trans.name }).sort() t.deepEqual(names, ['bar', 'baz', 'foo']) @@ -301,7 +301,7 @@ factories.forEach(function (f) { factory(function () { setImmediate(function () { - var trans = agent.startTransaction('foo') + const trans = agent.startTransaction('foo') queryable.query(sql, [1], function (err, rows, fields) { t.error(err) t.strictEqual(rows[0].solution, 2) @@ -310,7 +310,7 @@ factories.forEach(function (f) { }) setImmediate(function () { - var trans = agent.startTransaction('bar') + const trans = agent.startTransaction('bar') queryable.query(sql, [2], function (err, rows, fields) { t.error(err) t.strictEqual(rows[0].solution, 3) @@ -319,7 +319,7 @@ factories.forEach(function (f) { }) setImmediate(function () { - var trans = agent.startTransaction('baz') + const trans = agent.startTransaction('baz') queryable.query(sql, [3], function (err, rows, fields) { t.error(err) t.strictEqual(rows[0].solution, 4) @@ -364,7 +364,7 @@ function basicQueryPromise (t, p) { } p.then(function (response) { - var rows = response[0] + const rows = response[0] t.strictEqual(rows[0].solution, 2) done() }, function (error) { @@ -383,7 +383,7 @@ function basicQueryCallback (t) { } function basicQueryStream (stream, t) { - var results = 0 + let results = 0 stream.on('error', function (err) { t.ok(agent.currentSpan === null, 'mysql2 span should not be active in user code') t.error(err) @@ -404,8 +404,8 @@ function assertBasicQuery (t, sql, data) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 1) - var trans = data.transactions[0] - var span = data.spans[0] + const trans = data.transactions[0] + const span = data.spans[0] t.strictEqual(trans.name, 'foo') assertSpan(t, span, sql) diff --git a/test/instrumentation/modules/mysql2/pool-release-1.test.js b/test/instrumentation/modules/mysql2/pool-release-1.test.js index f95c2f8bd9..e4c3b5dfaa 100644 --- a/test/instrumentation/modules/mysql2/pool-release-1.test.js +++ b/test/instrumentation/modules/mysql2/pool-release-1.test.js @@ -19,7 +19,7 @@ if (semver.gte(mysql2Ver, '3.0.0') && semver.lt(process.version, '14.6.0')) { process.exit() } -var agent = require('../../../..').start({ +const agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -27,10 +27,10 @@ var agent = require('../../../..').start({ centralConfig: false }) -var mysql = require('mysql2') -var test = require('tape') +const mysql = require('mysql2') +const test = require('tape') -var utils = require('./_utils') +const utils = require('./_utils') test('release connection prior to transaction', function (t) { createPool(function (pool) { diff --git a/test/instrumentation/modules/next/next.test.js b/test/instrumentation/modules/next/next.test.js index 24ace91ace..0f5120aeb6 100644 --- a/test/instrumentation/modules/next/next.test.js +++ b/test/instrumentation/modules/next/next.test.js @@ -387,7 +387,7 @@ let TEST_REQUESTS = [ ] // Dev Note: To limit a test run to a particular test request, provide a // string value to DEV_TEST_FILTER that matches `testName`. -var DEV_TEST_FILTER = null +const DEV_TEST_FILTER = null if (DEV_TEST_FILTER) { TEST_REQUESTS = TEST_REQUESTS.filter(testReq => ~testReq.testName.indexOf(DEV_TEST_FILTER)) assert(TEST_REQUESTS.length > 0, 'DEV_TEST_FILTER should not result in an *empty* TEST_REQUESTS') diff --git a/test/instrumentation/modules/pg/_utils.js b/test/instrumentation/modules/pg/_utils.js index d1ee323e88..8f143e41ed 100644 --- a/test/instrumentation/modules/pg/_utils.js +++ b/test/instrumentation/modules/pg/_utils.js @@ -6,13 +6,13 @@ 'use strict' -var Client = require('pg').Client +const Client = require('pg').Client exports.reset = reset exports.loadData = loadData function reset (cb) { - var client = new Client({ + const client = new Client({ database: 'postgres', user: process.env.PGUSER || 'postgres' }) @@ -31,7 +31,7 @@ function reset (cb) { } function loadData (cb) { - var client = new Client({ + const client = new Client({ database: 'test_elastic_apm', user: process.env.PGUSER || 'postgres' }) @@ -41,7 +41,7 @@ function loadData (cb) { client.query('CREATE TABLE test (id serial NOT NULL, c1 varchar, c2 varchar)', function (err) { if (err) throw err - var sql = 'INSERT INTO test (c1, c2) ' + + const sql = 'INSERT INTO test (c1, c2) ' + 'VALUES (\'foo1\', \'bar1\'), ' + '(\'foo2\', \'bar2\'), ' + '(\'foo3\', \'bar3\'), ' + diff --git a/test/instrumentation/modules/pg/knex-no-span-stack-traces.test.js b/test/instrumentation/modules/pg/knex-no-span-stack-traces.test.js index 0bd0756e05..dbf56eb718 100644 --- a/test/instrumentation/modules/pg/knex-no-span-stack-traces.test.js +++ b/test/instrumentation/modules/pg/knex-no-span-stack-traces.test.js @@ -11,7 +11,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -var agent = require('../../../..').start({ +const agent = require('../../../..').start({ serviceName: 'test-knex-no-span-stack-traces', secretToken: 'test', captureExceptions: false, @@ -22,8 +22,8 @@ var agent = require('../../../..').start({ spanStackTraceMinDuration: -1 }) -var knexVersion = require('knex/package').version -var semver = require('semver') +const knexVersion = require('knex/package').version +const semver = require('semver') // knex 0.18.0 min supported node is v8, knex 0.21.0 min supported node is v10 if ((semver.gte(knexVersion, '0.18.0') && semver.lt(process.version, '8.6.0')) || @@ -38,8 +38,8 @@ if (semver.gte(knexVersion, '0.95.0') && agent._conf.contextManager === 'patch') process.exit() } -var Knex = require('knex') -var test = require('tape') +const Knex = require('knex') +const test = require('tape') test('knex instrumentation is disabled if not collecting span stacktraces', t => { // To test that knex instrumentation did *not* happen, we are assuming that diff --git a/test/instrumentation/modules/pg/knex.test.js b/test/instrumentation/modules/pg/knex.test.js index 1cac14eb39..5a452294f5 100644 --- a/test/instrumentation/modules/pg/knex.test.js +++ b/test/instrumentation/modules/pg/knex.test.js @@ -13,7 +13,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.env.ELASTIC_APM_TEST = true -var agent = require('../../../..').start({ +const agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -23,8 +23,8 @@ var agent = require('../../../..').start({ spanCompressionEnabled: false }) -var knexVersion = require('knex/package').version -var semver = require('semver') +const knexVersion = require('knex/package').version +const semver = require('semver') // knex 0.18.0 min supported node is v8, knex 0.21.0 min supported node is v10, knex 1.0.0 min supported node is v12 if ((semver.gte(knexVersion, '0.18.0') && semver.lt(process.version, '8.6.0')) || @@ -40,16 +40,16 @@ if (semver.gte(knexVersion, '0.95.0') && agent._conf.contextManager === 'patch') process.exit() } -var Knex = require('knex') -var test = require('tape') +const Knex = require('knex') +const test = require('tape') -var utils = require('./_utils') -var mockClient = require('../../../_mock_http_client') +const utils = require('./_utils') +const mockClient = require('../../../_mock_http_client') -var transNo = 0 -var knex +let transNo = 0 +let knex -var selectTests = [ +const selectTests = [ 'knex.select().from(\'test\')', 'knex.select(\'c1\', \'c2\').from(\'test\')', 'knex.column(\'c1\', \'c2\').select().from(\'test\')', @@ -60,7 +60,7 @@ if (semver.gte(knexVersion, '0.11.0')) { selectTests.push('knex.select().from(\'test\').timeout(10000)') } -var insertTests = [ +const insertTests = [ 'knex(\'test\').insert({c1: \'test1\', c2: \'test2\'})' ] @@ -73,7 +73,7 @@ selectTests.forEach(function (source) { createClient(t, function userLandCode () { agent.startTransaction('foo' + ++transNo) - var query = eval(source) // eslint-disable-line no-eval + const query = eval(source) // eslint-disable-line no-eval query.then(function (rows) { t.strictEqual(rows.length, 5) @@ -98,7 +98,7 @@ insertTests.forEach(function (source) { createClient(t, function userLandCode () { agent.startTransaction('foo' + ++transNo) - var query = eval(source) // eslint-disable-line no-eval + const query = eval(source) // eslint-disable-line no-eval query.then(function (result) { t.strictEqual(result.command, 'INSERT') @@ -119,10 +119,10 @@ test('knex.raw', function (t) { createClient(t, function userLandCode () { agent.startTransaction('foo' + ++transNo) - var query = knex.raw('SELECT * FROM "test"') + const query = knex.raw('SELECT * FROM "test"') query.then(function (result) { - var rows = result.rows + const rows = result.rows t.strictEqual(rows.length, 5) rows.forEach(function (row, i) { t.strictEqual(row.c1, 'foo' + (i + 1)) @@ -138,7 +138,7 @@ test('knex.raw', function (t) { function assertBasicQuery (t, data) { t.strictEqual(data.transactions.length, 1) - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, 'foo' + transNo) diff --git a/test/instrumentation/modules/pg/pg.test.js b/test/instrumentation/modules/pg/pg.test.js index 0985e21958..a107985db7 100644 --- a/test/instrumentation/modules/pg/pg.test.js +++ b/test/instrumentation/modules/pg/pg.test.js @@ -11,7 +11,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -var agent = require('../../../..').start({ +const agent = require('../../../..').start({ serviceName: 'test-pg', captureExceptions: false, metricsInterval: 0, @@ -20,25 +20,25 @@ var agent = require('../../../..').start({ spanCompressionEnabled: false }) -var semver = require('semver') -var once = require('once') -var pgVersion = require('pg/package.json').version +const semver = require('semver') +const once = require('once') +const pgVersion = require('pg/package.json').version -var test = require('tape') -var pg = require('pg') -var utils = require('./_utils') -var mockClient = require('../../../_mock_http_client') -var findObjInArray = require('../../../_utils').findObjInArray +const test = require('tape') +const pg = require('pg') +const utils = require('./_utils') +const mockClient = require('../../../_mock_http_client') +const findObjInArray = require('../../../_utils').findObjInArray -var queryable, connectionDone -var factories = [ +let queryable, connectionDone +const factories = [ [createClient, 'client'], [createPoolAndConnect, 'pool'] ] factories.forEach(function (f) { - var factory = f[0] - var type = f[1] + const factory = f[0] + const type = f[1] test('pg.' + factory.name, function (t) { t.on('end', teardown) @@ -115,7 +115,7 @@ factories.forEach(function (f) { }) var sql = 'SELECT 1 + 1 AS solution' factory(function () { - var trans = agent.startTransaction('foo') + const trans = agent.startTransaction('foo') queryable.query(sql) t.ok(agent.currentSpan === null, 'no currentSpan in sync code after pg .query') setTimeout(function () { @@ -136,7 +136,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + 1 AS solution' factory(function () { agent.startTransaction('foo') - var stream = queryable.query(new pg.Query(sql)) + const stream = queryable.query(new pg.Query(sql)) t.ok(agent.currentSpan === null, 'no currentSpan in sync code after pg .query') basicQueryStream(stream, t) }) @@ -152,7 +152,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + 1 AS solution' factory(function () { agent.startTransaction('foo') - var stream = queryable.query(sql) + const stream = queryable.query(sql) t.ok(agent.currentSpan === null, 'no currentSpan in sync code after pg .query') basicQueryStream(stream, t) }) @@ -166,7 +166,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + $1 AS solution' factory(function () { agent.startTransaction('foo') - var stream = queryable.query(sql, [1]) + const stream = queryable.query(sql, [1]) t.ok(agent.currentSpan === null, 'no currentSpan in sync code after pg .query') basicQueryStream(stream, t) }) @@ -180,7 +180,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + 1 AS solution' factory(function () { agent.startTransaction('foo') - var stream = queryable.query({ text: sql }) + const stream = queryable.query({ text: sql }) t.ok(agent.currentSpan === null, 'no currentSpan in sync code after pg .query') basicQueryStream(stream, t) }) @@ -194,7 +194,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + $1 AS solution' factory(function () { agent.startTransaction('foo') - var stream = queryable.query({ text: sql }, [1]) + const stream = queryable.query({ text: sql }, [1]) t.ok(agent.currentSpan === null, 'no currentSpan in sync code after pg .query') basicQueryStream(stream, t) }) @@ -208,7 +208,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + $1 AS solution' factory(function () { agent.startTransaction('foo') - var stream = queryable.query({ text: sql, values: [1] }) + const stream = queryable.query({ text: sql, values: [1] }) t.ok(agent.currentSpan === null, 'no currentSpan in sync code after pg .query') basicQueryStream(stream, t) }) @@ -227,7 +227,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + 1 AS solution' factory(function () { agent.startTransaction('foo') - var p = queryable.query(sql) + const p = queryable.query(sql) t.ok(agent.currentSpan === null, 'no currentSpan in sync code after pg .query') basicQueryPromise(p, t) }) @@ -241,7 +241,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + $1 AS solution' factory(function () { agent.startTransaction('foo') - var p = queryable.query(sql, [1]) + const p = queryable.query(sql, [1]) t.ok(agent.currentSpan === null, 'no currentSpan in sync code after pg .query') basicQueryPromise(p, t) }) @@ -255,7 +255,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + 1 AS solution' factory(function () { agent.startTransaction('foo') - var p = queryable.query({ text: sql }) + const p = queryable.query({ text: sql }) t.ok(agent.currentSpan === null, 'no currentSpan in sync code after pg .query') basicQueryPromise(p, t) }) @@ -269,7 +269,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + $1 AS solution' factory(function () { agent.startTransaction('foo') - var p = queryable.query({ text: sql }, [1]) + const p = queryable.query({ text: sql }, [1]) t.ok(agent.currentSpan === null, 'no currentSpan in sync code after pg .query') basicQueryPromise(p, t) }) @@ -283,7 +283,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + $1 AS solution' factory(function () { agent.startTransaction('foo') - var p = queryable.query({ text: sql, values: [1] }) + const p = queryable.query({ text: sql, values: [1] }) t.ok(agent.currentSpan === null, 'no currentSpan in sync code after pg .query') basicQueryPromise(p, t) }) @@ -297,7 +297,7 @@ factories.forEach(function (f) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 3) - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, 'foo') data.spans.forEach(function (span) { @@ -311,8 +311,8 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + $1 AS solution' factory(function () { - var n = 0 - var trans = agent.startTransaction('foo') + let n = 0 + const trans = agent.startTransaction('foo') queryable.query(sql, [1], function (err, result, fields) { t.error(err) @@ -341,7 +341,7 @@ factories.forEach(function (f) { resetAgent(6, function (data) { t.strictEqual(data.transactions.length, 3) t.strictEqual(data.spans.length, 3) - var names = data.transactions.map(function (trans) { + const names = data.transactions.map(function (trans) { return trans.name }).sort() t.deepEqual(names, ['bar', 'baz', 'foo']) @@ -360,7 +360,7 @@ factories.forEach(function (f) { factory(function () { setImmediate(function () { - var trans = agent.startTransaction('foo') + const trans = agent.startTransaction('foo') queryable.query(sql, [1], function (err, result, fields) { t.error(err) t.strictEqual(result.rows[0].solution, 2) @@ -369,7 +369,7 @@ factories.forEach(function (f) { }) setImmediate(function () { - var trans = agent.startTransaction('bar') + const trans = agent.startTransaction('bar') queryable.query(sql, [2], function (err, result, fields) { t.error(err) t.strictEqual(result.rows[0].solution, 3) @@ -378,7 +378,7 @@ factories.forEach(function (f) { }) setImmediate(function () { - var trans = agent.startTransaction('baz') + const trans = agent.startTransaction('baz') queryable.query(sql, [3], function (err, result, fields) { t.error(err) t.strictEqual(result.rows[0].solution, 4) @@ -396,7 +396,7 @@ test('simultaneous queries on different connections', function (t) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 3) - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, 'foo') data.spans.forEach(function (span) { @@ -410,8 +410,8 @@ test('simultaneous queries on different connections', function (t) { var sql = 'SELECT 1 + $1 AS solution' createPool(function (connector) { - var n = 0 - var trans = agent.startTransaction('foo') + let n = 0 + const trans = agent.startTransaction('foo') connector(function (err, client, release) { t.error(err) @@ -497,7 +497,7 @@ if (typeof pg.Client.prototype.query.on !== 'function' && teardown() }) - var sql = 'select \'not-a-uuid\' = \'00000000-0000-0000-0000-000000000000\'::uuid' + const sql = 'select \'not-a-uuid\' = \'00000000-0000-0000-0000-000000000000\'::uuid' createPool(function (connector) { agent.startTransaction('foo') @@ -533,7 +533,7 @@ function basicQueryCallback (t) { } function basicQueryStream (stream, t) { - var results = 0 + let results = 0 stream.on('error', function (err) { t.ok(agent.currentSpan === null, 'pg span should not be active in user code') t.error(err) @@ -565,10 +565,10 @@ function assertBasicQuery (t, sql, data) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 1) - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, 'foo') - var span = data.spans[0] + const span = data.spans[0] assertSpan(t, span, sql) } @@ -608,7 +608,7 @@ function createClient (cb) { function createPool (cb) { setup(function () { - var connector + let connector if (semver.satisfies(pgVersion, '<6.0.0')) { queryable = pg @@ -619,7 +619,7 @@ function createPool (cb) { }, cb) } } else { - var pool = new pg.Pool({ + const pool = new pg.Pool({ database: 'test_elastic_apm', user: process.env.PGUSER || 'postgres' }) diff --git a/test/instrumentation/modules/pug.test.js b/test/instrumentation/modules/pug.test.js index c905d25ad0..0c455131cf 100644 --- a/test/instrumentation/modules/pug.test.js +++ b/test/instrumentation/modules/pug.test.js @@ -13,7 +13,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.env.ELASTIC_APM_TEST = true -var agent = require('../../..').start({ +const agent = require('../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -22,18 +22,18 @@ var agent = require('../../..').start({ spanStackTraceMinDuration: 0 // Always have span stacktraces. }) -var pug = require('pug') -var test = require('tape') +const pug = require('pug') +const test = require('tape') -var mockClient = require('../../_mock_http_client') -var findObjInArray = require('../../_utils').findObjInArray +const mockClient = require('../../_mock_http_client') +const findObjInArray = require('../../_utils').findObjInArray test('pug compile and render', function userLandCode (t) { resetAgent(function (data) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 2) - var trans = data.transactions[0] + const trans = data.transactions[0] t.ok(/^foo\d$/.test(trans.name)) t.strictEqual(trans.type, 'custom') @@ -55,8 +55,8 @@ test('pug compile and render', function userLandCode (t) { agent.startTransaction('foo1') - var template = pug.compile('p Hello, #{name}!') - var output = template({ name: 'world' }) + const template = pug.compile('p Hello, #{name}!') + const output = template({ name: 'world' }) t.strictEqual(output, '

Hello, world!

', 'compiled string should be Hello,world!') agent.endTransaction() agent.flush() diff --git a/test/instrumentation/modules/redis-2-3.test.js b/test/instrumentation/modules/redis-2-3.test.js index dde9e141de..a5295c1229 100644 --- a/test/instrumentation/modules/redis-2-3.test.js +++ b/test/instrumentation/modules/redis-2-3.test.js @@ -11,14 +11,14 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -var redisVersion = require('redis/package.json').version -var semver = require('semver') +const redisVersion = require('redis/package.json').version +const semver = require('semver') if (semver.gte(redisVersion, '4.0.0')) { console.log('# SKIP: skipping redis-2-3.test.js tests >=4.0.0') process.exit(0) } -var agent = require('../../..').start({ +const agent = require('../../..').start({ serviceName: 'test-redis-2-3', captureExceptions: false, metricsInterval: 0, @@ -26,12 +26,12 @@ var agent = require('../../..').start({ spanCompressionEnabled: false }) -var redis = require('redis') +const redis = require('redis') -var test = require('tape') +const test = require('tape') -var findObjInArray = require('../../_utils').findObjInArray -var mockClient = require('../../_mock_http_client') +const findObjInArray = require('../../_utils').findObjInArray +const mockClient = require('../../_mock_http_client') test('redis', function (t) { resetAgent(function (data) { @@ -41,9 +41,9 @@ test('redis', function (t) { // does *not* have spans for each of the client commands. It *possibly* // (with contextManager="patch" it doesn't) has an "INFO" span for the // internal INFO command the RedisClient setup does. - var trans = findObjInArray(data.transactions, 'name', 'transBeforeClient') + let trans = findObjInArray(data.transactions, 'name', 'transBeforeClient') t.ok(trans, 'have "transBeforeClient" transaction') - var spans = data.spans.filter(s => s.transaction_id === trans.id) + let spans = data.spans.filter(s => s.transaction_id === trans.id) .filter(s => s.name !== 'INFO') t.equal(spans.length, 0, 'there are no non-INFO spans in the "transBeforeClient" transaction') @@ -56,7 +56,7 @@ test('redis', function (t) { t.ok(trans, 'have "transAfterClient" transaction') t.strictEqual(trans.result, 'success', 'trans.result') - var expectedSpanNames = [ + const expectedSpanNames = [ 'FLUSHALL', 'SET', 'SET', @@ -65,7 +65,7 @@ test('redis', function (t) { 'HKEYS' ] t.equal(spans.length, expectedSpanNames.length, 'have the expected number of spans') - for (var i = 0; i < expectedSpanNames.length; i++) { + for (let i = 0; i < expectedSpanNames.length; i++) { const expectedName = expectedSpanNames[i] const span = spans[i] t.strictEqual(span.transaction_id, trans.id, 'span.transaction_id') @@ -82,7 +82,7 @@ test('redis', function (t) { t.deepEqual(span.context.db, { type: 'redis' }, 'span.context.db') t.strictEqual(span.parent_id, trans.id, 'span is a child of the transaction') - var offset = span.timestamp - trans.timestamp + const offset = span.timestamp - trans.timestamp t.ok(offset + span.duration * 1000 < trans.duration * 1000, 'span ended before transaction ended') } @@ -98,16 +98,16 @@ test('redis', function (t) { // currentTransaction for the async task in which the redis client is created. // That's what `transBeforeClient` is: to make sure we *don't* get // double-spans. - var transBeforeClient = agent.startTransaction('transBeforeClient') + const transBeforeClient = agent.startTransaction('transBeforeClient') - var client = redis.createClient('6379', process.env.REDIS_HOST) + const client = redis.createClient('6379', process.env.REDIS_HOST) - var transAfterClient = agent.startTransaction('transAfterClient') + const transAfterClient = agent.startTransaction('transAfterClient') client.flushall(function (err, reply) { t.error(err, 'no flushall error') t.strictEqual(reply, 'OK', 'reply is OK') - var done = 0 + let done = 0 client.set('string key', 'string val', function (err, reply) { t.error(err) @@ -166,12 +166,12 @@ if (semver.satisfies(redisVersion, '>=3.0.0')) { // Simulate a redis client error with `enable_offline_queue: false` and a // quick `.set()` before the client connection ready. - var client = redis.createClient({ + const client = redis.createClient({ host: process.env.REDIS_HOST, port: '6379', enable_offline_queue: false }) - var t0 = agent.startTransaction('t0') + const t0 = agent.startTransaction('t0') client.set('k', 'v', function (err, reply) { t.ok(err, 'got error from client.set') t.equal(err.name, 'AbortError', 'error.name') @@ -201,9 +201,9 @@ test('client.cmd(...) call signatures', function (t) { t.end() }) - var client = redis.createClient('6379', process.env.REDIS_HOST) + const client = redis.createClient('6379', process.env.REDIS_HOST) client.on('ready', function () { - var t0 = agent.startTransaction('t0') + const t0 = agent.startTransaction('t0') // Use different call signatures to trigger the different forms of arguments // to the internal RedisClient.send_command that we are wrapping. @@ -235,9 +235,9 @@ if (semver.satisfies(redisVersion, '<=2.4.2')) { t.end() }) - var client = redis.createClient('6379', process.env.REDIS_HOST) + const client = redis.createClient('6379', process.env.REDIS_HOST) client.on('ready', function () { - var t0 = agent.startTransaction('t0') + const t0 = agent.startTransaction('t0') client.get(['k', myCb]) diff --git a/test/instrumentation/modules/tedious.test.js b/test/instrumentation/modules/tedious.test.js index 80fac5222d..dd49859f00 100644 --- a/test/instrumentation/modules/tedious.test.js +++ b/test/instrumentation/modules/tedious.test.js @@ -164,7 +164,7 @@ function assertTransaction (t, sql, data, spanCount) { t.strictEqual(data.transactions.length, 1, 'transaction count') t.strictEqual(data.spans.length, spanCount, 'span count') - var trans = data.transactions[0] + const trans = data.transactions[0] t.strictEqual(trans.name, 'foo', 'transaction name') } @@ -197,7 +197,7 @@ function assertBasicQuery (t, sql, data) { function assertPreparedQuery (t, sql, data) { assertTransaction(t, sql, data, 2) - var spans = sortSpansBy(data.spans, span => span.name) + const spans = sortSpansBy(data.spans, span => span.name) assertQuery(t, sql, spans[0], 'SELECT') assertQuery(t, sql, spans[1], 'SELECT (prepare)') } diff --git a/test/instrumentation/modules/ws.test.js b/test/instrumentation/modules/ws.test.js index c307526d19..ec36ea701f 100644 --- a/test/instrumentation/modules/ws.test.js +++ b/test/instrumentation/modules/ws.test.js @@ -11,24 +11,24 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -var agent = require('../../..').start({ +const agent = require('../../..').start({ serviceName: 'test-ws', captureExceptions: false, metricsInterval: 0, centralConfig: false }) -var test = require('tape') -var WebSocket = require('ws') +const test = require('tape') +const WebSocket = require('ws') -var mockClient = require('../../_mock_http_client') +const mockClient = require('../../_mock_http_client') -var PORT = 12342 +const PORT = 12342 test('ws.send', function (t) { resetAgent(done(t)) - var wss = new WebSocket.Server({ port: PORT }) + const wss = new WebSocket.Server({ port: PORT }) wss.on('connection', function (ws) { ws.on('message', function (message) { @@ -37,7 +37,7 @@ test('ws.send', function (t) { }) }) - var ws = new WebSocket('ws://localhost:' + PORT) + const ws = new WebSocket('ws://localhost:' + PORT) ws.on('open', function () { agent.startTransaction('foo', 'websocket') @@ -61,8 +61,8 @@ function done (t) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 1) - var trans = data.transactions[0] - var span = data.spans[0] + const trans = data.transactions[0] + const span = data.spans[0] t.strictEqual(trans.name, 'foo') t.strictEqual(trans.type, 'websocket') @@ -70,7 +70,7 @@ function done (t) { t.strictEqual(span.type, 'websocket') t.strictEqual(span.subtype, 'send') - var offset = span.timestamp - trans.timestamp + const offset = span.timestamp - trans.timestamp t.ok(offset + span.duration * 1000 < trans.duration * 1000) t.end() diff --git a/test/instrumentation/native-promises.test.js b/test/instrumentation/native-promises.test.js index 0781c93f6e..d52ceb0f26 100644 --- a/test/instrumentation/native-promises.test.js +++ b/test/instrumentation/native-promises.test.js @@ -6,14 +6,14 @@ 'use strict' -var agent = require('../..').start({ +const agent = require('../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false }) -var test = require('tape') +const test = require('tape') -var ins = agent._instrumentation +const ins = agent._instrumentation require('./_shared-promise-tests')(test, Promise, ins) diff --git a/test/instrumentation/run-context/fixtures/custom-instrumentation-sync.js b/test/instrumentation/run-context/fixtures/custom-instrumentation-sync.js index e197b5b037..412fa092b2 100644 --- a/test/instrumentation/run-context/fixtures/custom-instrumentation-sync.js +++ b/test/instrumentation/run-context/fixtures/custom-instrumentation-sync.js @@ -28,15 +28,15 @@ if (Number(process.versions.node.split('.')[0]) > 8) { assert = assert.strict } -var t1 = apm.startTransaction('t1') +const t1 = apm.startTransaction('t1') assert(apm.currentTransaction === t1) -var t2 = apm.startTransaction('t2') +const t2 = apm.startTransaction('t2') assert(apm.currentTransaction === t2) -var t3 = apm.startTransaction('t3') +const t3 = apm.startTransaction('t3') assert(apm.currentTransaction === t3) -var s4 = apm.startSpan('s4') +const s4 = apm.startSpan('s4') assert(apm.currentSpan === s4) -var s5 = apm.startSpan('s5') +const s5 = apm.startSpan('s5') assert(apm.currentSpan === s5) s4.end() // (out of order) assert(apm.currentSpan === s5) diff --git a/test/instrumentation/run-context/fixtures/ls-await.js b/test/instrumentation/run-context/fixtures/ls-await.js index 0c181070d8..39fd03144d 100644 --- a/test/instrumentation/run-context/fixtures/ls-await.js +++ b/test/instrumentation/run-context/fixtures/ls-await.js @@ -12,7 +12,7 @@ // `- span "cwd" // `- span "readdir" -var apm = require('../../../../').start({ // elastic-apm-node +const apm = require('../../../../').start({ // elastic-apm-node captureExceptions: false, metricsInterval: 0, cloudProvider: 'none', @@ -30,7 +30,7 @@ const fsp = require('fs').promises let t1 async function getCwd () { - var s2 = apm.startSpan('cwd') + const s2 = apm.startSpan('cwd') try { return process.cwd() } finally { @@ -47,7 +47,7 @@ async function main () { const cwd = await getCwd() let entries - var s3 = apm.startSpan('readdir') + const s3 = apm.startSpan('readdir') try { assert(apm.currentSpan === s3) entries = await fsp.readdir(cwd) diff --git a/test/instrumentation/run-context/fixtures/ls-promises.js b/test/instrumentation/run-context/fixtures/ls-promises.js index 14b4730cca..c3a7ae85e5 100644 --- a/test/instrumentation/run-context/fixtures/ls-promises.js +++ b/test/instrumentation/run-context/fixtures/ls-promises.js @@ -12,7 +12,7 @@ // `- span "cwd" // `- span "readdir" -var apm = require('../../../../').start({ // elastic-apm-node +const apm = require('../../../../').start({ // elastic-apm-node captureExceptions: false, metricsInterval: 0, cloudProvider: 'none', @@ -30,7 +30,7 @@ const fsp = require('fs').promises let t1 function getCwd () { - var s2 = apm.startSpan('cwd') + const s2 = apm.startSpan('cwd') try { return Promise.resolve(process.cwd()) } finally { @@ -47,7 +47,7 @@ function main () { .then(cwd => { assert(apm.currentTransaction === t1) assert(apm.currentSpan === null) - var s3 = apm.startSpan('readdir') + const s3 = apm.startSpan('readdir') assert(apm.currentSpan === s3) return fsp.readdir(cwd) .finally(() => { diff --git a/test/instrumentation/span-compression.test.js b/test/instrumentation/span-compression.test.js index 386b71dd9e..82ee8fcedc 100644 --- a/test/instrumentation/span-compression.test.js +++ b/test/instrumentation/span-compression.test.js @@ -122,12 +122,12 @@ tape.test('integration/end-to-end span compression tests', function (suite) { t.end() }) - var t0 = agent.startTransaction('t0') + const t0 = agent.startTransaction('t0') setImmediate(() => { - var s1 = t0.startSpan('s1', 'db', 'mysql', { exitSpan: true }) + const s1 = t0.startSpan('s1', 'db', 'mysql', { exitSpan: true }) setTimeout(() => { s1.end() - var s2 = t0.startSpan('s2', 'db', 'mysql', { exitSpan: true }) + const s2 = t0.startSpan('s2', 'db', 'mysql', { exitSpan: true }) setTimeout(() => { s2.end() t0.end() diff --git a/test/instrumentation/span.test.js b/test/instrumentation/span.test.js index 544cbcf8c9..34a3a2acc8 100644 --- a/test/instrumentation/span.test.js +++ b/test/instrumentation/span.test.js @@ -20,16 +20,16 @@ const agent = require('../..').start({ transport () { return new CapturingTransport() } }) -var test = require('tape') +const test = require('tape') -var assert = require('../_assert') -var Transaction = require('../../lib/instrumentation/transaction') -var Span = require('../../lib/instrumentation/span') +const assert = require('../_assert') +const Transaction = require('../../lib/instrumentation/transaction') +const Span = require('../../lib/instrumentation/span') test('init', function (t) { t.test('properties', function (t) { - var trans = new Transaction(agent) - var span = new Span(trans, 'sig', 'type') + const trans = new Transaction(agent) + const span = new Span(trans, 'sig', 'type') t.ok(/^[\da-f]{16}$/.test(span.id)) t.ok(/^[\da-f]{32}$/.test(span.traceId)) t.ok(/^[\da-f]{16}$/.test(span.parentId)) @@ -42,9 +42,9 @@ test('init', function (t) { }) t.test('options.childOf', function (t) { - var childOf = '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01' - var trans = new Transaction(agent) - var span = new Span(trans, 'sig', 'type', { childOf }) + const childOf = '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01' + const trans = new Transaction(agent) + const span = new Span(trans, 'sig', 'type', { childOf }) t.strictEqual(span._context.traceparent.version, '00') t.strictEqual(span._context.traceparent.traceId, '4bf92f3577b34da6a3ce929d0e0e4736') t.notEqual(span._context.traceparent.id, '00f067aa0ba902b7') @@ -127,8 +127,8 @@ test('init', function (t) { }) test('#end()', function (t) { - var trans = new Transaction(agent) - var span = new Span(trans, 'sig', 'type') + const trans = new Transaction(agent) + const span = new Span(trans, 'sig', 'type') t.strictEqual(span.ended, false) span.end() t.strictEqual(span.ended, true) @@ -136,8 +136,8 @@ test('#end()', function (t) { }) test('#duration()', function (t) { - var trans = new Transaction(agent) - var span = new Span(trans) + const trans = new Transaction(agent) + const span = new Span(trans) setTimeout(function () { span.end() t.ok(span.duration() > 49, span.duration() + ' should be larger than 49') @@ -146,28 +146,28 @@ test('#duration()', function (t) { }) test('#duration() - return null if not ended', function (t) { - var trans = new Transaction(agent) - var span = new Span(trans) + const trans = new Transaction(agent) + const span = new Span(trans) t.strictEqual(span.duration(), null) t.end() }) test('custom start time', function (t) { - var trans = new Transaction(agent) - var startTime = Date.now() - 1000 - var span = new Span(trans, 'sig', 'type', { childOf: trans, startTime }) + const trans = new Transaction(agent) + const startTime = Date.now() - 1000 + const span = new Span(trans, 'sig', 'type', { childOf: trans, startTime }) span.end() - var duration = span.duration() + const duration = span.duration() t.ok(duration > 990, `duration should be circa more than 1s (was: ${duration})`) // we've seen 998.752 in the wild t.ok(duration < 1100, `duration should be less than 1.1s (was: ${duration})`) t.end() }) test('#end(time)', function (t) { - var trans = new Transaction(agent) - var startTime = Date.now() - 1000 - var endTime = startTime + 2000.123 - var span = new Span(trans, 'sig', 'type', { childOf: trans, startTime }) + const trans = new Transaction(agent) + const startTime = Date.now() - 1000 + const endTime = startTime + 2000.123 + const span = new Span(trans, 'sig', 'type', { childOf: trans, startTime }) span.end(endTime) t.strictEqual(span.duration(), 2000.123) t.end() @@ -175,8 +175,8 @@ test('#end(time)', function (t) { test('#setLabel', function (t) { t.test('valid', function (t) { - var trans = new Transaction(agent) - var span = new Span(trans) + const trans = new Transaction(agent) + const span = new Span(trans) t.strictEqual(span._labels, null) t.strictEqual(span.setLabel(), false) t.strictEqual(span._labels, null) @@ -190,8 +190,8 @@ test('#setLabel', function (t) { }) t.test('invalid', function (t) { - var trans = new Transaction(agent) - var span = new Span(trans) + const trans = new Transaction(agent) + const span = new Span(trans) t.strictEqual(span._labels, null) t.strictEqual(span.setLabel(), false) t.strictEqual(span._labels, null) @@ -206,8 +206,8 @@ test('#setLabel', function (t) { }) test('#addLabels', function (t) { - var trans = new Transaction(agent) - var span = new Span(trans) + const trans = new Transaction(agent) + const span = new Span(trans) t.strictEqual(span._labels, null) t.strictEqual(span.setLabel(), false) @@ -240,13 +240,13 @@ test('#addLabels', function (t) { }) test('span.sync', function (t) { - var trans = agent.startTransaction() + const trans = agent.startTransaction() - var span1 = agent.startSpan('span1') + const span1 = agent.startSpan('span1') t.strictEqual(span1.sync, true) // This span will be *ended* synchronously. It should stay `span.sync=true`. - var span2 = agent.startSpan('span2') + const span2 = agent.startSpan('span2') t.strictEqual(span2.sync, true, 'span2.sync=true immediately after creation') span2.end() t.strictEqual(span2.sync, true, 'span2.sync=true immediately after end') @@ -262,8 +262,8 @@ test('span.sync', function (t) { }) test('#_encode() - un-ended', function (t) { - var trans = new Transaction(agent) - var span = new Span(trans) + const trans = new Transaction(agent) + const span = new Span(trans) span._encode(function (err, payload) { t.strictEqual(err.message, 'cannot encode un-ended span') t.end() @@ -271,9 +271,9 @@ test('#_encode() - un-ended', function (t) { }) test('#_encode() - ended unnamed', function myTest1 (t) { - var trans = new Transaction(agent) - var span = new Span(trans) - var timerStart = span._timer.start + const trans = new Transaction(agent) + const span = new Span(trans) + const timerStart = span._timer.start span.end() span._encode(function (err, payload) { t.error(err) @@ -296,9 +296,9 @@ test('#_encode() - ended unnamed', function myTest1 (t) { }) test('#_encode() - ended named', function myTest2 (t) { - var trans = new Transaction(agent) - var span = new Span(trans, 'foo', 'bar') - var timerStart = span._timer.start + const trans = new Transaction(agent) + const span = new Span(trans, 'foo', 'bar') + const timerStart = span._timer.start span.end() span._encode(function (err, payload) { t.error(err) @@ -321,9 +321,9 @@ test('#_encode() - ended named', function myTest2 (t) { }) test('#_encode() - with meta data', function myTest2 (t) { - var trans = new Transaction(agent) - var span = new Span(trans, 'foo', 'bar') - var timerStart = span._timer.start + const trans = new Transaction(agent) + const span = new Span(trans, 'foo', 'bar') + const timerStart = span._timer.start span.setDbContext({ statement: 'foo', type: 'bar' }) span.setLabel('baz', 1) span.end() @@ -354,9 +354,9 @@ test('#_encode() - disabled stack traces', function (t) { const oldValue = agent._conf.spanStackTraceMinDuration agent._conf.spanStackTraceMinDuration = -1 - var trans = new Transaction(agent) - var span = new Span(trans) - var timerStart = span._timer.start + const trans = new Transaction(agent) + const span = new Span(trans) + const timerStart = span._timer.start span.end() span._encode(function (err, payload) { t.error(err) @@ -381,8 +381,8 @@ test('#_encode() - disabled stack traces', function (t) { }) test('#ids', function (t) { - var trans = new Transaction(agent) - var span = new Span(trans) + const trans = new Transaction(agent) + const span = new Span(trans) t.deepLooseEqual(span.ids, { 'trace.id': span.traceId, 'span.id': span.id @@ -391,8 +391,8 @@ test('#ids', function (t) { }) test('#toString()', function (t) { - var trans = new Transaction(agent) - var span = new Span(trans) + const trans = new Transaction(agent) + const span = new Span(trans) t.strictEqual(span.toString(), `trace.id=${span.traceId} span.id=${span.id}`) t.end() }) diff --git a/test/instrumentation/timer.test.js b/test/instrumentation/timer.test.js index 034751e610..9ce7a064f4 100644 --- a/test/instrumentation/timer.test.js +++ b/test/instrumentation/timer.test.js @@ -6,19 +6,19 @@ 'use strict' -var test = require('tape') +const test = require('tape') -var Timer = require('../../lib/instrumentation/timer') +const Timer = require('../../lib/instrumentation/timer') test('started', function (t) { - var timer = new Timer() + const timer = new Timer() t.ok(timer.start > 0) t.strictEqual(timer.duration, null) t.end() }) test('ended', function (t) { - var timer = new Timer() + const timer = new Timer() timer.end() t.ok(timer.duration > 0) t.ok(timer.duration < 100) @@ -26,19 +26,19 @@ test('ended', function (t) { }) test('ended twice', function (t) { - var timer = new Timer() + const timer = new Timer() timer.end() - var duration = timer.duration + const duration = timer.duration timer.end() t.strictEqual(timer.duration, duration) t.end() }) test('elapsed', function (t) { - var timer = new Timer() - var e1 = timer.elapsed() + const timer = new Timer() + const e1 = timer.elapsed() process.nextTick(function () { - var e2 = timer.elapsed() + const e2 = timer.elapsed() t.ok(e2 > e1) timer.end() t.ok(timer.duration >= e2) @@ -48,8 +48,8 @@ test('elapsed', function (t) { }) test('custom start time', function (t) { - var startTime = Date.now() - 1000 - var timer = new Timer(null, startTime) + const startTime = Date.now() - 1000 + const timer = new Timer(null, startTime) t.strictEqual(timer.start, startTime * 1000) timer.end() t.ok(timer.duration > 990, `duration should be circa more than 1s (was: ${timer.duration})`) // we've seen 998.752 in the wild @@ -58,9 +58,9 @@ test('custom start time', function (t) { }) test('custom end time', function (t) { - var startTime = Date.now() - 1000 - var endTime = startTime + 2000.123 - var timer = new Timer(null, startTime) + const startTime = Date.now() - 1000 + const endTime = startTime + 2000.123 + const timer = new Timer(null, startTime) timer.end(endTime) t.strictEqual(timer.duration, 2000.123) t.end() diff --git a/test/instrumentation/transaction.test.js b/test/instrumentation/transaction.test.js index b5a0af09cc..cbf75362f1 100644 --- a/test/instrumentation/transaction.test.js +++ b/test/instrumentation/transaction.test.js @@ -20,14 +20,14 @@ const agent = require('../..').start({ transport () { return new CapturingTransport() } }) -var test = require('tape') +const test = require('tape') -var Transaction = require('../../lib/instrumentation/transaction') +const Transaction = require('../../lib/instrumentation/transaction') const Span = require('../../lib/instrumentation/span') test('init', function (t) { t.test('name and type', function (t) { - var trans = new Transaction(agent, 'name', 'type') + const trans = new Transaction(agent, 'name', 'type') t.ok(/^[\da-f]{16}$/.test(trans.id)) t.ok(/^[\da-f]{32}$/.test(trans.traceId)) t.ok(/^[\da-f]{2}-[\da-f]{32}-[\da-f]{16}-[\da-f]{2}$/.test(trans.traceparent)) @@ -39,8 +39,8 @@ test('init', function (t) { }) t.test('options.childOf', function (t) { - var childOf = '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01' - var trans = new Transaction(agent, 'name', 'type', { childOf }) + const childOf = '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01' + const trans = new Transaction(agent, 'name', 'type', { childOf }) t.strictEqual(trans._context.traceparent.version, '00') t.strictEqual(trans._context.traceparent.traceId, '4bf92f3577b34da6a3ce929d0e0e4736') t.notEqual(trans._context.traceparent.id, '00f067aa0ba902b7') @@ -102,7 +102,7 @@ test('init', function (t) { }) test('#setUserContext', function (t) { - var trans = new Transaction(agent) + const trans = new Transaction(agent) t.strictEqual(trans._user, null) trans.setUserContext() t.strictEqual(trans._user, null) @@ -118,7 +118,7 @@ test('#setUserContext', function (t) { }) test('#setCustomContext', function (t) { - var trans = new Transaction(agent) + const trans = new Transaction(agent) t.strictEqual(trans._custom, null) trans.setCustomContext() t.strictEqual(trans._custom, null) @@ -135,7 +135,7 @@ test('#setCustomContext', function (t) { test('#setLabel', function (t) { t.test('valid', function (t) { - var trans = new Transaction(agent) + const trans = new Transaction(agent) t.strictEqual(trans._labels, null) t.strictEqual(trans.setLabel(), false) t.strictEqual(trans._labels, null) @@ -149,7 +149,7 @@ test('#setLabel', function (t) { }) t.test('invalid', function (t) { - var trans = new Transaction(agent) + const trans = new Transaction(agent) t.strictEqual(trans._labels, null) t.strictEqual(trans.setLabel(), false) t.strictEqual(trans._labels, null) @@ -164,7 +164,7 @@ test('#setLabel', function (t) { }) test('#addLabels', function (t) { - var trans = new Transaction(agent) + const trans = new Transaction(agent) t.strictEqual(trans._labels, null) t.strictEqual(trans.setLabel(), false) @@ -198,8 +198,8 @@ test('#addLabels', function (t) { test('#startSpan()', function (t) { t.test('basic', function (t) { - var trans = new Transaction(agent) - var span = trans.startSpan('span-name', 'span-type') + const trans = new Transaction(agent) + const span = trans.startSpan('span-name', 'span-type') t.ok(span, 'should return a span') t.strictEqual(span.name, 'span-name') t.strictEqual(span.type, 'span-type') @@ -207,20 +207,20 @@ test('#startSpan()', function (t) { }) t.test('options.startTime', function (t) { - var trans = new Transaction(agent) - var startTime = Date.now() - 1000 - var span = trans.startSpan(null, null, { startTime }) + const trans = new Transaction(agent) + const startTime = Date.now() - 1000 + const span = trans.startSpan(null, null, { startTime }) span.end() - var duration = span.duration() + const duration = span.duration() t.ok(duration > 990, `duration should be circa more than 1s (was: ${duration})`) // we've seen 998.752 in the wild t.ok(duration < 1100, `duration should be less than 1.1s (was: ${duration})`) t.end() }) t.test('options.childOf', function (t) { - var trans = new Transaction(agent) - var childOf = '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01' - var span = trans.startSpan(null, null, { childOf }) + const trans = new Transaction(agent) + const childOf = '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01' + const span = trans.startSpan(null, null, { childOf }) t.strictEqual(span._context.traceparent.version, '00') t.strictEqual(span._context.traceparent.traceId, '4bf92f3577b34da6a3ce929d0e0e4736') t.notEqual(span._context.traceparent.id, '00f067aa0ba902b7') @@ -233,7 +233,7 @@ test('#startSpan()', function (t) { test('#end() - with result', function (t) { agent._apmClient.clear() - var trans = new Transaction(agent) + const trans = new Transaction(agent) trans.end('test-result') t.strictEqual(trans.ended, true) t.strictEqual(trans.result, 'test-result') @@ -248,7 +248,7 @@ test('#end() - with result', function (t) { test('#duration()', function (t) { agent._apmClient.clear() - var trans = new Transaction(agent) + const trans = new Transaction(agent) setTimeout(function () { trans.end() @@ -263,17 +263,17 @@ test('#duration()', function (t) { }) test('#duration() - un-ended transaction', function (t) { - var trans = new Transaction(agent) + const trans = new Transaction(agent) t.strictEqual(trans.duration(), null) t.end() }) test('custom start time', function (t) { - var startTime = Date.now() - 1000 - var trans = new Transaction(agent, null, null, { startTime }) + const startTime = Date.now() - 1000 + const trans = new Transaction(agent, null, null, { startTime }) trans.end() - var duration = trans.duration() + const duration = trans.duration() t.ok(duration > 990, `duration should be circa more than 1s (was: ${duration})`) // we've seen 998.752 in the wild t.ok(duration < 1100, `duration should be less than 1.1s (was: ${duration})`) @@ -281,9 +281,9 @@ test('custom start time', function (t) { }) test('#end(time)', function (t) { - var startTime = Date.now() - 1000 - var endTime = startTime + 2000.123 - var trans = new Transaction(agent, null, null, { startTime }) + const startTime = Date.now() - 1000 + const endTime = startTime + 2000.123 + const trans = new Transaction(agent, null, null, { startTime }) trans.end(null, endTime) t.strictEqual(trans.duration(), 2000.123) @@ -292,7 +292,7 @@ test('#end(time)', function (t) { }) test('#setDefaultName() - with initial value', function (t) { - var trans = new Transaction(agent, 'default-1') + const trans = new Transaction(agent, 'default-1') t.strictEqual(trans.name, 'default-1') trans.setDefaultName('default-2') t.strictEqual(trans.name, 'default-2') @@ -300,7 +300,7 @@ test('#setDefaultName() - with initial value', function (t) { }) test('#setDefaultName() - no initial value', function (t) { - var trans = new Transaction(agent) + const trans = new Transaction(agent) t.strictEqual(trans.name, 'unnamed') trans.setDefaultName('default') t.strictEqual(trans.name, 'default') @@ -308,7 +308,7 @@ test('#setDefaultName() - no initial value', function (t) { }) test('name - custom first, then default', function (t) { - var trans = new Transaction(agent) + const trans = new Transaction(agent) trans.name = 'custom' trans.setDefaultName('default') t.strictEqual(trans.name, 'custom') @@ -316,7 +316,7 @@ test('name - custom first, then default', function (t) { }) test('name - default first, then custom', function (t) { - var trans = new Transaction(agent) + const trans = new Transaction(agent) trans.setDefaultName('default') trans.name = 'custom' t.strictEqual(trans.name, 'custom') @@ -334,7 +334,7 @@ test('parallel transactions', function (t) { } setImmediate(function () { - var t1 = new Transaction(agent, 'first') + const t1 = new Transaction(agent, 'first') setTimeout(function () { t1.end() finish() @@ -342,7 +342,7 @@ test('parallel transactions', function (t) { }) setTimeout(function () { - var t2 = new Transaction(agent, 'second') + const t2 = new Transaction(agent, 'second') setTimeout(function () { t2.end() }, 25) @@ -350,7 +350,7 @@ test('parallel transactions', function (t) { }) test('#_encode() - un-ended', function (t) { - var trans = new Transaction(agent) + const trans = new Transaction(agent) t.strictEqual(trans._encode(), null, 'cannot encode un-ended transaction') t.end() }) @@ -358,8 +358,8 @@ test('#_encode() - un-ended', function (t) { test('#_encode() - ended', function (t) { agent._apmClient.clear() - var trans = new Transaction(agent) - var timerStart = trans._timer.start + const trans = new Transaction(agent) + const timerStart = trans._timer.start trans.end() const payload = agent._apmClient.transactions[0] @@ -382,8 +382,8 @@ test('#_encode() - ended', function (t) { test('#_encode() - with meta data', function (t) { agent._apmClient.clear() - var trans = new Transaction(agent, 'foo', 'bar') - var timerStart = trans._timer.start + const trans = new Transaction(agent, 'foo', 'bar') + const timerStart = trans._timer.start trans.result = 'baz' trans.setUserContext({ foo: 1 }) trans.setLabel('bar', 1) @@ -410,8 +410,8 @@ test('#_encode() - with meta data', function (t) { test('#_encode() - http request meta data', function (t) { agent._apmClient.clear() - var trans = new Transaction(agent) - var timerStart = trans._timer.start + const trans = new Transaction(agent) + const timerStart = trans._timer.start trans.req = mockRequest() trans.end() @@ -469,10 +469,10 @@ test('#_encode() - http request meta data', function (t) { }) test('#_encode() - with spans', function (t) { - var trans = new Transaction(agent, 'single-name', 'type') - var timerStart = trans._timer.start + const trans = new Transaction(agent, 'single-name', 'type') + const timerStart = trans._timer.start trans.result = 'result' - var span = trans.startSpan('span') + const span = trans.startSpan('span') span.end() trans.end() @@ -505,12 +505,12 @@ test('#_encode() - dropped spans', function (t) { const oldTransactionMaxSpans = agent._conf.transactionMaxSpans agent._conf.transactionMaxSpans = 2 - var trans = new Transaction(agent, 'single-name', 'type') - var timerStart = trans._timer.start + const trans = new Transaction(agent, 'single-name', 'type') + const timerStart = trans._timer.start trans.result = 'result' - var span0 = trans.startSpan('s0', 'type0') + const span0 = trans.startSpan('s0', 'type0') trans.startSpan('s1', 'type1') - var span2 = trans.startSpan('s2', { exitSpan: true }) + const span2 = trans.startSpan('s2', { exitSpan: true }) if (span2.isRecorded()) { t.fail('should have dropped the span') } @@ -549,12 +549,12 @@ test('#_encode() - not sampled', function (t) { const oldTransactionSampleRate = agent._conf.transactionSampleRate agent._conf.transactionSampleRate = 0 - var trans = new Transaction(agent, 'single-name', 'type') - var timerStart = trans._timer.start + const trans = new Transaction(agent, 'single-name', 'type') + const timerStart = trans._timer.start trans.result = 'result' trans.req = mockRequest() trans.res = mockResponse() - var span = trans.startSpan() + const span = trans.startSpan() t.notOk(span) trans.end() @@ -572,7 +572,7 @@ test('#_encode() - not sampled', function (t) { }) test('#ids', function (t) { - var trans = new Transaction(agent) + const trans = new Transaction(agent) t.deepLooseEqual(trans.ids, { 'trace.id': trans.traceId, 'transaction.id': trans.id @@ -581,7 +581,7 @@ test('#ids', function (t) { }) test('#toString()', function (t) { - var trans = new Transaction(agent) + const trans = new Transaction(agent) t.strictEqual(trans.toString(), `trace.id=${trans.traceId} transaction.id=${trans.id}`) t.end() }) @@ -667,8 +667,8 @@ function mockRequest () { } function mockResponse () { - var statusLine = 'HTTP/1.1 200 OK\r\n' - var msgHeaders = 'Date: Tue, 10 Jun 2014 07:29:20 GMT\r\n' + + const statusLine = 'HTTP/1.1 200 OK\r\n' + const msgHeaders = 'Date: Tue, 10 Jun 2014 07:29:20 GMT\r\n' + 'Connection: keep-alive\r\n' + 'Transfer-Encoding: chunked\r\n' + 'Age: foo\r\n' + diff --git a/test/integration/503.test.js b/test/integration/503.test.js index 5784371ce9..f31fff2609 100644 --- a/test/integration/503.test.js +++ b/test/integration/503.test.js @@ -6,10 +6,10 @@ 'use strict' -var getPort = require('get-port') +const getPort = require('get-port') getPort().then(function (port) { - var agent = require('../../').start({ + const agent = require('../../').start({ serviceName: 'test', serverUrl: 'http://localhost:' + port, captureExceptions: false, @@ -18,11 +18,11 @@ getPort().then(function (port) { disableInstrumentations: ['http'] // avoid the agent instrumenting the mock APM Server }) - var http = require('http') - var test = require('tape') + const http = require('http') + const test = require('tape') test('should not throw on 503', function (t) { - var server = http.createServer(function (req, res) { + const server = http.createServer(function (req, res) { res.statusCode = 503 res.setHeader('Content-Type', 'application/json') res.end('{"error":"something"}') diff --git a/test/integration/abort-on-invalid-cert.test.js b/test/integration/abort-on-invalid-cert.test.js index 28e2cf7a98..96b7b12f8f 100644 --- a/test/integration/abort-on-invalid-cert.test.js +++ b/test/integration/abort-on-invalid-cert.test.js @@ -6,24 +6,24 @@ 'use strict' -var getPort = require('get-port') +const getPort = require('get-port') getPort().then(function (port) { - var agent = require('../../').start({ + const agent = require('../../').start({ serviceName: 'test', serverUrl: 'https://localhost:' + port, metricsInterval: 0, centralConfig: false }) - var https = require('https') - var pem = require('https-pem') - var test = require('tape') + const https = require('https') + const pem = require('https-pem') + const test = require('tape') test('should not allow self signed certificate', function (t) { t.plan(1) - var server = https.createServer(pem, function (req, res) { + const server = https.createServer(pem, function (req, res) { // Gotcha: there's no way to know if the agent failed except setting // `logLevel < error` and looking at stderr, which is a bit cumbersome. // This is easier. diff --git a/test/integration/allow-invalid-cert.test.js b/test/integration/allow-invalid-cert.test.js index 0b2422b8fd..1674005b28 100644 --- a/test/integration/allow-invalid-cert.test.js +++ b/test/integration/allow-invalid-cert.test.js @@ -6,10 +6,10 @@ 'use strict' -var getPort = require('get-port') +const getPort = require('get-port') getPort().then(function (port) { - var agent = require('../../').start({ + const agent = require('../../').start({ serviceName: 'test-allow-invalid-cert', serverUrl: 'https://localhost:' + port, captureExceptions: false, @@ -20,14 +20,14 @@ getPort().then(function (port) { verifyServerCert: false }) - var https = require('https') - var pem = require('https-pem') - var test = require('tape') + const https = require('https') + const pem = require('https-pem') + const test = require('tape') test('should allow self signed certificate', function (t) { t.plan(3) - var server = https.createServer(pem, function (req, res) { + const server = https.createServer(pem, function (req, res) { t.pass('server received client request') res.end() }) diff --git a/test/integration/no-sampling.test.js b/test/integration/no-sampling.test.js index ded17988c4..1bab665720 100644 --- a/test/integration/no-sampling.test.js +++ b/test/integration/no-sampling.test.js @@ -6,11 +6,11 @@ 'use strict' -var getPort = require('get-port') -var ndjson = require('ndjson') +const getPort = require('get-port') +const ndjson = require('ndjson') getPort().then(function (port) { - var agent = require('../../').start({ + const agent = require('../../').start({ serviceName: 'test-no-sampling', serverUrl: 'http://localhost:' + port, captureExceptions: false, @@ -21,9 +21,9 @@ getPort().then(function (port) { apiRequestTime: '1s' }) - var http = require('http') - var zlib = require('zlib') - var test = require('tape') + const http = require('http') + const zlib = require('zlib') + const test = require('tape') test('should not sample', function (t) { var server = http.createServer(function (req, res) { @@ -57,7 +57,7 @@ getPort().then(function (port) { } function makeTransaction (cb) { - var trans = agent.startTransaction('foo', 'bar') + const trans = agent.startTransaction('foo', 'bar') setTimeout(function () { trans.end() process.nextTick(cb) diff --git a/test/integration/server-url-path.test.js b/test/integration/server-url-path.test.js index 23c7266d5e..74876d4117 100644 --- a/test/integration/server-url-path.test.js +++ b/test/integration/server-url-path.test.js @@ -6,10 +6,10 @@ 'use strict' -var getPort = require('get-port') +const getPort = require('get-port') getPort().then(function (port) { - var agent = require('../../').start({ + const agent = require('../../').start({ serviceName: 'test', serverUrl: 'http://localhost:' + port + '/sub', captureExceptions: false, @@ -19,8 +19,8 @@ getPort().then(function (port) { disableInstrumentations: ['http'] // avoid the agent instrumenting the mock APM Server }) - var http = require('http') - var test = require('tape') + const http = require('http') + const test = require('tape') test('should allow path in serverUrl', function (t) { var server = http.createServer(function (req, res) { diff --git a/test/integration/socket-close.test.js b/test/integration/socket-close.test.js index a85ef8bb53..3809d60229 100644 --- a/test/integration/socket-close.test.js +++ b/test/integration/socket-close.test.js @@ -6,10 +6,10 @@ 'use strict' -var getPort = require('get-port') +const getPort = require('get-port') getPort().then(function (port) { - var agent = require('../../').start({ + const agent = require('../../').start({ serviceName: 'test', serverUrl: 'http://localhost:' + port, captureExceptions: false, @@ -19,11 +19,11 @@ getPort().then(function (port) { disableInstrumentations: ['http'] // avoid the agent instrumenting the mock APM Server }) - var net = require('net') - var test = require('tape') + const net = require('net') + const test = require('tape') test('should not throw on socket close', function (t) { - var server = net.createServer(function (socket) { + const server = net.createServer(function (socket) { socket.destroy() }) diff --git a/test/integration/verify-server-ca-cert.test.js b/test/integration/verify-server-ca-cert.test.js index 09dbab94a5..18cd27ce7f 100644 --- a/test/integration/verify-server-ca-cert.test.js +++ b/test/integration/verify-server-ca-cert.test.js @@ -6,13 +6,13 @@ 'use strict' -var getPort = require('get-port') +const getPort = require('get-port') getPort().then(function (port) { - var fs = require('fs') - var path = require('path') + const fs = require('fs') + const path = require('path') - var agent = require('../../').start({ + const agent = require('../../').start({ serviceName: 'test', serverUrl: 'https://localhost:' + port, captureExceptions: false, @@ -23,16 +23,16 @@ getPort().then(function (port) { serverCaCertFile: path.join(__dirname, 'cert.pem') // self-signed certificate }) - var https = require('https') - var test = require('tape') + const https = require('https') + const test = require('tape') test('should allow self signed certificate', function (t) { t.plan(3) - var cert = fs.readFileSync(path.join(__dirname, 'cert.pem')) - var key = fs.readFileSync(path.join(__dirname, 'key.pem')) + const cert = fs.readFileSync(path.join(__dirname, 'cert.pem')) + const key = fs.readFileSync(path.join(__dirname, 'key.pem')) - var server = https.createServer({ cert, key }, function (req, res) { + const server = https.createServer({ cert, key }, function (req, res) { t.pass('server received client request') res.end() }) diff --git a/test/lambda/lambda.test.js b/test/lambda/lambda.test.js index 3edede27b0..3417ce2717 100644 --- a/test/lambda/lambda.test.js +++ b/test/lambda/lambda.test.js @@ -927,7 +927,7 @@ tape.test('lambda transactions', function (suite) { const wrappedHandler = apm.lambda(handler) // Save current and apply new config values. - var confToRestore = {} + const confToRestore = {} if (c.conf) { Object.keys(c.conf).forEach(k => { confToRestore[k] = apm._conf[k] diff --git a/test/lambda/metadata.test.js b/test/lambda/metadata.test.js index 274664ac18..b30fefebe3 100644 --- a/test/lambda/metadata.test.js +++ b/test/lambda/metadata.test.js @@ -90,7 +90,7 @@ tape.test('lambda config & metadata tests', function (suite) { t.error(err, `no error from executing the lambda handler: err=${JSON.stringify(err)}`) t.strictEqual(result, output) - var metadata = server.events[0].metadata + const metadata = server.events[0].metadata t.ok(metadata, 'got metadata') t.same(metadata.service.name, process.env.AWS_LAMBDA_FUNCTION_NAME, 'service.name') t.same(metadata.service.version, '42', 'service.version') diff --git a/test/lambda/metadata2.test.js b/test/lambda/metadata2.test.js index acf5880128..60b57c787b 100644 --- a/test/lambda/metadata2.test.js +++ b/test/lambda/metadata2.test.js @@ -69,7 +69,7 @@ tape.test('lambda metadata respects config settings', function (suite) { callback: function (err, result) { t.error(err, `no error from executing the lambda handler: err=${JSON.stringify(err)}`) - var metadata = server.events[0].metadata + const metadata = server.events[0].metadata t.ok(metadata, 'got metadata') t.same(metadata.service.name, 'my-service', 'service.name from serviceName config') t.same(metadata.service.version, '1.2.3', 'service.version from serviceVersion config') diff --git a/test/logging-preamble.test.js b/test/logging-preamble.test.js index ed7ed37431..80920fecb5 100644 --- a/test/logging-preamble.test.js +++ b/test/logging-preamble.test.js @@ -6,12 +6,12 @@ 'use strict' -var fs = require('fs') -var os = require('os') -var path = require('path') +const fs = require('fs') +const os = require('os') +const path = require('path') -var mkdirp = require('mkdirp') -var rimraf = require('rimraf') +const mkdirp = require('mkdirp') +const rimraf = require('rimraf') const test = require('tape') const AGENT_VERSION = require('../package.json').version diff --git a/test/metrics/breakdown.test.js b/test/metrics/breakdown.test.js index 04772892d9..4412382961 100644 --- a/test/metrics/breakdown.test.js +++ b/test/metrics/breakdown.test.js @@ -150,8 +150,8 @@ function waitForAgentToSendBreakdownMetrics (agent, waitCb) { test('includes breakdown when sampling', t => { const agent = new Agent().start(testAgentOpts) - var transaction = agent.startTransaction('foo', 'bar') - var span = agent.startSpan('s0 name', 's0 type') + const transaction = agent.startTransaction('foo', 'bar') + const span = agent.startSpan('s0 name', 's0 type') if (span) span.end() transaction.end() @@ -182,7 +182,7 @@ test('includes breakdown when sampling', t => { test('only transaction', t => { const agent = new Agent().start(testAgentOpts) - var transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) + const transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) transaction.end(null, 30) waitForAgentToSendBreakdownMetrics(agent, function (err) { @@ -206,8 +206,8 @@ test('only transaction', t => { test('with single sub-span', t => { const agent = new Agent().start(testAgentOpts) - var transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) - var span = agent.startSpan('SELECT *', 'db.mysql', { startTime: 10 }) + const transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) + const span = agent.startSpan('SELECT *', 'db.mysql', { startTime: 10 }) if (span) span.end(20) transaction.end(null, 30) @@ -239,8 +239,8 @@ test('with single sub-span', t => { test('with single app sub-span', t => { const agent = new Agent().start(testAgentOpts) - var transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) - var span = agent.startSpan('foo', 'app', { startTime: 10 }) + const transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) + const span = agent.startSpan('foo', 'app', { startTime: 10 }) if (span) span.end(20) transaction.end(null, 30) @@ -266,8 +266,8 @@ test('with single app sub-span', t => { test('with parallel sub-spans', t => { const agent = new Agent().start(testAgentOpts) - var transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) - var span0 + const transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) + let span0 setImmediate(function () { span0 = agent.startSpan('SELECT * FROM a', 'db.mysql', { startTime: 10 }) setImmediate(function () { @@ -279,7 +279,7 @@ test('with parallel sub-spans', t => { // transaction for the special case of (a) contextManager="patch" such that // we are using "patch-async.js" and (b) use of `agent.destroy(); new // Agent()`. The latter breaks patch-async's patching of setImmediate. - var span1 = agent.startSpan('SELECT * FROM b', 'db.mysql', + const span1 = agent.startSpan('SELECT * FROM b', 'db.mysql', { startTime: 10, childOf: transaction }) setImmediate(function () { if (span1) span1.end(20) @@ -315,8 +315,8 @@ test('with parallel sub-spans', t => { test('with overlapping sub-spans', t => { const agent = new Agent().start(testAgentOpts) - var transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) - var span0 + const transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) + let span0 setImmediate(function () { span0 = agent.startSpan('SELECT * FROM a', 'db.mysql', { startTime: 10 }) setImmediate(function () { @@ -325,7 +325,7 @@ test('with overlapping sub-spans', t => { }) setImmediate(function () { // See "childOf" comment above for why `childOf` is used here. - var span1 = agent.startSpan('SELECT * FROM b', 'db.mysql', + const span1 = agent.startSpan('SELECT * FROM b', 'db.mysql', { startTime: 15, childOf: transaction }) setImmediate(function () { if (span1) span1.end(25) @@ -363,10 +363,10 @@ test('with overlapping sub-spans', t => { test('with sequential sub-spans', t => { const agent = new Agent().start(testAgentOpts) - var transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) - var span0 = agent.startSpan('SELECT * FROM a', 'db.mysql', { startTime: 5 }) + const transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) + const span0 = agent.startSpan('SELECT * FROM a', 'db.mysql', { startTime: 5 }) if (span0) span0.end(15) - var span1 = agent.startSpan('SELECT * FROM b', 'db.mysql', { startTime: 15 }) + const span1 = agent.startSpan('SELECT * FROM b', 'db.mysql', { startTime: 15 }) if (span1) span1.end(25) transaction.end(null, 30) @@ -398,10 +398,10 @@ test('with sequential sub-spans', t => { test('with sub-spans returning to app time', t => { const agent = new Agent().start(testAgentOpts) - var transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) - var span0 = agent.startSpan('SELECT * FROM a', 'db.mysql', { startTime: 10 }) + const transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) + const span0 = agent.startSpan('SELECT * FROM a', 'db.mysql', { startTime: 10 }) if (span0) span0.end(15) - var span1 = agent.startSpan('SELECT * FROM b', 'db.mysql', { startTime: 20 }) + const span1 = agent.startSpan('SELECT * FROM b', 'db.mysql', { startTime: 20 }) if (span1) span1.end(25) transaction.end(null, 30) @@ -433,9 +433,9 @@ test('with sub-spans returning to app time', t => { test('with overlapping nested async sub-spans', t => { const agent = new Agent().start(testAgentOpts) - var transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) - var span0 = agent.startSpan('foo', 'app', { startTime: 10 }) - var span1 = agent.startSpan('SELECT *', 'db.mysql', { startTime: 15, childOf: span0 }) + const transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) + const span0 = agent.startSpan('foo', 'app', { startTime: 10 }) + const span1 = agent.startSpan('SELECT *', 'db.mysql', { startTime: 15, childOf: span0 }) if (span0) span0.end(20) if (span1) span1.end(25) transaction.end(null, 30) @@ -468,11 +468,11 @@ test('with overlapping nested async sub-spans', t => { test('with app sub-span extending beyond end', t => { const agent = new Agent().start(testAgentOpts) - var transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) - var span0 = agent.startSpan('foo', 'app', { startTime: 10 }) + const transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) + const span0 = agent.startSpan('foo', 'app', { startTime: 10 }) transaction.end(null, 20) // span1 is *not* created, because cannot create a span on an ended transaction. - var span1 = agent.startSpan('SELECT *', 'db.mysql', { startTime: 20, childOf: span0 }) + const span1 = agent.startSpan('SELECT *', 'db.mysql', { startTime: 20, childOf: span0 }) if (span0) span0.end(30) if (span1) span1.end(30) @@ -499,8 +499,8 @@ test('with app sub-span extending beyond end', t => { test('with other sub-span extending beyond end', t => { const agent = new Agent().start(testAgentOpts) - var transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) - var span = agent.startSpan('SELECT *', 'db.mysql', { startTime: 10 }) + const transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) + const span = agent.startSpan('SELECT *', 'db.mysql', { startTime: 10 }) transaction.end(null, 20) if (span) span.end(30) @@ -527,9 +527,9 @@ test('with other sub-span extending beyond end', t => { test('with other sub-span starting after end', t => { const agent = new Agent().start(testAgentOpts) - var transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) + const transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) transaction.end(null, 10) - var span = agent.startSpan('SELECT *', 'db.mysql', { startTime: 20, childOf: transaction }) + const span = agent.startSpan('SELECT *', 'db.mysql', { startTime: 20, childOf: transaction }) if (span) span.end(30) waitForAgentToSendBreakdownMetrics(agent, function (err) { diff --git a/test/outcome.test.js b/test/outcome.test.js index dda3fcf2e8..9ca7e04832 100644 --- a/test/outcome.test.js +++ b/test/outcome.test.js @@ -5,7 +5,7 @@ */ 'use strict' -var agent = require('..').start({ +const agent = require('..').start({ serviceName: 'test-outcome', captureExceptions: true, metricsInterval: 0, diff --git a/test/parsers.test.js b/test/parsers.test.js index 4abe20b86f..36ef6bd370 100644 --- a/test/parsers.test.js +++ b/test/parsers.test.js @@ -6,11 +6,11 @@ 'use strict' -var http = require('http') +const http = require('http') -var test = require('tape') +const test = require('tape') -var parsers = require('../lib/parsers') +const parsers = require('../lib/parsers') test('#getContextFromResponse()', function (t) { t.test('for error (before headers)', function (t) { @@ -21,7 +21,7 @@ test('#getContextFromResponse()', function (t) { res.sendDate = false - var context = parsers.getContextFromResponse(res, { captureHeaders: true }, true) + const context = parsers.getContextFromResponse(res, { captureHeaders: true }, true) t.deepEqual(context, { status_code: 200, headers: {}, @@ -42,7 +42,7 @@ test('#getContextFromResponse()', function (t) { res.sendDate = false res.write('foo') - var context = parsers.getContextFromResponse(res, { captureHeaders: true }, true) + const context = parsers.getContextFromResponse(res, { captureHeaders: true }, true) t.deepEqual(context, { status_code: 200, headers: { connection: 'close', 'transfer-encoding': 'chunked' }, @@ -57,7 +57,7 @@ test('#getContextFromResponse()', function (t) { t.test('for error (request finished)', function (t) { onRequest(function (req, res) { req.on('end', function () { - var context = parsers.getContextFromResponse(res, { captureHeaders: true }, true) + const context = parsers.getContextFromResponse(res, { captureHeaders: true }, true) t.deepEqual(context, { status_code: 200, headers: { connection: 'close', 'content-length': '0' }, @@ -76,7 +76,7 @@ test('#getContextFromResponse()', function (t) { t.test('for transaction', function (t) { onRequest(function (req, res) { req.on('end', function () { - var context = parsers.getContextFromResponse(res, { captureHeaders: true }, false) + const context = parsers.getContextFromResponse(res, { captureHeaders: true }, false) t.deepEqual(context, { status_code: 200, headers: { connection: 'close', 'content-length': '0' } @@ -91,8 +91,8 @@ test('#getContextFromResponse()', function (t) { test('#getContextFromRequest()', function (t) { t.test('should parse a request object', function (t) { - var conf = { captureHeaders: true, captureBody: 'off' } - var parsed = parsers.getContextFromRequest(getMockReq(), conf) + const conf = { captureHeaders: true, captureBody: 'off' } + const parsed = parsers.getContextFromRequest(getMockReq(), conf) t.deepEqual(parsed, { http_version: '1.1', method: 'GET', @@ -116,9 +116,9 @@ test('#getContextFromRequest()', function (t) { }) t.test('full URI', function (t) { - var req = getMockReq() + const req = getMockReq() req.url = 'https://www.example.com:8080/some/path?key=value' - var parsed = parsers.getContextFromRequest(req, {}) + const parsed = parsers.getContextFromRequest(req, {}) t.deepEqual(parsed.url, { pathname: '/some/path', search: '?key=value', @@ -132,9 +132,9 @@ test('#getContextFromRequest()', function (t) { }) t.test('port in host header', function (t) { - var req = getMockReq() + const req = getMockReq() req.headers.host = 'example.com:8080' - var parsed = parsers.getContextFromRequest(req, {}) + const parsed = parsers.getContextFromRequest(req, {}) t.deepEqual(parsed.url, { hostname: 'example.com', port: '8080', @@ -148,9 +148,9 @@ test('#getContextFromRequest()', function (t) { }) t.test('empty query string', function (t) { - var req = getMockReq() + const req = getMockReq() req.url = '/some/path?' - var parsed = parsers.getContextFromRequest(req, {}) + const parsed = parsers.getContextFromRequest(req, {}) t.deepEqual(parsed.url, { hostname: 'example.com', pathname: '/some/path', @@ -163,42 +163,42 @@ test('#getContextFromRequest()', function (t) { }) t.test('should not log body if opts.body is false', function (t) { - var conf = { captureBody: 'off' } - var req = getMockReq() + const conf = { captureBody: 'off' } + const req = getMockReq() req.body = 'secret stuff' req.headers['content-length'] = String(req.body.length) - var parsed = parsers.getContextFromRequest(req, conf) + const parsed = parsers.getContextFromRequest(req, conf) t.strictEqual(parsed.body, '[REDACTED]') t.end() }) t.test('body is object', function (t) { - var conf = { captureBody: 'all' } - var req = getMockReq() + const conf = { captureBody: 'all' } + const req = getMockReq() req.body = { foo: 42 } req.headers['content-length'] = JSON.stringify(req.body).length - var parsed = parsers.getContextFromRequest(req, conf) + const parsed = parsers.getContextFromRequest(req, conf) t.deepEqual(parsed.body, JSON.stringify({ foo: 42 })) t.end() }) t.test('body is object, but not safe to stringify', function (t) { - var conf = { captureBody: 'all' } - var req = getMockReq() + const conf = { captureBody: 'all' } + const req = getMockReq() req.body = { foo: 42 } req.body.bar = req.body req.headers['transfer-encoding'] = 'chunked' - var parsed = parsers.getContextFromRequest(req, conf) + const parsed = parsers.getContextFromRequest(req, conf) t.deepEqual(parsed.body, JSON.stringify({ foo: 42, bar: '[Circular]' })) t.end() }) t.test('body is an array', function (t) { - var conf = { captureBody: 'all' } - var req = getMockReq() + const conf = { captureBody: 'all' } + const req = getMockReq() req.body = [{ foo: 42 }] req.headers['content-length'] = JSON.stringify(req.body).length - var parsed = parsers.getContextFromRequest(req, conf) + const parsed = parsers.getContextFromRequest(req, conf) t.deepEqual(parsed.body, JSON.stringify([{ foo: 42 }])) t.end() }) @@ -235,14 +235,14 @@ test('#getContextFromRequest()', function (t) { }) function onRequest (cb) { - var server = http.createServer(cb) + const server = http.createServer(cb) server.listen(function () { - var opts = { + const opts = { agent: new http.Agent(), port: server.address().port } - var req = http.request(opts, function (res) { + const req = http.request(opts, function (res) { res.on('end', function () { server.close() }) diff --git a/test/redact-secrets/is-secret.test.js b/test/redact-secrets/is-secret.test.js index 4a15a7ecb2..d32dee6f32 100644 --- a/test/redact-secrets/is-secret.test.js +++ b/test/redact-secrets/is-secret.test.js @@ -34,8 +34,8 @@ require('../..').start({ disableSend: true }) -var test = require('tape') -var isSecret = require('../../lib/redact-secrets/is-secret') +const test = require('tape') +const isSecret = require('../../lib/redact-secrets/is-secret') test('isSecret.key true', function (t) { t.equal(isSecret.key('pass'), true) diff --git a/test/redact-secrets/redact-secrets.test.js b/test/redact-secrets/redact-secrets.test.js index d599a1d454..da8748ac4b 100644 --- a/test/redact-secrets/redact-secrets.test.js +++ b/test/redact-secrets/redact-secrets.test.js @@ -34,12 +34,12 @@ require('../..').start({ disableSend: true }) -var test = require('tape') -var clone = require('clone') -var redact = require('../../lib/redact-secrets') +const test = require('tape') +const clone = require('clone') +const redact = require('../../lib/redact-secrets') test('redact.map', function (t) { - var input = { + const input = { foo: 'non-secret', secret: 'secret', sub1: { @@ -52,7 +52,7 @@ test('redact.map', function (t) { }] } - var expected = { + const expected = { foo: 'non-secret', secret: 'redacted', sub1: { @@ -65,8 +65,8 @@ test('redact.map', function (t) { }] } - var orig = clone(input) - var result = redact('redacted').map(input) + const orig = clone(input) + const result = redact('redacted').map(input) t.deepEqual(result, expected) t.deepEqual(input, orig) @@ -74,7 +74,7 @@ test('redact.map', function (t) { }) test('redact.forEach', function (t) { - var input = { + const input = { foo: 'non-secret', secret: 'secret', sub1: { @@ -87,7 +87,7 @@ test('redact.forEach', function (t) { }] } - var expected = { + const expected = { foo: 'non-secret', secret: 'redacted', sub1: { @@ -100,7 +100,7 @@ test('redact.forEach', function (t) { }] } - var result = redact('redacted').forEach(input) + const result = redact('redacted').forEach(input) t.equal(result, undefined) t.deepEqual(input, expected) diff --git a/test/sanitize-field-names/hapi.test.js b/test/sanitize-field-names/hapi.test.js index 9abf8f9b2c..71f9842a97 100644 --- a/test/sanitize-field-names/hapi.test.js +++ b/test/sanitize-field-names/hapi.test.js @@ -15,7 +15,7 @@ const { } = require('./_shared') const agent = require('../..').start(createAgentConfig()) -var isHapiIncompat = require('../_is_hapi_incompat') +const isHapiIncompat = require('../_is_hapi_incompat') if (isHapiIncompat('@hapi/hapi')) { // Skip out of this test. process.exit() diff --git a/test/service-resource-inference.test.js b/test/service-resource-inference.test.js index 19061f93d2..e4d71d3d8e 100644 --- a/test/service-resource-inference.test.js +++ b/test/service-resource-inference.test.js @@ -28,7 +28,7 @@ test('setup: current trans', t => { t.end() }) -var testData = require('./fixtures/json-specs/service_resource_inference.json') +const testData = require('./fixtures/json-specs/service_resource_inference.json') testData.forEach(testDatum => { test(testDatum.failure_message, t => { // 1. Create a span according to `testDatum.span`. diff --git a/test/sourcemaps/index.test.js b/test/sourcemaps/index.test.js index 5ffef0b348..bbc20e9cf0 100644 --- a/test/sourcemaps/index.test.js +++ b/test/sourcemaps/index.test.js @@ -6,11 +6,11 @@ 'use strict' -var path = require('path') +const path = require('path') -var test = require('tape') +const test = require('tape') -var agent = require('../../').start({ +const agent = require('../../').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -46,7 +46,7 @@ test('fails', function (t) { t.strictEqual(error.exception.type, 'Error') t.strictEqual(error.culprit, `generateError (${path.join('test', 'sourcemaps', 'fixtures', 'lib', 'error-inline-broken.js')})`) - var frame = error.exception.stacktrace[0] + const frame = error.exception.stacktrace[0] t.strictEqual(frame.filename, path.join('test', 'sourcemaps', 'fixtures', 'lib', 'error-inline-broken.js')) t.strictEqual(frame.lineno, 6) t.strictEqual(frame.function, 'generateError') @@ -63,7 +63,7 @@ test('fails', function (t) { t.strictEqual(error.exception.type, 'Error') t.strictEqual(error.culprit, `generateError (${path.join('test', 'sourcemaps', 'fixtures', 'lib', 'error-map-missing.js')})`) - var frame = error.exception.stacktrace[0] + const frame = error.exception.stacktrace[0] t.strictEqual(frame.filename, path.join('test', 'sourcemaps', 'fixtures', 'lib', 'error-map-missing.js')) t.strictEqual(frame.lineno, 6) t.strictEqual(frame.function, 'generateError') @@ -80,7 +80,7 @@ test('fails', function (t) { t.strictEqual(error.exception.type, 'Error') t.strictEqual(error.culprit, `generateError (${path.join('test', 'sourcemaps', 'fixtures', 'lib', 'error-broken.js')})`) - var frame = error.exception.stacktrace[0] + const frame = error.exception.stacktrace[0] t.strictEqual(frame.filename, path.join('test', 'sourcemaps', 'fixtures', 'lib', 'error-broken.js')) t.strictEqual(frame.lineno, 6) t.strictEqual(frame.function, 'generateError') @@ -110,7 +110,7 @@ function assertSourceFound (t, error) { t.strictEqual(error.exception.type, 'Error') t.strictEqual(error.culprit, `generateError (${path.join('test', 'sourcemaps', 'fixtures', 'src', 'error.js')})`) - var frame = error.exception.stacktrace[0] + const frame = error.exception.stacktrace[0] t.strictEqual(frame.filename, path.join('test', 'sourcemaps', 'fixtures', 'src', 'error.js')) t.strictEqual(frame.lineno, 2) t.strictEqual(frame.function, 'generateError') @@ -126,7 +126,7 @@ function assertSourceNotFound (t, error) { t.strictEqual(error.exception.type, 'Error') t.strictEqual(error.culprit, `generateError (${path.join('test', 'sourcemaps', 'fixtures', 'src', 'not', 'found.js')})`) - var frame = error.exception.stacktrace[0] + const frame = error.exception.stacktrace[0] t.strictEqual(frame.filename, path.join('test', 'sourcemaps', 'fixtures', 'src', 'not', 'found.js')) t.strictEqual(frame.lineno, 2) t.strictEqual(frame.function, 'generateError') diff --git a/test/stacktraces/stacktraces.test.js b/test/stacktraces/stacktraces.test.js index 041eb5e956..0d2a3715ce 100644 --- a/test/stacktraces/stacktraces.test.js +++ b/test/stacktraces/stacktraces.test.js @@ -325,7 +325,7 @@ tape.test('gatherStackTrace()', function (suite) { } } - var cases = [ + const cases = [ { lines: 0, expectedContext: {} diff --git a/test/start/env/test.test.js b/test/start/env/test.test.js index 55263bec9e..4072c36b44 100644 --- a/test/start/env/test.test.js +++ b/test/start/env/test.test.js @@ -10,7 +10,7 @@ process.env.ELASTIC_APM_SERVICE_NAME = 'from-env' -var agent = require('../../..').start({ +const agent = require('../../..').start({ disableSend: true }) const tape = require('tape') diff --git a/test/start/file/test.test.js b/test/start/file/test.test.js index 66b06d2d24..6ac5b99248 100644 --- a/test/start/file/test.test.js +++ b/test/start/file/test.test.js @@ -11,7 +11,7 @@ process.chdir(__dirname) -var agent = require('../../..').start({ +const agent = require('../../..').start({ disableSend: true }) diff --git a/test/test.js b/test/test.js index 99c65c4e52..4f7b4fe48f 100644 --- a/test/test.js +++ b/test/test.js @@ -14,13 +14,13 @@ // // Run `node test/test.js -h` for usage. -var fs = require('fs') -var path = require('path') -var spawn = require('child_process').spawn +const fs = require('fs') +const path = require('path') +const spawn = require('child_process').spawn -var dashdash = require('dashdash') -var glob = require('glob') -var semver = require('semver') +const dashdash = require('dashdash') +const glob = require('glob') +const semver = require('semver') // ---- support functions @@ -31,7 +31,7 @@ function slugifyPath (f) { // Run a single test file. function runTestFile (test, cb) { - var args = [test.file] + const args = [test.file] if (semver.gte(process.version, '12.0.0')) { args.unshift('--unhandled-rejections=strict') } else { @@ -47,7 +47,7 @@ function runTestFile (test, cb) { } const outFile = fs.createWriteStream(outFileName) outFile.on('open', function () { - var ps = spawn('node', args, { + const ps = spawn('node', args, { stdio: ['inherit', outFile, outFile] }) ps.on('error', cb) @@ -78,7 +78,7 @@ function runTestFile (test, cb) { cb() return } - var ps = spawn('node', args, { + const ps = spawn('node', args, { stdio: 'inherit', env: test.env }) @@ -96,8 +96,8 @@ function runTestFile (test, cb) { } function series (tasks, cb) { - var results = [] - var pos = 0 + const results = [] + let pos = 0 function done (err, result) { if (err) return cb(err) @@ -125,7 +125,7 @@ function mapSeries (tasks, handler, cb) { // ---- mainline -var options = [ +const options = [ { names: ['help', 'h'], type: 'bool', @@ -146,7 +146,7 @@ var options = [ ] function main () { - var parser = dashdash.createParser({ options }) + const parser = dashdash.createParser({ options }) try { var opts = parser.parse(process.argv) } catch (e) { @@ -156,14 +156,14 @@ function main () { // Use `parser.help()` for formatted options help. if (opts.help) { - var help = parser.help().trimRight() + const help = parser.help().trimRight() console.log('usage: node test/test.js [OPTIONS]\n' + 'options:\n' + help) process.exit(0) } - var tests = glob + const tests = glob .sync( // Find all ".test.js" files, except those in "fixtures" dirs and in // "node_modules" dirs created for test packages. diff --git a/test/tracecontext/tracestate.test.js b/test/tracecontext/tracestate.test.js index c7f8946e38..2bc8d824dd 100644 --- a/test/tracecontext/tracestate.test.js +++ b/test/tracecontext/tracestate.test.js @@ -4,7 +4,7 @@ * compliance with the BSD 2-Clause License. */ -var test = require('tape') +const test = require('tape') const TraceState = require('../../lib/tracecontext/tracestate') test('TraceState binary format functionality', function (t) { diff --git a/test/transaction-sampling.test.js b/test/transaction-sampling.test.js index 03aa6476e1..170cce0cf1 100644 --- a/test/transaction-sampling.test.js +++ b/test/transaction-sampling.test.js @@ -35,13 +35,13 @@ tape.test('various transactionSampleRate values', function (t) { } )) - var results = { + const results = { count: count, numSampled: 0, numUnsampled: 0 } - for (var i = 0; i < count; i++) { - var trans = agent.startTransaction('myTrans') + for (let i = 0; i < count; i++) { + const trans = agent.startTransaction('myTrans') if (trans && trans.sampled) { results.numSampled++ } else { @@ -95,11 +95,11 @@ tape.test('APM Server =v8.0 (which does not want unsampled transactions)', func suite.test('unsampled transactions are not sent', function (t) { // Start and end a transaction with some spans. - var t0 = agent.startTransaction('t0') - var s0 = agent.startSpan('s0', 'type') + const t0 = agent.startTransaction('t0') + const s0 = agent.startSpan('s0', 'type') process.nextTick(function () { if (s0) s0.end() - var s1 = agent.startSpan('s1', 'type') + const s1 = agent.startSpan('s1', 'type') t.ok(s1 === null, 'no span should be started for an unsampled transaction') process.nextTick(function () { if (s1) s1.end() diff --git a/test/wildcard-matcher.test.js b/test/wildcard-matcher.test.js index b6ca3cacc2..33383e8c2d 100644 --- a/test/wildcard-matcher.test.js +++ b/test/wildcard-matcher.test.js @@ -5,7 +5,7 @@ */ 'use strict' -var test = require('tape') +const test = require('tape') const { WildcardMatcher } = require('../lib/wildcard-matcher') From 3ca80e592e366f117a5088c6fdbebfa917251a7e Mon Sep 17 00:00:00 2001 From: jacques metevier Date: Wed, 7 Jun 2023 16:32:28 -0700 Subject: [PATCH 04/10] chore rm no var and allow warnings --- .eslintrc.json | 1 - package.json | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index a5692d90ae..6accbda566 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -7,7 +7,6 @@ "plugins": ["license-header"], "rules": { "license-header/header": ["error", "./dev-utils/license-header.js"], - "no-var":0, "array-callback-return":0 }, "ignorePatterns": [ diff --git a/package.json b/package.json index afbd173714..2eb9e368bc 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "docs:open": "PREVIEW=1 npm run docs:build", "docs:build": "./docs/scripts/build_docs.sh apm-agent-nodejs ./docs ./build", "lint": "npm run lint:eslint && npm run lint:license-files && npm run lint:yaml-files && npm run lint:tav", - "lint:eslint": "eslint . # requires node >10", + "lint:eslint": "eslint . --max-warnings=144 # requires node >10", "lint:fix": "eslint --fix . # requires node >10", "lint:license-files": "./dev-utils/gen-notice.sh --lint . # requires node >=16", "lint:yaml-files": "./dev-utils/lint-yaml-files.sh # requires node >=10", From 8bbbb55da6d0ea4a82b6c5316ac3a391009e27b1 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Fri, 9 Jun 2023 14:20:06 -0700 Subject: [PATCH 05/10] eslint config: no-var=off except in examples/; re-enable array-callback-return --- .eslintrc.json | 14 ++++++++++++-- examples/.eslintrc.json | 5 +++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 examples/.eslintrc.json diff --git a/.eslintrc.json b/.eslintrc.json index 6accbda566..dd03081332 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -4,10 +4,20 @@ "node": true }, "extends": "standard", - "plugins": ["license-header"], + "plugins": [ + "license-header" + ], "rules": { "license-header/header": ["error", "./dev-utils/license-header.js"], - "array-callback-return":0 + // Regarding "no-var": The opinion of this repository's maintainers is that + // while const/let are useful, the use of `var` is not bad and therefore + // does not need to be ruled out. Eliminating the use of `var` would be a + // large diff that (a) could theoretically cause bugs due to lexical scoping + // changes and (b) could theoretically impact perf (e.g. see + // https://github.com/microsoft/TypeScript/issues/52924). New code MAY + // prefer const/let over `var`. Code in "examples/" MUST use const/let -- + // this is enforced by "examples/.eslintrc.json". + "no-var": "off" }, "ignorePatterns": [ "/*.example.js", // a pattern for uncommited local dev files to avoid linting diff --git a/examples/.eslintrc.json b/examples/.eslintrc.json new file mode 100644 index 0000000000..c731943471 --- /dev/null +++ b/examples/.eslintrc.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-var": ["error"] + } +} From 9738a3d7f63f8a571de67a75b549c67155c2b648 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Fri, 9 Jun 2023 14:21:07 -0700 Subject: [PATCH 06/10] Revert "chore lint auto fixes" This reverts commit 1727021b659c393982a775deecb3f4d7cb488e8c. --- dev-utils/bitrot.js | 46 +-- examples/trace-graphql.js | 6 +- examples/trace-handlebars.js | 2 +- examples/trace-pg.js | 2 +- examples/trace-pug.js | 2 +- examples/trace-tedious.js | 2 +- examples/trace-ws.js | 4 +- index.js | 2 +- lib/activation-method.js | 2 +- lib/agent.js | 16 +- lib/config/config.js | 2 +- lib/errors.js | 16 +- lib/http-request.js | 4 +- lib/instrumentation/context.js | 2 +- lib/instrumentation/elasticsearch-shared.js | 2 +- lib/instrumentation/express-utils.js | 8 +- lib/instrumentation/generic-span.js | 4 +- lib/instrumentation/http-shared.js | 24 +- lib/instrumentation/index.js | 22 +- lib/instrumentation/modules/@apollo/server.js | 2 +- .../modules/apollo-server-core.js | 2 +- lib/instrumentation/modules/bluebird.js | 16 +- lib/instrumentation/modules/elasticsearch.js | 12 +- .../modules/express-graphql.js | 6 +- lib/instrumentation/modules/express-queue.js | 6 +- lib/instrumentation/modules/express.js | 22 +- lib/instrumentation/modules/finalhandler.js | 6 +- lib/instrumentation/modules/generic-pool.js | 24 +- lib/instrumentation/modules/graphql.js | 26 +- lib/instrumentation/modules/handlebars.js | 4 +- lib/instrumentation/modules/hapi.js | 18 +- lib/instrumentation/modules/http.js | 10 +- lib/instrumentation/modules/http2.js | 52 +-- lib/instrumentation/modules/https.js | 6 +- lib/instrumentation/modules/jade.js | 4 +- lib/instrumentation/modules/knex.js | 12 +- lib/instrumentation/modules/koa-router.js | 10 +- lib/instrumentation/modules/memcached.js | 8 +- lib/instrumentation/modules/mimic-response.js | 4 +- lib/instrumentation/modules/mongodb-core.js | 34 +- lib/instrumentation/modules/mysql.js | 26 +- lib/instrumentation/modules/mysql2.js | 14 +- lib/instrumentation/modules/pg.js | 16 +- lib/instrumentation/modules/pug.js | 4 +- lib/instrumentation/modules/redis.js | 10 +- lib/instrumentation/modules/tedious.js | 8 +- lib/instrumentation/modules/ws.js | 4 +- lib/instrumentation/patch-async.js | 92 ++--- lib/instrumentation/shimmer.js | 12 +- lib/instrumentation/span.js | 14 +- lib/instrumentation/template-shared.js | 12 +- lib/instrumentation/timer.js | 2 +- lib/instrumentation/transaction.js | 24 +- lib/lambda.js | 2 +- lib/load-source-map.js | 22 +- lib/logging.js | 6 +- lib/middleware/connect.js | 2 +- lib/opentelemetry-bridge/OTelSpan.js | 2 +- .../ElasticApmMetricExporter.js | 2 +- lib/parsers.js | 20 +- lib/propwrap.js | 10 +- lib/redact-secrets/index.js | 4 +- lib/redact-secrets/is-secret.js | 4 +- lib/stacktraces.js | 22 +- test/InflightEventSet.test.js | 2 +- test/_agent.js | 10 +- test/_assert.js | 16 +- test/_is_fastify_incompat.js | 2 +- test/_is_hapi_incompat.js | 6 +- test/_is_mongodb_incompat.js | 2 +- test/_is_restify_incompat.js | 2 +- test/_is_undici_incompat.js | 2 +- test/_mock_apm_server.js | 4 +- test/_utils.js | 8 +- .../activation-method.test.js | 2 +- test/agent.test.js | 88 ++--- test/apm-client/http-apm-client.test.js | 2 +- ...001-transaction-and-span-no-stack-trace.js | 2 +- ...action-and-span-overhead-realistic-size.js | 10 +- ...3-transaction-and-span-with-stack-trace.js | 2 +- test/benchmarks/004-transaction.js | 2 +- .../005-transaction-reading-file.js | 6 +- ...verhead-realistic-size-with-stack-trace.js | 10 +- test/config.test.js | 200 +++++------ test/connect.test.js | 4 +- test/errors.test.js | 4 +- test/fixtures/do-not-trace-self.js | 2 +- test/http-request.test.js | 2 +- test/instrumentation/_async-await.js | 4 +- test/instrumentation/_shared-promise-tests.js | 42 +-- test/instrumentation/async-await.test.js | 18 +- test/instrumentation/context.test.js | 4 +- test/instrumentation/core-async-apis.test.js | 30 +- test/instrumentation/fs.test.js | 4 +- test/instrumentation/index.test.js | 124 +++---- .../modules/@apollo/server.test.js | 6 +- .../modules/apollo-server-express.test.js | 124 +++---- .../modules/aws-sdk/dynamodb.test.js | 12 +- .../modules/aws-sdk/fixtures/use-s3.js | 2 +- .../modules/bluebird/_coroutine.js | 18 +- .../modules/bluebird/bluebird.test.js | 320 +++++++++--------- .../modules/bluebird/cancel.test.js | 26 +- .../modules/elasticsearch.test.js | 58 ++-- .../modules/express-queue.test.js | 32 +- .../modules/express/basic.test.js | 88 ++--- .../modules/fastify/fastify.test.js | 2 +- .../modules/finalhandler.test.js | 32 +- .../modules/generic-pool.test.js | 26 +- test/instrumentation/modules/graphql.test.js | 86 ++--- .../modules/handlebars.test.js | 14 +- .../hapi/set-framework-hapihapi.test.js | 2 +- test/instrumentation/modules/hapi/shared.js | 60 ++-- test/instrumentation/modules/http/_assert.js | 2 +- .../modules/http/_echo_server.js | 12 +- .../modules/http/_echo_server_util.js | 10 +- .../http/aborted-requests-disabled.test.js | 30 +- .../http/aborted-requests-enabled.test.js | 62 ++-- .../modules/http/basic.test.js | 22 +- .../bind-write-head-to-transaction.test.js | 12 +- .../modules/http/github-179.test.js | 22 +- .../modules/http/github-423.test.js | 28 +- .../ignore-url-does-not-leak-trans.test.js | 10 +- .../modules/http/ignoring.test.js | 10 +- .../http/node-prefixed-http-require.test.js | 2 +- .../modules/http/outgoing.test.js | 84 ++--- .../modules/http/request.test.js | 26 +- test/instrumentation/modules/http/sse.test.js | 26 +- test/instrumentation/modules/http2.test.js | 134 ++++---- test/instrumentation/modules/ioredis.test.js | 28 +- .../modules/koa-router/shared.js | 24 +- .../instrumentation/modules/memcached.test.js | 12 +- .../modules/mimic-response.test.js | 10 +- .../modules/mongodb-core.test.js | 24 +- test/instrumentation/modules/mysql/_utils.js | 6 +- .../modules/mysql/mysql.test.js | 78 ++--- .../modules/mysql/pool-release-1.test.js | 8 +- test/instrumentation/modules/mysql2/_utils.js | 6 +- .../modules/mysql2/mysql.test.js | 100 +++--- .../modules/mysql2/pool-release-1.test.js | 8 +- .../instrumentation/modules/next/next.test.js | 2 +- test/instrumentation/modules/pg/_utils.js | 8 +- .../pg/knex-no-span-stack-traces.test.js | 10 +- test/instrumentation/modules/pg/knex.test.js | 32 +- test/instrumentation/modules/pg/pg.test.js | 82 ++--- test/instrumentation/modules/pug.test.js | 16 +- .../instrumentation/modules/redis-2-3.test.js | 44 +-- test/instrumentation/modules/tedious.test.js | 4 +- test/instrumentation/modules/ws.test.js | 20 +- test/instrumentation/native-promises.test.js | 6 +- .../fixtures/custom-instrumentation-sync.js | 10 +- .../run-context/fixtures/ls-await.js | 6 +- .../run-context/fixtures/ls-promises.js | 6 +- test/instrumentation/span-compression.test.js | 6 +- test/instrumentation/span.test.js | 100 +++--- test/instrumentation/timer.test.js | 28 +- test/instrumentation/transaction.test.js | 110 +++--- test/integration/503.test.js | 10 +- .../integration/abort-on-invalid-cert.test.js | 12 +- test/integration/allow-invalid-cert.test.js | 12 +- test/integration/no-sampling.test.js | 14 +- test/integration/server-url-path.test.js | 8 +- test/integration/socket-close.test.js | 10 +- .../integration/verify-server-ca-cert.test.js | 18 +- test/lambda/lambda.test.js | 2 +- test/lambda/metadata.test.js | 2 +- test/lambda/metadata2.test.js | 2 +- test/logging-preamble.test.js | 10 +- test/metrics/breakdown.test.js | 58 ++-- test/outcome.test.js | 2 +- test/parsers.test.js | 60 ++-- test/redact-secrets/is-secret.test.js | 4 +- test/redact-secrets/redact-secrets.test.js | 20 +- test/sanitize-field-names/hapi.test.js | 2 +- test/service-resource-inference.test.js | 2 +- test/sourcemaps/index.test.js | 16 +- test/stacktraces/stacktraces.test.js | 2 +- test/start/env/test.test.js | 2 +- test/start/file/test.test.js | 2 +- test/test.js | 30 +- test/tracecontext/tracestate.test.js | 2 +- test/transaction-sampling.test.js | 20 +- test/wildcard-matcher.test.js | 2 +- 182 files changed, 1960 insertions(+), 1960 deletions(-) diff --git a/dev-utils/bitrot.js b/dev-utils/bitrot.js index 33c5949866..6f0cce2ba2 100755 --- a/dev-utils/bitrot.js +++ b/dev-utils/bitrot.js @@ -82,7 +82,7 @@ function saveCache () { // - Bad: blue (not visible on cmd.exe), grey (same color as background on // Solarized Dark theme from , see // issue #160) -const colors = { +var colors = { bold: [1, 22], italic: [3, 23], underline: [4, 24], @@ -100,7 +100,7 @@ const colors = { function stylizeWithColor (str, color) { if (!str) { return '' } - const codes = colors[color] + var codes = colors[color] if (codes) { return '\x1B[' + codes[0] + 'm' + str + '\x1B[' + codes[1] + 'm' } else { @@ -131,9 +131,9 @@ function rot (moduleName, s) { // I see in supported-technologies.asciidoc. function loadSupportedDoc () { const docPath = 'docs/supported-technologies.asciidoc' - const html = fs.readFileSync(docPath, 'utf8') - const rows = [] - let state = null // null | 'thead' | 'tbody' + var html = fs.readFileSync(docPath, 'utf8') + var rows = [] + var state = null // null | 'thead' | 'tbody' html.split(/\n/g).forEach(function (line) { if (!line.startsWith('|')) { // no op @@ -150,8 +150,8 @@ function loadSupportedDoc () { // Examples: // |https://www.npmjs.com/package/generic-pool[generic-pool] | ^2.0.0 \|\| ^3.1.0 |Used by a lot of ... // |https://www.npmjs.com/package/bluebird[bluebird] |>=2.0.0 <4.0.0 | - const escapePlaceholder = '6B1EC7E1-B273-40E9-94C4-197A59B55E24' - const cells = line + var escapePlaceholder = '6B1EC7E1-B273-40E9-94C4-197A59B55E24' + var cells = line .trim() .slice(1) // remove leading '|' .replace(/\\\|/g, escapePlaceholder) @@ -177,7 +177,7 @@ function loadSupportedDoc () { // The entries in the "Frameworks" table use the names of internal links in // these docs. The anchor name is *sometimes* the same name as the npm // module, but sometimes not. - const results = [] + var results = [] let match rows.forEach(function (row) { if (row[1] === 'N/A') { @@ -187,7 +187,7 @@ function loadSupportedDoc () { if (!match) { throw new Error(`could not parse this table cell text from docs/supported-technologies.asciidoc: ${JSON.stringify(row[0])}`) } - let moduleNames + var moduleNames if (match[1] === 'nextjs') { moduleNames = ['next'] } else if (match[2] === '@hapi/hapi') { @@ -246,24 +246,24 @@ function getNpmInfo (name) { function bitrot (moduleNames) { log.debug({ moduleNames }, 'bitrot') - const tavYmls = [ + var tavYmls = [ yaml.load(fs.readFileSync('.tav.yml', 'utf8')), yaml.load(fs.readFileSync('./test/opentelemetry-bridge/.tav.yml', 'utf8')), yaml.load(fs.readFileSync('./test/opentelemetry-metrics/fixtures/.tav.yml', 'utf8')), yaml.load(fs.readFileSync('test/instrumentation/modules/next/a-nextjs-app/.tav.yml', 'utf8')) ] - const supported = loadSupportedDoc() + var supported = loadSupportedDoc() // Merge into one data structure we can iterate through. - const rangesFromName = {} - const ensureKey = (name) => { + var rangesFromName = {} + var ensureKey = (name) => { if (!(name in rangesFromName)) { rangesFromName[name] = { tavRanges: [], supRanges: [] } } } tavYmls.forEach(tavYml => { for (const [label, tavInfo] of Object.entries(tavYml)) { - const name = tavInfo.name || label + var name = tavInfo.name || label ensureKey(name) rangesFromName[name].tavRanges.push(tavInfo.versions) } @@ -275,7 +275,7 @@ function bitrot (moduleNames) { // Reduce to `moduleNames` if given. if (moduleNames && moduleNames.length > 0) { - const allNames = Object.keys(rangesFromName) + var allNames = Object.keys(rangesFromName) moduleNames.forEach(name => { if (!(name in rangesFromName)) { throw new Error(`unknown module name: ${name} (known module names: ${allNames.join(', ')})`) @@ -290,15 +290,15 @@ function bitrot (moduleNames) { log.debug({ rangesFromName }, 'rangesFromName') // Check each module name. - const namesToCheck = Object.keys(rangesFromName).sort() + var namesToCheck = Object.keys(rangesFromName).sort() namesToCheck.forEach(name => { - const npmInfo = getNpmInfo(name) + var npmInfo = getNpmInfo(name) log.trace({ name, 'dist-tags': npmInfo['dist-tags'], time: npmInfo.time }, 'npmInfo') // If the current latest version is in the supported and // tav ranges, then all is good. - const latest = npmInfo['dist-tags'].latest - let tavGood = false + var latest = npmInfo['dist-tags'].latest + var tavGood = false if (EXCUSE_FROM_TAV[name]) { tavGood = true } else { @@ -309,7 +309,7 @@ function bitrot (moduleNames) { } } } - let supGood = false + var supGood = false if (EXCUSE_FROM_SUPPORTED_TECHNOLOGIES_DOC[name]) { supGood = true } else { @@ -324,7 +324,7 @@ function bitrot (moduleNames) { log.debug(`latest ${name}@${latest} is in tav and supported ranges (a good thing)`) return } - const issues = [] + var issues = [] if (!tavGood) { issues.push(`is not in .tav.yml ranges (${rangesFromName[name].tavRanges.join(', ')})`) } @@ -351,7 +351,7 @@ const options = [ ] function main (argv) { - const parser = dashdash.createParser({ options: options }) + var parser = dashdash.createParser({ options: options }) try { var opts = parser.parse(argv) } catch (e) { @@ -359,7 +359,7 @@ function main (argv) { process.exit(1) } if (opts.help) { - const help = parser.help().trimRight() + var help = parser.help().trimRight() process.stdout.write(`Synopsis: dev-utils/bitrot.js [OPTIONS] diff --git a/examples/trace-graphql.js b/examples/trace-graphql.js index f1dc2023a6..2dfa074455 100644 --- a/examples/trace-graphql.js +++ b/examples/trace-graphql.js @@ -10,10 +10,10 @@ const apm = require('../').start({ // elastic-apm-node serviceName: 'example-trace-graphql' }) -const { graphql, buildSchema } = require('graphql') +var { graphql, buildSchema } = require('graphql') // Construct a schema, using GraphQL schema language -const schema = buildSchema(` +var schema = buildSchema(` type Query { hello: String bye: String @@ -21,7 +21,7 @@ const schema = buildSchema(` `) // The root provides a resolver function for each API endpoint -const root = { +var root = { hello: () => { return 'Hello world!' }, diff --git a/examples/trace-handlebars.js b/examples/trace-handlebars.js index c1e1543b5b..fdd457fb14 100755 --- a/examples/trace-handlebars.js +++ b/examples/trace-handlebars.js @@ -21,7 +21,7 @@ const handlebars = require('handlebars') // https://www.elastic.co/guide/en/apm/agent/nodejs/current/custom-transactions.html const t1 = apm.startTransaction('t1') -const template = handlebars.compile('Hello, {{name}}!') +var template = handlebars.compile('Hello, {{name}}!') console.log(template({ name: 'world' })) console.log(template({ name: 'Bob' })) diff --git a/examples/trace-pg.js b/examples/trace-pg.js index af5ada1285..269c57801b 100755 --- a/examples/trace-pg.js +++ b/examples/trace-pg.js @@ -43,7 +43,7 @@ client.query('SELECT $1::text as message', ['bye'], (err, res) => { // 2. Using streaming style, i.e. using a `Submittable` as node-postgres calls it. const t2 = apm.startTransaction('t2') -const q = client.query(new Query('select 1 + 1 as solution')) +var q = client.query(new Query('select 1 + 1 as solution')) q.on('error', (err) => { console.log('[t2] Failure: err is', err) t2.end() diff --git a/examples/trace-pug.js b/examples/trace-pug.js index cd43e1d1c9..34b7deb8d8 100755 --- a/examples/trace-pug.js +++ b/examples/trace-pug.js @@ -21,7 +21,7 @@ const pug = require('pug') // https://www.elastic.co/guide/en/apm/agent/nodejs/current/custom-transactions.html const t1 = apm.startTransaction('t1') -const template = pug.compile('p Hello, #{name}!') +var template = pug.compile('p Hello, #{name}!') console.log(template({ name: 'world' })) console.log(template({ name: 'Bob' })) diff --git a/examples/trace-tedious.js b/examples/trace-tedious.js index afac19bc1f..5d31eb3344 100755 --- a/examples/trace-tedious.js +++ b/examples/trace-tedious.js @@ -65,7 +65,7 @@ const conn2 = new tedious.Connection(connOpts) conn2.on('connect', onConnect2) conn2.connect() function onConnect2 () { - const req = new tedious.Request("select @mynum=42, @mystr='qaz'", function (err, rowCount) { + var req = new tedious.Request("select @mynum=42, @mystr='qaz'", function (err, rowCount) { console.log('select @mynum ...: err=%s rowCount=%s', err && err.message, rowCount) conn2.close() }) diff --git a/examples/trace-ws.js b/examples/trace-ws.js index 027acb0109..440b83fd9f 100755 --- a/examples/trace-ws.js +++ b/examples/trace-ws.js @@ -20,8 +20,8 @@ const apm = require('../').start({ // elastic-apm-node serviceName: 'example-trace-ws' }) -const WebSocket = require('ws') -const PORT = 4567 +var WebSocket = require('ws') +var PORT = 4567 // Server const wss = new WebSocket.Server({ port: PORT }) diff --git a/index.js b/index.js index 5d7fcc8f22..04711888d1 100644 --- a/index.js +++ b/index.js @@ -6,6 +6,6 @@ 'use strict' -const Agent = require('./lib/agent') +var Agent = require('./lib/agent') module.exports = new Agent() diff --git a/lib/activation-method.js b/lib/activation-method.js index 3590dc8020..f9b1938b3c 100644 --- a/lib/activation-method.js +++ b/lib/activation-method.js @@ -11,7 +11,7 @@ const path = require('path') const errorStackParser = require('error-stack-parser') const semver = require('semver') -const { isLambdaExecutionEnvironment } = require('./lambda') +var { isLambdaExecutionEnvironment } = require('./lambda') const CONTAINS_R_ELASTIC_APM_NODE_START = /(-r\s+|--require\s*=?\s*).*elastic-apm-node\/start/ diff --git a/lib/agent.js b/lib/agent.js index 0511a0d5c5..1042d63467 100644 --- a/lib/agent.js +++ b/lib/agent.js @@ -251,7 +251,7 @@ Agent.prototype.start = function (opts) { // Attempt to load package.json from process.argv. let pkg = null try { - const basedir = path.dirname(process.argv[1] || '.') + var basedir = path.dirname(process.argv[1] || '.') pkg = require(path.join(basedir, 'package.json')) } catch (e) {} @@ -343,14 +343,14 @@ Agent.prototype.setFramework = function ({ name, version, overwrite = true }) { } Agent.prototype.setUserContext = function (context) { - const trans = this._instrumentation.currTransaction() + var trans = this._instrumentation.currTransaction() if (!trans) return false trans.setUserContext(context) return true } Agent.prototype.setCustomContext = function (context) { - const trans = this._instrumentation.currTransaction() + var trans = this._instrumentation.currTransaction() if (!trans) return false trans.setCustomContext(context) return true @@ -373,13 +373,13 @@ Agent.prototype.setGlobalLabel = function (key, value) { } Agent.prototype.setLabel = function (key, value, stringify) { - const trans = this._instrumentation.currTransaction() + var trans = this._instrumentation.currTransaction() if (!trans) return false return trans.setLabel(key, value, stringify) } Agent.prototype.addLabels = function (labels, stringify) { - const trans = this._instrumentation.currTransaction() + var trans = this._instrumentation.currTransaction() if (!trans) return false return trans.addLabels(labels, stringify) } @@ -661,7 +661,7 @@ Agent.prototype.captureError = function (err, opts, cb) { // automatically terminate the process, so if you provide a callback you must // remember to terminate the process manually. Agent.prototype.handleUncaughtExceptions = function (cb) { - const agent = this + var agent = this if (this._uncaughtExceptionListener) { process.removeListener('uncaughtException', this._uncaughtExceptionListener) @@ -793,7 +793,7 @@ Agent.prototype._flush = function (opts, cb) { } Agent.prototype.registerMetric = function (name, labelsOrCallback, callback) { - let labels + var labels if (typeof labelsOrCallback === 'function') { callback = labelsOrCallback } else { @@ -816,7 +816,7 @@ Agent.prototype.registerMetric = function (name, labelsOrCallback, callback) { */ Agent.prototype._isMetricNameDisabled = function (name) { const regexps = this._conf.disableMetricsRegExp - for (let i = 0; i < regexps.length; i++) { + for (var i = 0; i < regexps.length; i++) { if (regexps[i].test(name)) { return true } diff --git a/lib/config/config.js b/lib/config/config.js index 42b81f35e5..d8ff391f4a 100644 --- a/lib/config/config.js +++ b/lib/config/config.js @@ -277,7 +277,7 @@ class Config { } function readEnv () { - const opts = {} + var opts = {} for (const key of Object.keys(ENV_TABLE)) { let env = ENV_TABLE[key] if (!Array.isArray(env)) env = [env] diff --git a/lib/errors.js b/lib/errors.js index 97a1aab8c0..bdd087ef83 100644 --- a/lib/errors.js +++ b/lib/errors.js @@ -10,7 +10,7 @@ // https://github.com/elastic/apm-server/blob/master/docs/spec/v2/error.json const crypto = require('crypto') -const path = require('path') +var path = require('path') const util = require('util') const { gatherStackTrace } = require('./stacktraces') @@ -24,9 +24,9 @@ const MYSQL_ERROR_MSG_RE = /(ER_[A-Z_]+): / function culpritFromStacktrace (frames) { if (frames.length === 0) return - let filename = frames[0].filename - let fnName = frames[0].function - for (let n = 0; n < frames.length; n++) { + var filename = frames[0].filename + var fnName = frames[0].function + for (var n = 0; n < frames.length; n++) { if (!frames[n].library_frame) { filename = frames[n].filename fnName = frames[n].function @@ -52,15 +52,15 @@ function _moduleNameFromFrames (frames) { if (frames.length === 0) { return null } - const frame = frames[0] + var frame = frames[0] if (!frame.library_frame) { return null } - const idx = frame.filename.lastIndexOf('node_modules' + path.sep) + var idx = frame.filename.lastIndexOf('node_modules' + path.sep) if (idx === -1) { return null } - const parts = frame.filename.slice(idx).split(path.sep) + var parts = frame.filename.slice(idx).split(path.sep) if (!parts[1]) { return null } else if (parts[1].startsWith('@')) { @@ -191,7 +191,7 @@ function createAPMError (args, cb) { // To provide better grouping of mysql errors that happens after the async // boundery, we modify to exception type to include the custom mysql error // type (e.g. ER_PARSE_ERROR) - const match = errMsg.match(MYSQL_ERROR_MSG_RE) + var match = errMsg.match(MYSQL_ERROR_MSG_RE) if (match) { error.exception.code = match[1] } diff --git a/lib/http-request.js b/lib/http-request.js index b7580819ee..56bf298691 100644 --- a/lib/http-request.js +++ b/lib/http-request.js @@ -132,7 +132,7 @@ function httpRequest (url, opts, cb) { // is connected. req.on('socket', function (socket) { // log.trace({url: url}, 'start connectTimeout') - let connectTimer = setTimeout(function onConnectTimeout () { + var connectTimer = setTimeout(function onConnectTimeout () { // log.trace({url: url}, 'connectTimeout') req.emit('connectTimeout') }, connectTimeout) @@ -206,7 +206,7 @@ function main (argv) { const connectTimeout = Number(argv[3]) const timeout = Number(argv[4]) - const req = httpRequest(url, { + var req = httpRequest(url, { timeout: timeout, connectTimeout: connectTimeout // TODO: log support diff --git a/lib/instrumentation/context.js b/lib/instrumentation/context.js index 37d0a8eb81..147adad65f 100644 --- a/lib/instrumentation/context.js +++ b/lib/instrumentation/context.js @@ -6,7 +6,7 @@ 'use strict' -const { parseUrl } = require('../parsers') +var { parseUrl } = require('../parsers') // Get the port number including the default port for a protocols function getPortNumber (port, protocol) { diff --git a/lib/instrumentation/elasticsearch-shared.js b/lib/instrumentation/elasticsearch-shared.js index 7df91ff512..75734b001f 100644 --- a/lib/instrumentation/elasticsearch-shared.js +++ b/lib/instrumentation/elasticsearch-shared.js @@ -16,7 +16,7 @@ function shouldCaptureBody (path, elasticsearchCaptureBodyUrlsRegExp) { if (!path) { return false } - for (let i = 0; i < elasticsearchCaptureBodyUrlsRegExp.length; i++) { + for (var i = 0; i < elasticsearchCaptureBodyUrlsRegExp.length; i++) { const re = elasticsearchCaptureBodyUrlsRegExp[i] if (re.test(path)) { return true diff --git a/lib/instrumentation/express-utils.js b/lib/instrumentation/express-utils.js index 02717c3dab..590040647e 100644 --- a/lib/instrumentation/express-utils.js +++ b/lib/instrumentation/express-utils.js @@ -8,7 +8,7 @@ const url = require('url') -const symbols = require('../symbols') +var symbols = require('../symbols') function normalizeSlash (value) { return value[0] === '/' ? value : '/' + value @@ -30,7 +30,7 @@ function routePath (route) { } function getStackPath (req) { - const stack = req[symbols.expressMountStack] + var stack = req[symbols.expressMountStack] return join(stack) } @@ -41,8 +41,8 @@ function getPathFromRequest (req, useBase, usePathAsTransactionName) { return 'static file' } - const path = getStackPath(req) - const route = routePath(req.route) + var path = getStackPath(req) + var route = routePath(req.route) if (route) { return path ? join([path, route]) : route diff --git a/lib/instrumentation/generic-span.js b/lib/instrumentation/generic-span.js index 224578d3d2..501e48997a 100644 --- a/lib/instrumentation/generic-span.js +++ b/lib/instrumentation/generic-span.js @@ -137,7 +137,7 @@ GenericSpan.prototype.setLabel = function (key, value, stringify = true) { if (!key) return false if (!this._labels) this._labels = {} - const skey = key.replace(/[.*"]/g, '_') + var skey = key.replace(/[.*"]/g, '_') if (key !== skey) { this._agent.logger.warn('Illegal characters used in tag key: %s', key) } @@ -147,7 +147,7 @@ GenericSpan.prototype.setLabel = function (key, value, stringify = true) { GenericSpan.prototype.addLabels = function (labels, stringify) { if (!labels) return false - const keys = Object.keys(labels) + var keys = Object.keys(labels) for (const key of keys) { if (!this.setLabel(key, labels[key], stringify)) { return false diff --git a/lib/instrumentation/http-shared.js b/lib/instrumentation/http-shared.js index 1a8de541a1..c7636d0852 100644 --- a/lib/instrumentation/http-shared.js +++ b/lib/instrumentation/http-shared.js @@ -6,12 +6,12 @@ 'use strict' -const { URL, urlToHttpOptions } = require('url') +var { URL, urlToHttpOptions } = require('url') -const endOfStream = require('end-of-stream') +var endOfStream = require('end-of-stream') const semver = require('semver') -const { getHTTPDestination } = require('./context') +var { getHTTPDestination } = require('./context') const transactionForResponse = new WeakMap() exports.transactionForResponse = transactionForResponse @@ -82,7 +82,7 @@ if (!urlToHttpOptions) { } exports.instrumentRequest = function (agent, moduleName) { - const ins = agent._instrumentation + var ins = agent._instrumentation return function (orig) { return function (event, req, res) { if (event === 'request') { @@ -115,7 +115,7 @@ exports.instrumentRequest = function (agent, moduleName) { if (!err) return trans.end() if (agent._conf.errorOnAbortedRequests) { - const duration = trans._timer.elapsed() + var duration = trans._timer.elapsed() if (duration > (agent._conf.abortedErrorThreshold * 1000)) { agent.captureError('Socket closed with active HTTP request (>' + agent._conf.abortedErrorThreshold + ' sec)', { request: req, @@ -142,7 +142,7 @@ exports.instrumentRequest = function (agent, moduleName) { } function shouldIgnoreRequest (agent, req) { - let i + var i for (i = 0; i < agent._conf.ignoreUrlStr.length; i++) { if (agent._conf.ignoreUrlStr[i] === req.url) return true @@ -154,7 +154,7 @@ function shouldIgnoreRequest (agent, req) { if (agent._conf.transactionIgnoreUrlRegExp[i].test(req.url)) return true } - const ua = req.headers['user-agent'] + var ua = req.headers['user-agent'] if (!ua) return false for (i = 0; i < agent._conf.ignoreUserAgentStr.length; i++) { @@ -179,13 +179,13 @@ function getSafeHost (req) { } exports.traceOutgoingRequest = function (agent, moduleName, method) { - const ins = agent._instrumentation + var ins = agent._instrumentation return function (orig) { return function (input, options, cb) { const parentRunContext = ins.currRunContext() - const span = ins.createSpan(null, 'external', 'http', { exitSpan: true }) - const id = span && span.transaction.id + var span = ins.createSpan(null, 'external', 'http', { exitSpan: true }) + var id = span && span.transaction.id agent.logger.debug('intercepted call to %s.%s %o', moduleName, method, { id: id }) // Reproduce the argument handling from node/lib/_http_client.js#ClientRequest(). @@ -258,9 +258,9 @@ exports.traceOutgoingRequest = function (agent, moduleName, method) { } const spanRunContext = parentRunContext.enterSpan(span) - const req = ins.withRunContext(spanRunContext, orig, this, ...newArgs) + var req = ins.withRunContext(spanRunContext, orig, this, ...newArgs) - const protocol = req.agent && req.agent.protocol + var protocol = req.agent && req.agent.protocol agent.logger.debug('request details: %o', { protocol: protocol, host: getSafeHost(req), id: id }) ins.bindEmitter(req) diff --git a/lib/instrumentation/index.js b/lib/instrumentation/index.js index bffd273ad8..b721b064cd 100644 --- a/lib/instrumentation/index.js +++ b/lib/instrumentation/index.js @@ -6,8 +6,8 @@ 'use strict' -const fs = require('fs') -const path = require('path') +var fs = require('fs') +var path = require('path') const Hook = require('require-in-the-middle') const semver = require('semver') @@ -17,9 +17,9 @@ const { CONTEXT_MANAGER_ASYNCHOOKS, CONTEXT_MANAGER_ASYNCLOCALSTORAGE } = require('../config/schema') -const { Ids } = require('./ids') -const NamedArray = require('./named-array') -const Transaction = require('./transaction') +var { Ids } = require('./ids') +var NamedArray = require('./named-array') +var Transaction = require('./transaction') const { BasicRunContextManager, AsyncHooksRunContextManager, @@ -34,7 +34,7 @@ const nodeSupportsAsyncLocalStorage = semver.satisfies(process.versions.node, '> // v18.0.0) based on undici@5.0.0. We can instrument undici >=v4.7.1. const nodeHasInstrumentableFetch = typeof (global.fetch) === 'function' -const MODULES = [ +var MODULES = [ '@apollo/server', '@aws-sdk/smithy-client', // Instrument the base client which all AWS-SDK v3 clients extends ['@elastic/elasticsearch', '@elastic/elasticsearch-canary'], @@ -295,13 +295,13 @@ Instrumentation.prototype._startHook = function () { this._hook.unhook() } - const self = this + var self = this this._agent.logger.debug('adding hook to Node.js module loader') this._hook = new Hook(this._patches.keys, function (exports, name, basedir) { const enabled = self._isModuleEnabled(name) - let pkg, version + var pkg, version const isHandlingLambda = self._lambdaHandlerInfo && self._lambdaHandlerInfo.module === name @@ -353,7 +353,7 @@ Instrumentation.prototype._patchModule = function (exports, name, version, enabl } Instrumentation.prototype.addEndedTransaction = function (transaction) { - const agent = this._agent + var agent = this._agent if (!this._started) { agent.logger.debug('ignoring transaction %o', { trans: transaction.id, trace: transaction.traceId }) @@ -387,7 +387,7 @@ Instrumentation.prototype.addEndedTransaction = function (transaction) { this._encodeAndSendSpan(transaction.getBufferedSpan()) } - const payload = agent._transactionFilters.process(transaction._encode()) + var payload = agent._transactionFilters.process(transaction._encode()) if (!payload) { agent.logger.debug('transaction ignored by filter %o', { trans: transaction.id, trace: transaction.traceId }) return @@ -398,7 +398,7 @@ Instrumentation.prototype.addEndedTransaction = function (transaction) { } Instrumentation.prototype.addEndedSpan = function (span) { - const agent = this._agent + var agent = this._agent if (!this._started) { agent.logger.debug('ignoring span %o', { span: span.id, parent: span.parentId, trace: span.traceId, name: span.name, type: span.type }) diff --git a/lib/instrumentation/modules/@apollo/server.js b/lib/instrumentation/modules/@apollo/server.js index 02a465bd0b..2fb428208c 100644 --- a/lib/instrumentation/modules/@apollo/server.js +++ b/lib/instrumentation/modules/@apollo/server.js @@ -15,7 +15,7 @@ module.exports = function (apolloServer, agent, { enabled }) { function wrapExecuteHTTPGraphQLRequest (orig) { return function wrappedExecuteHTTPGraphQLRequest () { - const trans = agent._instrumentation.currTransaction() + var trans = agent._instrumentation.currTransaction() if (trans) trans._graphqlRoute = true return orig.apply(this, arguments) } diff --git a/lib/instrumentation/modules/apollo-server-core.js b/lib/instrumentation/modules/apollo-server-core.js index b667b02402..523febac18 100644 --- a/lib/instrumentation/modules/apollo-server-core.js +++ b/lib/instrumentation/modules/apollo-server-core.js @@ -20,7 +20,7 @@ module.exports = function (apolloServerCore, agent, { version, enabled }) { function wrapRunHttpQuery (orig) { return function wrappedRunHttpQuery () { - const trans = agent._instrumentation.currTransaction() + var trans = agent._instrumentation.currTransaction() if (trans) trans._graphqlRoute = true return orig.apply(this, arguments) } diff --git a/lib/instrumentation/modules/bluebird.js b/lib/instrumentation/modules/bluebird.js index 401bde3c55..722de79341 100644 --- a/lib/instrumentation/modules/bluebird.js +++ b/lib/instrumentation/modules/bluebird.js @@ -6,17 +6,17 @@ 'use strict' -const semver = require('semver') +var semver = require('semver') -const shimmer = require('../shimmer') +var shimmer = require('../shimmer') -const massWrap = shimmer.massWrap -const wrap = shimmer.wrap +var massWrap = shimmer.massWrap +var wrap = shimmer.wrap -const BLUEBIRD_FNS = ['_then', '_addCallbacks'] +var BLUEBIRD_FNS = ['_then', '_addCallbacks'] module.exports = function (bluebird, agent, { version }) { - const ins = agent._instrumentation + var ins = agent._instrumentation if (!semver.satisfies(version, '>=2 <4')) { agent.logger.debug('bluebird version %s not supported - aborting...', version) @@ -32,7 +32,7 @@ module.exports = function (bluebird, agent, { version }) { agent.logger.debug('shimming bluebird.config') wrap(bluebird, 'config', function wrapConfig (original) { return function wrappedConfig () { - const result = original.apply(this, arguments) + var result = original.apply(this, arguments) agent.logger.debug('shimming bluebird.prototype._attachCancellationCallback') wrap(bluebird.prototype, '_attachCancellationCallback', function wrapAttachCancellationCallback (original) { @@ -75,7 +75,7 @@ module.exports = function (bluebird, agent, { version }) { function wrapThen (original) { return function wrappedThen () { - const args = Array.prototype.slice.call(arguments) + var args = Array.prototype.slice.call(arguments) if (typeof args[0] === 'function') args[0] = ins.bindFunction(args[0]) if (typeof args[1] === 'function') args[1] = ins.bindFunction(args[1]) return original.apply(this, args) diff --git a/lib/instrumentation/modules/elasticsearch.js b/lib/instrumentation/modules/elasticsearch.js index 8e09d8dbbf..c2a4da75f6 100644 --- a/lib/instrumentation/modules/elasticsearch.js +++ b/lib/instrumentation/modules/elasticsearch.js @@ -8,8 +8,8 @@ const { URL, URLSearchParams } = require('url') -const shimmer = require('../shimmer') -const { getDBDestination } = require('../context') +var shimmer = require('../shimmer') +var { getDBDestination } = require('../context') const { getElasticsearchDbStatement } = require('../elasticsearch-shared') const startsWithProtocolRE = /^([a-z]+:)?\/\//i @@ -76,10 +76,10 @@ module.exports = function (elasticsearch, agent, { enabled }) { function wrapRequest (original) { return function wrappedRequest (params, cb) { - const span = ins.createSpan(null, 'db', 'elasticsearch', 'request', { exitSpan: true }) - const id = span && span.transaction.id - const method = params && params.method - const path = params && params.path + var span = ins.createSpan(null, 'db', 'elasticsearch', 'request', { exitSpan: true }) + var id = span && span.transaction.id + var method = params && params.method + var path = params && params.path agent.logger.debug('intercepted call to elasticsearch.Transport.prototype.request %o', { id: id, method: method, path: path }) diff --git a/lib/instrumentation/modules/express-graphql.js b/lib/instrumentation/modules/express-graphql.js index 373af6ca06..356d3f5605 100644 --- a/lib/instrumentation/modules/express-graphql.js +++ b/lib/instrumentation/modules/express-graphql.js @@ -6,7 +6,7 @@ 'use strict' -const semver = require('semver') +var semver = require('semver') const shimmer = require('../shimmer') @@ -41,7 +41,7 @@ module.exports = function (expressGraphql, agent, { version, enabled }) { function wrapGraphqlHTTP (origGraphqlHTTP) { return function wrappedGraphqlHTTP () { - const orig = origGraphqlHTTP.apply(this, arguments) + var orig = origGraphqlHTTP.apply(this, arguments) if (typeof orig !== 'function') { return orig @@ -49,7 +49,7 @@ module.exports = function (expressGraphql, agent, { version, enabled }) { // Express is very particular with the number of arguments! return function (req, res) { - const trans = agent._instrumentation.currTransaction() + var trans = agent._instrumentation.currTransaction() if (trans) { trans._graphqlRoute = true } diff --git a/lib/instrumentation/modules/express-queue.js b/lib/instrumentation/modules/express-queue.js index 745cd27247..14ea180826 100644 --- a/lib/instrumentation/modules/express-queue.js +++ b/lib/instrumentation/modules/express-queue.js @@ -6,15 +6,15 @@ 'use strict' -const shimmer = require('../shimmer') +var shimmer = require('../shimmer') module.exports = function (expressQueue, agent, { enabled }) { if (!enabled) return expressQueue - const ins = agent._instrumentation + var ins = agent._instrumentation return function wrappedExpressQueue (config) { - const result = expressQueue(config) + var result = expressQueue(config) shimmer.wrap(result.queue, 'createJob', function (original) { return function (job) { if (job.next) { diff --git a/lib/instrumentation/modules/express.js b/lib/instrumentation/modules/express.js index 3c11af4a03..9f420e7ec4 100644 --- a/lib/instrumentation/modules/express.js +++ b/lib/instrumentation/modules/express.js @@ -6,11 +6,11 @@ 'use strict' -const isError = require('core-util-is').isError -const semver = require('semver') +var isError = require('core-util-is').isError +var semver = require('semver') -const shimmer = require('../shimmer') -const symbols = require('../../symbols') +var shimmer = require('../shimmer') +var symbols = require('../../symbols') module.exports = function (express, agent, { version, enabled }) { if (!enabled) return express @@ -23,11 +23,11 @@ module.exports = function (express, agent, { version, enabled }) { } // express 5 moves the router methods onto a prototype - const routerProto = semver.satisfies(version, '^5') + var routerProto = semver.satisfies(version, '^5') ? (express.Router && express.Router.prototype) : express.Router - const layerPatchedSymbol = Symbol('layer-patched') + var layerPatchedSymbol = Symbol('layer-patched') function shouldReport (err) { if (!agent._conf.captureExceptions) return false @@ -97,8 +97,8 @@ module.exports = function (express, agent, { version, enabled }) { shimmer.wrap(routerProto, 'route', orig => { return function route (path) { - const route = orig.apply(this, arguments) - const layer = this.stack[this.stack.length - 1] + var route = orig.apply(this, arguments) + var layer = this.stack[this.stack.length - 1] patchLayer(layer, path) return route } @@ -106,8 +106,8 @@ module.exports = function (express, agent, { version, enabled }) { shimmer.wrap(routerProto, 'use', orig => { return function use (path) { - const route = orig.apply(this, arguments) - const layer = this.stack[this.stack.length - 1] + var route = orig.apply(this, arguments) + var layer = this.stack[this.stack.length - 1] patchLayer(layer, typeof path === 'string' && path) return route } @@ -129,7 +129,7 @@ module.exports = function (express, agent, { version, enabled }) { return wrappedStatic function wrappedStatic () { - const origServeStatic = orig.apply(this, arguments) + var origServeStatic = orig.apply(this, arguments) return function serveStatic (req, res, next) { req[symbols.staticFile] = true diff --git a/lib/instrumentation/modules/finalhandler.js b/lib/instrumentation/modules/finalhandler.js index f5ff65045a..251775a8d2 100644 --- a/lib/instrumentation/modules/finalhandler.js +++ b/lib/instrumentation/modules/finalhandler.js @@ -14,9 +14,9 @@ // The `errorReportedSymbol` symbol is used to coordinate with 'express' // instrumentation to avoid double-reporting errors. -const isError = require('core-util-is').isError +var isError = require('core-util-is').isError -const symbols = require('../../symbols') +var symbols = require('../../symbols') function shouldReport (err) { if (typeof err === 'string') return true @@ -29,7 +29,7 @@ function shouldReport (err) { module.exports = function (finalhandler, agent) { return function wrappedFinalhandler (req, res, options) { - const final = finalhandler.apply(this, arguments) + var final = finalhandler.apply(this, arguments) return function (err) { if (shouldReport(err)) { diff --git a/lib/instrumentation/modules/generic-pool.js b/lib/instrumentation/modules/generic-pool.js index f0f1352f0b..f9b050c124 100644 --- a/lib/instrumentation/modules/generic-pool.js +++ b/lib/instrumentation/modules/generic-pool.js @@ -6,22 +6,22 @@ 'use strict' -const semver = require('semver') +var semver = require('semver') -const shimmer = require('../shimmer') +var shimmer = require('../shimmer') module.exports = function (generic, agent, { version }) { if (semver.satisfies(version, '^2.0.0')) { agent.logger.debug('shimming generic-pool.Pool') shimmer.wrap(generic, 'Pool', function (orig) { return function wrappedPool () { - const trans = agent._instrumentation.currTransaction() - const id = trans && trans.id + var trans = agent._instrumentation.currTransaction() + var id = trans && trans.id agent.logger.debug('intercepted call to generic-pool.Pool %o', { id: id }) - let pool + var pool if (this instanceof generic.Pool) { - const args = [].slice.call(arguments) + var args = [].slice.call(arguments) args.unshift(null) pool = new (Function.prototype.bind.apply(orig, args))() } else { @@ -30,11 +30,11 @@ module.exports = function (generic, agent, { version }) { shimmer.wrap(pool, 'acquire', function (orig) { return function wrappedAcquire () { - const trans = agent._instrumentation.currTransaction() - const id = trans && trans.id + var trans = agent._instrumentation.currTransaction() + var id = trans && trans.id agent.logger.debug('intercepted call to pool.acquire %o', { id: id }) - const cb = arguments[0] + var cb = arguments[0] if (typeof cb === 'function') { arguments[0] = agent._instrumentation.bindFunction(cb) } @@ -57,11 +57,11 @@ module.exports = function (generic, agent, { version }) { agent.logger.debug('shimming generic-pool.PriorityQueue.prototype.enqueue') shimmer.wrap(generic.PriorityQueue.prototype, 'enqueue', function (orig) { return function wrappedEnqueue () { - const trans = agent._instrumentation.currTransaction() - const id = trans && trans.id + var trans = agent._instrumentation.currTransaction() + var id = trans && trans.id agent.logger.debug('intercepted call to generic-pool.PriorityQueue.prototype.enqueue %o', { id: id }) - const obj = arguments[0] + var obj = arguments[0] // Expect obj to of type Deferred if (obj._resolve && obj._reject) { obj._resolve = agent._instrumentation.bindFunction(obj._resolve) diff --git a/lib/instrumentation/modules/graphql.js b/lib/instrumentation/modules/graphql.js index 82df26f5e6..214cb80d11 100644 --- a/lib/instrumentation/modules/graphql.js +++ b/lib/instrumentation/modules/graphql.js @@ -6,10 +6,10 @@ 'use strict' -const semver = require('semver') -const clone = require('shallow-clone-shim') +var semver = require('semver') +var clone = require('shallow-clone-shim') -const getPathFromRequest = require('../express-utils').getPathFromRequest +var getPathFromRequest = require('../express-utils').getPathFromRequest module.exports = function (graphql, agent, { version, enabled }) { if (!enabled) return graphql @@ -85,7 +85,7 @@ module.exports = function (graphql, agent, { version, enabled }) { ? new graphql.Source(source || '', 'GraphQL request') : source) if (sourceObj) { - let documentAST + var documentAST try { documentAST = graphql.parse(sourceObj) @@ -94,9 +94,9 @@ module.exports = function (graphql, agent, { version, enabled }) { } if (documentAST) { - const validationErrors = graphql.validate(schema, documentAST) + var validationErrors = graphql.validate(schema, documentAST) if (validationErrors && validationErrors.length === 0) { - const queries = extractDetails(documentAST, operationName).queries + var queries = extractDetails(documentAST, operationName).queries if (queries.length > 0) span.name = 'GraphQL: ' + queries.join(', ') } } @@ -133,8 +133,8 @@ module.exports = function (graphql, agent, { version, enabled }) { operationName = arguments[5] } - const details = extractDetails(document, operationName) - const queries = details.queries + var details = extractDetails(document, operationName) + var queries = details.queries operationName = operationName || (details.operation && details.operation.name && details.operation.name.value) if (queries.length > 0) { span.name = 'GraphQL: ' + (operationName ? operationName + ' ' : '') + queries.join(', ') @@ -145,9 +145,9 @@ module.exports = function (graphql, agent, { version, enabled }) { // indicate that this transaction is for a GraphQL request. const trans = span.transaction if (trans._graphqlRoute) { - const name = queries.length > 0 ? queries.join(', ') : 'Unknown GraphQL query' + var name = queries.length > 0 ? queries.join(', ') : 'Unknown GraphQL query' if (trans.req) var path = getPathFromRequest(trans.req, true) - let defaultName = name + var defaultName = name defaultName = path ? defaultName + ' (' + path + ')' : defaultName defaultName = operationName ? operationName + ' ' + defaultName : defaultName trans.setDefaultName(defaultName) @@ -168,8 +168,8 @@ module.exports = function (graphql, agent, { version, enabled }) { } function extractDetails (document, operationName) { - let queries = [] - let operation + var queries = [] + var operation if (document && Array.isArray(document.definitions)) { document.definitions.some(function (definition) { @@ -181,7 +181,7 @@ module.exports = function (graphql, agent, { version, enabled }) { } }) - const selections = operation && operation.selectionSet && operation.selectionSet.selections + var selections = operation && operation.selectionSet && operation.selectionSet.selections if (selections && Array.isArray(selections)) { for (const selection of selections) { const kind = selection.name && selection.name.kind diff --git a/lib/instrumentation/modules/handlebars.js b/lib/instrumentation/modules/handlebars.js index ee1597a50d..85065655d1 100644 --- a/lib/instrumentation/modules/handlebars.js +++ b/lib/instrumentation/modules/handlebars.js @@ -6,8 +6,8 @@ 'use strict' -const shimmer = require('../shimmer') -const templateShared = require('../template-shared') +var shimmer = require('../shimmer') +var templateShared = require('../template-shared') module.exports = function (handlebars, agent, { enabled }) { if (!enabled) return handlebars diff --git a/lib/instrumentation/modules/hapi.js b/lib/instrumentation/modules/hapi.js index adf7c488cf..dad5e0b7e7 100644 --- a/lib/instrumentation/modules/hapi.js +++ b/lib/instrumentation/modules/hapi.js @@ -6,11 +6,11 @@ 'use strict' -const semver = require('semver') +var semver = require('semver') -const shimmer = require('../shimmer') +var shimmer = require('../shimmer') -const onPreAuthSym = Symbol('ElasticAPMOnPreAuth') +var onPreAuthSym = Symbol('ElasticAPMOnPreAuth') module.exports = function (hapi, agent, { version, enabled }) { if (!enabled) return hapi @@ -28,7 +28,7 @@ module.exports = function (hapi, agent, { version, enabled }) { if (isHapiGte17) { shimmer.massWrap(hapi, ['Server', 'server'], function (orig) { return function (options) { - const res = orig.apply(this, arguments) + var res = orig.apply(this, arguments) patchServer(res) return res } @@ -56,7 +56,7 @@ module.exports = function (hapi, agent, { version, enabled }) { // connection lifecycle hooks (in hapi 17+ the server always has // connections, though the `server.connections` property doesn't exists, // so this if-statement wont fire) - const conns = server.connections + var conns = server.connections if (conns && conns.length === 0) { agent.logger.debug('unable to enable hapi instrumentation on connectionless server') return @@ -99,7 +99,7 @@ module.exports = function (hapi, agent, { version, enabled }) { } // TODO: Find better location to put this than custom - const payload = { + var payload = { custom: { tags: event.tags, internals: event.internals, @@ -109,7 +109,7 @@ module.exports = function (hapi, agent, { version, enabled }) { request: req && req.raw && req.raw.req } - let err = payload.custom.data + var err = payload.custom.data if (!(err instanceof Error) && typeof err !== 'string') { err = 'hapi server emitted a ' + type + ' event tagged error' } @@ -131,10 +131,10 @@ module.exports = function (hapi, agent, { version, enabled }) { // stable in case the param names change // - path example: /foo/{bar*2} // - fingerprint example: /foo/?/? - const fingerprint = request.route.fingerprint || request.route.path + var fingerprint = request.route.fingerprint || request.route.path if (fingerprint) { - let name = (request.raw && request.raw.req && request.raw.req.method) || + var name = (request.raw && request.raw.req && request.raw.req.method) || (request.route.method && request.route.method.toUpperCase()) if (typeof name === 'string') { diff --git a/lib/instrumentation/modules/http.js b/lib/instrumentation/modules/http.js index c30d228f7c..8f1fdecbbc 100644 --- a/lib/instrumentation/modules/http.js +++ b/lib/instrumentation/modules/http.js @@ -6,8 +6,8 @@ 'use strict' -const httpShared = require('../http-shared') -const shimmer = require('../shimmer') +var httpShared = require('../http-shared') +var shimmer = require('../shimmer') function getSafeHeaders (res) { return res.getHeaders ? res.getHeaders() : res._headers @@ -34,13 +34,13 @@ module.exports = function (http, agent, { enabled }) { function wrapWriteHead (original) { return function wrappedWriteHead () { - const headers = arguments.length === 1 + var headers = arguments.length === 1 ? getSafeHeaders(this) // might be because of implicit headers. : arguments[arguments.length - 1] - const result = original.apply(this, arguments) + var result = original.apply(this, arguments) - const trans = httpShared.transactionForResponse.get(this) + var trans = httpShared.transactionForResponse.get(this) if (trans) { httpShared.transactionForResponse.delete(this) diff --git a/lib/instrumentation/modules/http2.js b/lib/instrumentation/modules/http2.js index e37b3950c6..2a8106b164 100644 --- a/lib/instrumentation/modules/http2.js +++ b/lib/instrumentation/modules/http2.js @@ -6,12 +6,12 @@ 'use strict' -const eos = require('end-of-stream') +var eos = require('end-of-stream') -const shimmer = require('../shimmer') -const symbols = require('../../symbols') -const { parseUrl } = require('../../parsers') -const { getHTTPDestination } = require('../context') +var shimmer = require('../shimmer') +var symbols = require('../../symbols') +var { parseUrl } = require('../../parsers') +var { getHTTPDestination } = require('../context') // Return true iff this is an HTTP 1.0 or 1.1 request. // @@ -28,7 +28,7 @@ module.exports = function (http2, agent, { enabled }) { } if (!enabled) return http2 - const ins = agent._instrumentation + var ins = agent._instrumentation agent.logger.debug('shimming http2.connect function') shimmer.wrap(http2, 'connect', wrapConnect) @@ -38,7 +38,7 @@ module.exports = function (http2, agent, { enabled }) { // the first server prototype it patches. function wrapCreateServer (original) { return function wrappedCreateServer (options, handler) { - const server = original.apply(this, arguments) + var server = original.apply(this, arguments) shimmer.wrap(server.constructor.prototype, 'emit', wrapEmit) wrappedCreateServer[symbols.unwrap]() return server @@ -46,12 +46,12 @@ module.exports = function (http2, agent, { enabled }) { } function wrapEmit (original) { - let patched = false + var patched = false return function wrappedEmit (event, stream, headers) { if (event === 'stream') { if (!patched) { patched = true - const proto = stream.constructor.prototype + var proto = stream.constructor.prototype shimmer.wrap(proto, 'pushStream', wrapPushStream) shimmer.wrap(proto, 'respondWithFile', wrapRespondWith) shimmer.wrap(proto, 'respondWithFD', wrapRespondWith) @@ -105,8 +105,8 @@ module.exports = function (http2, agent, { enabled }) { agent.logger.debug('intercepted request event call to http2.Server.prototype.emit for %s', req.url) - const traceparent = req.headers.traceparent || req.headers['elastic-apm-traceparent'] - const tracestate = req.headers.tracestate + var traceparent = req.headers.traceparent || req.headers['elastic-apm-traceparent'] + var tracestate = req.headers.tracestate const trans = agent.startTransaction(null, null, { childOf: traceparent, tracestate: tracestate @@ -126,7 +126,7 @@ module.exports = function (http2, agent, { enabled }) { } if (agent._conf.errorOnAbortedRequests) { - const duration = trans._timer.elapsed() + var duration = trans._timer.elapsed() if (duration > (agent._conf.abortedErrorThreshold * 1000)) { agent.captureError('Socket closed with active HTTP request (>' + agent._conf.abortedErrorThreshold + ' sec)', { request: req, @@ -151,9 +151,9 @@ module.exports = function (http2, agent, { enabled }) { } function updateHeaders (headers) { - const trans = agent._instrumentation.currTransaction() + var trans = agent._instrumentation.currTransaction() if (trans && !trans.ended) { - const status = headers[':status'] || 200 + var status = headers[':status'] || 200 trans.result = 'HTTP ' + status.toString()[0] + 'xx' trans.res.statusCode = status trans._setOutcomeFromHttpStatusCode(status) @@ -178,7 +178,7 @@ module.exports = function (http2, agent, { enabled }) { function wrapEnd (original) { return function (headers) { - const trans = agent._instrumentation.currTransaction() + var trans = agent._instrumentation.currTransaction() // `trans.res` might be removed, because before // https://github.com/nodejs/node/pull/20084 (e.g. in node v10.0.0) the // 'end' event could be called multiple times for the same Http2Stream, @@ -194,7 +194,7 @@ module.exports = function (http2, agent, { enabled }) { return function wrappedPushStream (...args) { // Note: Break the run context so that the wrapped `stream.respond` et al // for this pushStream do not overwrite outer transaction state. - const callback = args.pop() + var callback = args.pop() args.push(agent._instrumentation.bindFunctionToEmptyRunContext(callback)) return original.apply(this, args) } @@ -202,10 +202,10 @@ module.exports = function (http2, agent, { enabled }) { function mergeHeaders (source, target) { if (source === null) return target - const result = Object.assign({}, target) - const keys = Object.keys(source) + var result = Object.assign({}, target) + var keys = Object.keys(source) for (let i = 0; i < keys.length; i++) { - const key = keys[i] + var key = keys[i] if (typeof target[key] === 'undefined') { result[key] = source[key] } else if (Array.isArray(target[key])) { @@ -228,11 +228,11 @@ module.exports = function (http2, agent, { enabled }) { function wrapRequest (orig, host) { return function (headers) { agent.logger.debug('intercepted call to http2.request') - const method = headers[':method'] || 'GET' + var method = headers[':method'] || 'GET' const span = ins.createSpan(null, 'external', 'http', method, { exitSpan: true }) const parentRunContext = ins.currRunContext() - const parent = span || parentRunContext.currSpan() || parentRunContext.currTransaction() + var parent = span || parentRunContext.currSpan() || parentRunContext.currTransaction() if (parent) { const newHeaders = Object.assign({}, headers) parent.propagateTraceContextHeaders(newHeaders, function (carrier, name, value) { @@ -245,16 +245,16 @@ module.exports = function (http2, agent, { enabled }) { } const spanRunContext = parentRunContext.enterSpan(span) - const req = ins.withRunContext(spanRunContext, orig, this, ...arguments) + var req = ins.withRunContext(spanRunContext, orig, this, ...arguments) ins.bindEmitterToRunContext(parentRunContext, req) - const urlObj = parseUrl(headers[':path']) - const path = urlObj.pathname - const url = host + path + var urlObj = parseUrl(headers[':path']) + var path = urlObj.pathname + var url = host + path span.name = method + ' ' + host - let statusCode + var statusCode req.on('response', (headers) => { statusCode = headers[':status'] }) diff --git a/lib/instrumentation/modules/https.js b/lib/instrumentation/modules/https.js index 731f51b100..c6591ca4b7 100644 --- a/lib/instrumentation/modules/https.js +++ b/lib/instrumentation/modules/https.js @@ -6,10 +6,10 @@ 'use strict' -const semver = require('semver') +var semver = require('semver') -const httpShared = require('../http-shared') -const shimmer = require('../shimmer') +var httpShared = require('../http-shared') +var shimmer = require('../shimmer') module.exports = function (https, agent, { version, enabled }) { if (agent._conf.instrumentIncomingHTTPRequests) { diff --git a/lib/instrumentation/modules/jade.js b/lib/instrumentation/modules/jade.js index 768f78f536..f2f4480972 100644 --- a/lib/instrumentation/modules/jade.js +++ b/lib/instrumentation/modules/jade.js @@ -6,8 +6,8 @@ 'use strict' -const shimmer = require('../shimmer') -const templateShared = require('../template-shared') +var shimmer = require('../shimmer') +var templateShared = require('../template-shared') module.exports = function (jade, agent, { enabled }) { if (!enabled) return jade diff --git a/lib/instrumentation/modules/knex.js b/lib/instrumentation/modules/knex.js index 02654e28f5..af168d299c 100644 --- a/lib/instrumentation/modules/knex.js +++ b/lib/instrumentation/modules/knex.js @@ -10,10 +10,10 @@ 'use strict' -const semver = require('semver') +var semver = require('semver') -const shimmer = require('../shimmer') -const symbols = require('../../symbols') +var shimmer = require('../shimmer') +var symbols = require('../../symbols') module.exports = function (Knex, agent, { version, enabled }) { if (!enabled) { @@ -40,10 +40,10 @@ module.exports = function (Knex, agent, { version, enabled }) { function wrapQueryStartPoint (original) { return function wrappedQueryStartPoint () { - const builder = original.apply(this, arguments) + var builder = original.apply(this, arguments) agent.logger.debug('capturing custom stack trace for knex') - const obj = {} + var obj = {} Error.captureStackTrace(obj) builder[symbols.knexStackObj] = obj @@ -53,7 +53,7 @@ module.exports = function (Knex, agent, { version, enabled }) { function wrapRunner (original) { return function wrappedRunner () { - const runner = original.apply(this, arguments) + var runner = original.apply(this, arguments) agent.logger.debug('shimming knex runner.query') shimmer.wrap(runner, 'query', wrapQuery) diff --git a/lib/instrumentation/modules/koa-router.js b/lib/instrumentation/modules/koa-router.js index 0d827695cd..4a08e404ba 100644 --- a/lib/instrumentation/modules/koa-router.js +++ b/lib/instrumentation/modules/koa-router.js @@ -6,9 +6,9 @@ 'use strict' -const semver = require('semver') +var semver = require('semver') -const shimmer = require('../shimmer') +var shimmer = require('../shimmer') module.exports = function (Router, agent, { version, enabled }) { if (!enabled) return Router @@ -20,7 +20,7 @@ module.exports = function (Router, agent, { version, enabled }) { agent.logger.debug('shimming koa-router prototype.match function') shimmer.wrap(Router.prototype, 'match', function (orig) { return function (_, method) { - const matched = orig.apply(this, arguments) + var matched = orig.apply(this, arguments) if (typeof method !== 'string') { agent.logger.debug('unexpected method type in koa-router prototype.match: %s', typeof method) @@ -32,9 +32,9 @@ module.exports = function (Router, agent, { version, enabled }) { return layer && layer.opts && layer.opts.end === true }) - const path = layer && layer.path + var path = layer && layer.path if (typeof path === 'string') { - const name = method + ' ' + path + var name = method + ' ' + path agent._instrumentation.setDefaultTransactionName(name) } else { agent.logger.debug('unexpected path type in koa-router prototype.match: %s', typeof path) diff --git a/lib/instrumentation/modules/memcached.js b/lib/instrumentation/modules/memcached.js index b641eda8cd..cb84817899 100644 --- a/lib/instrumentation/modules/memcached.js +++ b/lib/instrumentation/modules/memcached.js @@ -6,10 +6,10 @@ 'use strict' -const semver = require('semver') +var semver = require('semver') -const shimmer = require('../shimmer') -const { getDBDestination } = require('../context') +var shimmer = require('../shimmer') +var { getDBDestination } = require('../context') module.exports = function (memcached, agent, { version, enabled }) { if (!enabled) { @@ -48,7 +48,7 @@ module.exports = function (memcached, agent, { version, enabled }) { return original.apply(this, arguments) } - const query = queryCompiler() + var query = queryCompiler() // Replace the queryCompiler function so it isn't called a second time. arguments[0] = function prerunQueryCompiler () { return query diff --git a/lib/instrumentation/modules/mimic-response.js b/lib/instrumentation/modules/mimic-response.js index 36d6825dca..51a9bd8cfd 100644 --- a/lib/instrumentation/modules/mimic-response.js +++ b/lib/instrumentation/modules/mimic-response.js @@ -12,7 +12,7 @@ * See https://github.com/elastic/apm-agent-nodejs/issues/423. */ -const semver = require('semver') +var semver = require('semver') module.exports = function (mimicResponse, agent, { version, enabled }) { if (!enabled) return mimicResponse @@ -22,7 +22,7 @@ module.exports = function (mimicResponse, agent, { version, enabled }) { return mimicResponse } - const ins = agent._instrumentation + var ins = agent._instrumentation return function wrappedMimicResponse (fromStream, toStream) { // If we bound the `fromStream` emitter, but not the `toStream` emitter, we diff --git a/lib/instrumentation/modules/mongodb-core.js b/lib/instrumentation/modules/mongodb-core.js index 42b818bab8..ab08f7e671 100644 --- a/lib/instrumentation/modules/mongodb-core.js +++ b/lib/instrumentation/modules/mongodb-core.js @@ -6,13 +6,13 @@ 'use strict' -const semver = require('semver') +var semver = require('semver') const { getDBDestination } = require('../context') -const shimmer = require('../shimmer') +var shimmer = require('../shimmer') -const SERVER_FNS = ['insert', 'update', 'remove', 'auth'] -const CURSOR_FNS_FIRST = ['next', '_getmore'] +var SERVER_FNS = ['insert', 'update', 'remove', 'auth'] +var CURSOR_FNS_FIRST = ['next', '_getmore'] const firstSpan = Symbol('first-span') @@ -41,17 +41,17 @@ module.exports = function (mongodb, agent, { version, enabled }) { function wrapCommand (orig) { return function wrappedFunction (ns, cmd) { - const trans = agent._instrumentation.currTransaction() - const id = trans && trans.id - let span + var trans = agent._instrumentation.currTransaction() + var id = trans && trans.id + var span agent.logger.debug('intercepted call to mongodb-core.Server.prototype.command %o', { id: id, ns: ns }) if (trans && arguments.length > 0) { - const index = arguments.length - 1 + var index = arguments.length - 1 var cb = arguments[index] if (typeof cb === 'function') { - let type + var type if (cmd.findAndModify) type = 'findAndModify' else if (cmd.createIndexes) type = 'createIndexes' else if (cmd.ismaster) type = 'ismaster' @@ -82,14 +82,14 @@ module.exports = function (mongodb, agent, { version, enabled }) { function wrapQuery (orig, name) { return function wrappedFunction (ns) { - const trans = agent._instrumentation.currTransaction() - const id = trans && trans.id - let span + var trans = agent._instrumentation.currTransaction() + var id = trans && trans.id + var span agent.logger.debug('intercepted call to mongodb-core.Server.prototype.%s %o', name, { id: id, ns: ns }) if (trans && arguments.length > 0) { - const index = arguments.length - 1 + var index = arguments.length - 1 var cb = arguments[index] if (typeof cb === 'function') { span = ins.createSpan(ns + '.' + name, 'db', 'mongodb', 'query', { exitSpan: true }) @@ -115,9 +115,9 @@ module.exports = function (mongodb, agent, { version, enabled }) { } function wrapCursor (orig, name) { return function wrappedFunction () { - const trans = agent._instrumentation.currTransaction() - const id = trans && trans.id - let span + var trans = agent._instrumentation.currTransaction() + var id = trans && trans.id + var span agent.logger.debug('intercepted call to mongodb-core.Cursor.prototype.%s %o', name, { id: id }) @@ -125,7 +125,7 @@ module.exports = function (mongodb, agent, { version, enabled }) { var cb = arguments[0] if (typeof cb === 'function') { if (name !== 'next' || !this[firstSpan]) { - const spanName = `${this.ns}.${this.cmd.find ? 'find' : name}` + var spanName = `${this.ns}.${this.cmd.find ? 'find' : name}` span = ins.createSpan(spanName, 'db', 'mongodb', 'query', { exitSpan: true }) } if (span) { diff --git a/lib/instrumentation/modules/mysql.js b/lib/instrumentation/modules/mysql.js index f8040f72f9..bfad3b991e 100644 --- a/lib/instrumentation/modules/mysql.js +++ b/lib/instrumentation/modules/mysql.js @@ -8,12 +8,12 @@ const EventEmitter = require('events') -const semver = require('semver') -const sqlSummary = require('sql-summary') +var semver = require('semver') +var sqlSummary = require('sql-summary') -const shimmer = require('../shimmer') -const symbols = require('../../symbols') -const { getDBDestination } = require('../context') +var shimmer = require('../shimmer') +var symbols = require('../../symbols') +var { getDBDestination } = require('../context') module.exports = function (mysql, agent, { version, enabled }) { if (!enabled) { @@ -37,7 +37,7 @@ module.exports = function (mysql, agent, { version, enabled }) { function wrapCreateConnection (original) { return function wrappedCreateConnection () { - const connection = original.apply(this, arguments) + var connection = original.apply(this, arguments) wrapQueryable(connection, 'connection', agent) @@ -47,7 +47,7 @@ module.exports = function (mysql, agent, { version, enabled }) { function wrapCreatePool (original) { return function wrappedCreatePool () { - const pool = original.apply(this, arguments) + var pool = original.apply(this, arguments) agent.logger.debug('shimming mysql pool.getConnection') shimmer.wrap(pool, 'getConnection', wrapGetConnection) @@ -58,12 +58,12 @@ module.exports = function (mysql, agent, { version, enabled }) { function wrapCreatePoolCluster (original) { return function wrappedCreatePoolCluster () { - const cluster = original.apply(this, arguments) + var cluster = original.apply(this, arguments) agent.logger.debug('shimming mysql cluster.of') shimmer.wrap(cluster, 'of', function wrapOf (original) { return function wrappedOf () { - const ofCluster = original.apply(this, arguments) + var ofCluster = original.apply(this, arguments) agent.logger.debug('shimming mysql cluster of.getConnection') shimmer.wrap(ofCluster, 'getConnection', wrapGetConnection) @@ -78,7 +78,7 @@ module.exports = function (mysql, agent, { version, enabled }) { function wrapGetConnection (original) { return function wrappedGetConnection () { - const cb = arguments[0] + var cb = arguments[0] if (typeof cb === 'function') { arguments[0] = agent._instrumentation.bindFunction(function wrapedCallback (err, connection) { // eslint-disable-line node/handle-callback-err @@ -107,13 +107,13 @@ function wrapQueryable (connection, objType, agent) { return function wrappedQuery (sql, values, cb) { agent.logger.debug('intercepted call to mysql %s.query', objType) - const span = ins.createSpan(null, 'db', 'mysql', 'query', { exitSpan: true }) + var span = ins.createSpan(null, 'db', 'mysql', 'query', { exitSpan: true }) if (!span) { return original.apply(this, arguments) } - let hasCallback = false - let sqlStr + var hasCallback = false + var sqlStr if (this[symbols.knexStackObj]) { span.customStackTrace(this[symbols.knexStackObj]) diff --git a/lib/instrumentation/modules/mysql2.js b/lib/instrumentation/modules/mysql2.js index 5c003f34fc..7570001368 100644 --- a/lib/instrumentation/modules/mysql2.js +++ b/lib/instrumentation/modules/mysql2.js @@ -6,12 +6,12 @@ 'use strict' -const semver = require('semver') -const sqlSummary = require('sql-summary') +var semver = require('semver') +var sqlSummary = require('sql-summary') -const shimmer = require('../shimmer') -const symbols = require('../../symbols') -const { getDBDestination } = require('../context') +var shimmer = require('../shimmer') +var symbols = require('../../symbols') +var { getDBDestination } = require('../context') module.exports = function (mysql2, agent, { version, enabled }) { if (!enabled) { @@ -22,7 +22,7 @@ module.exports = function (mysql2, agent, { version, enabled }) { return mysql2 } - const ins = agent._instrumentation + var ins = agent._instrumentation shimmer.wrap(mysql2.Connection.prototype, 'query', wrapQuery) shimmer.wrap(mysql2.Connection.prototype, 'execute', wrapQuery) @@ -33,7 +33,7 @@ module.exports = function (mysql2, agent, { version, enabled }) { return function wrappedQuery (sql, values, cb) { agent.logger.debug('intercepted call to mysql2.%s', original.name) - const span = ins.createSpan(null, 'db', 'mysql', 'query', { exitSpan: true }) + var span = ins.createSpan(null, 'db', 'mysql', 'query', { exitSpan: true }) if (!span) { return original.apply(this, arguments) } diff --git a/lib/instrumentation/modules/pg.js b/lib/instrumentation/modules/pg.js index 4a0d16f669..dca971b379 100644 --- a/lib/instrumentation/modules/pg.js +++ b/lib/instrumentation/modules/pg.js @@ -8,12 +8,12 @@ const EventEmitter = require('events') -const semver = require('semver') -const sqlSummary = require('sql-summary') +var semver = require('semver') +var sqlSummary = require('sql-summary') -const shimmer = require('../shimmer') -const symbols = require('../../symbols') -const { getDBDestination } = require('../context') +var shimmer = require('../shimmer') +var symbols = require('../../symbols') +var { getDBDestination } = require('../context') module.exports = function (pg, agent, { version, enabled }) { if (!enabled) { @@ -30,13 +30,13 @@ module.exports = function (pg, agent, { version, enabled }) { // "Cannot find module 'pg-native'" to STDERR if the module isn't installed. // Overwriting the getter we can lazily patch the native client only if the // user is acually requesting it. - const getter = pg.__lookupGetter__('native') + var getter = pg.__lookupGetter__('native') if (getter) { delete pg.native // To be as true to the original pg module as possible, we use // __defineGetter__ instead of Object.defineProperty. pg.__defineGetter__('native', function () { - const native = getter() + var native = getter() if (native && native.Client) { patchClient(native.Client, 'pg.native.Client', agent) } @@ -111,7 +111,7 @@ function patchClient (Client, klass, agent) { }) return orig.apply(this, arguments) } else { - const queryOrPromise = orig.apply(this, arguments) + var queryOrPromise = orig.apply(this, arguments) // It is important to prefer `.on` to `.then` for pg <7 >=6.3.0, because // `query.then` is broken in those versions. See diff --git a/lib/instrumentation/modules/pug.js b/lib/instrumentation/modules/pug.js index e88e57823a..b00597c1f8 100644 --- a/lib/instrumentation/modules/pug.js +++ b/lib/instrumentation/modules/pug.js @@ -6,8 +6,8 @@ 'use strict' -const shimmer = require('../shimmer') -const templateShared = require('../template-shared') +var shimmer = require('../shimmer') +var templateShared = require('../template-shared') module.exports = function (pug, agent, { enabled }) { if (!enabled) return pug diff --git a/lib/instrumentation/modules/redis.js b/lib/instrumentation/modules/redis.js index 0d044905df..b8a4b507ba 100644 --- a/lib/instrumentation/modules/redis.js +++ b/lib/instrumentation/modules/redis.js @@ -6,11 +6,11 @@ 'use strict' -const semver = require('semver') +var semver = require('semver') const constants = require('../../constants') -const shimmer = require('../shimmer') -const { getDBDestination } = require('../context') +var shimmer = require('../shimmer') +var { getDBDestination } = require('../context') const isWrappedRedisCbSym = Symbol('ElasticAPMIsWrappedRedisCb') @@ -39,7 +39,7 @@ module.exports = function (redis, agent, { version, enabled }) { const connOptsFromRedisClient = (rc) => rc.connection_options || rc.connection_option || rc.connectionOption || {} - const proto = redis.RedisClient && redis.RedisClient.prototype + var proto = redis.RedisClient && redis.RedisClient.prototype if (semver.satisfies(version, '>2.5.3')) { agent.logger.debug('shimming redis.RedisClient.prototype.internal_send_command') shimmer.wrap(proto, 'internal_send_command', wrapInternalSendCommand) @@ -113,7 +113,7 @@ module.exports = function (redis, agent, { version, enabled }) { } agent.logger.debug({ command: command }, 'intercepted call to RedisClient.prototype.send_command') - const span = ins.createSpan(command.toUpperCase(), TYPE, SUBTYPE, ACTION, { exitSpan: true }) + var span = ins.createSpan(command.toUpperCase(), TYPE, SUBTYPE, ACTION, { exitSpan: true }) if (!span) { return original.apply(this, arguments) } diff --git a/lib/instrumentation/modules/tedious.js b/lib/instrumentation/modules/tedious.js index 4bb90cb1d1..4a95631f10 100644 --- a/lib/instrumentation/modules/tedious.js +++ b/lib/instrumentation/modules/tedious.js @@ -6,11 +6,11 @@ 'use strict' -const semver = require('semver') -const clone = require('shallow-clone-shim') -const sqlSummary = require('sql-summary') +var semver = require('semver') +var clone = require('shallow-clone-shim') +var sqlSummary = require('sql-summary') -const { getDBDestination } = require('../context') +var { getDBDestination } = require('../context') module.exports = function (tedious, agent, { version, enabled }) { if (!enabled) return tedious diff --git a/lib/instrumentation/modules/ws.js b/lib/instrumentation/modules/ws.js index 0e9141663d..4a20774695 100644 --- a/lib/instrumentation/modules/ws.js +++ b/lib/instrumentation/modules/ws.js @@ -6,9 +6,9 @@ 'use strict' -const semver = require('semver') +var semver = require('semver') -const shimmer = require('../shimmer') +var shimmer = require('../shimmer') module.exports = function (ws, agent, { version, enabled }) { if (!enabled) return ws diff --git a/lib/instrumentation/patch-async.js b/lib/instrumentation/patch-async.js index 119f23f7f2..6cc81e106d 100644 --- a/lib/instrumentation/patch-async.js +++ b/lib/instrumentation/patch-async.js @@ -23,21 +23,21 @@ * BSD-2-Clause, http://opensource.org/licenses/BSD-2-Clause */ -const { promisify } = require('util') +var { promisify } = require('util') -const isNative = require('is-native') -const semver = require('semver') +var isNative = require('is-native') +var semver = require('semver') -const shimmer = require('./shimmer') +var shimmer = require('./shimmer') -const wrap = shimmer.wrap -const massWrap = shimmer.massWrap +var wrap = shimmer.wrap +var massWrap = shimmer.massWrap -const v7plus = semver.gte(process.version, '7.0.0') -const v11plus = semver.gte(process.version, '11.0.0') +var v7plus = semver.gte(process.version, '7.0.0') +var v11plus = semver.gte(process.version, '11.0.0') module.exports = function (ins) { - const net = require('net') + var net = require('net') // From Node.js v7.0.0, net._normalizeConnectArgs have been renamed net._normalizeArgs if (v7plus && !net._normalizeArgs) { @@ -47,8 +47,8 @@ module.exports = function (ins) { return [{}, null] } - const arg0 = args[0] - let options = {} + var arg0 = args[0] + var options = {} if (typeof arg0 === 'object' && arg0 !== null) { // (options[...][, cb]) options = arg0 @@ -63,7 +63,7 @@ module.exports = function (ins) { } } - const cb = args[args.length - 1] + var cb = args[args.length - 1] if (typeof cb !== 'function') { return [options, null] } else { @@ -73,7 +73,7 @@ module.exports = function (ins) { } else if (!v7plus && !net._normalizeConnectArgs) { // a polyfill in our polyfill etc so forth -- taken from node master on 2013/10/30 net._normalizeConnectArgs = function (args) { - let options = {} + var options = {} function toNumber (x) { return (x = Number(x)) >= 0 ? x : false } @@ -91,7 +91,7 @@ module.exports = function (ins) { } } - const cb = args[args.length - 1] + var cb = args[args.length - 1] return typeof cb === 'function' ? [options, cb] : [options] } } @@ -117,7 +117,7 @@ module.exports = function (ins) { function patchOnRead (ctx) { if (ctx && ctx._handle) { - const handle = ctx._handle + var handle = ctx._handle if (!handle._obOriginalOnread) { handle._obOriginalOnread = handle.onread } @@ -128,17 +128,17 @@ module.exports = function (ins) { wrap(net.Socket.prototype, 'connect', function (original) { return function () { // From Node.js v7.0.0, net._normalizeConnectArgs have been renamed net._normalizeArgs - const args = v7plus + var args = v7plus ? net._normalizeArgs(arguments) : net._normalizeConnectArgs(arguments) if (args[1]) args[1] = ins.bindFunction(args[1]) - const result = original.apply(this, args) + var result = original.apply(this, args) patchOnRead(this) return result } }) - const http = require('http') + var http = require('http') // NOTE: A rewrite occurred in 0.11 that changed the addRequest signature // from (req, host, port, localAddress) to (req, options) @@ -146,7 +146,7 @@ module.exports = function (ins) { // the rest of the arguments aren't actually used wrap(http.Agent.prototype, 'addRequest', function (original) { return function (req) { - const onSocket = req.onSocket + var onSocket = req.onSocket req.onSocket = ins.bindFunction(function (socket) { patchOnRead(socket) return onSocket.apply(this, arguments) @@ -155,7 +155,7 @@ module.exports = function (ins) { } }) - const childProcess = require('child_process') + var childProcess = require('child_process') function wrapChildProcess (child) { if (Array.isArray(child.stdio)) { @@ -176,7 +176,7 @@ module.exports = function (ins) { if (childProcess.ChildProcess) { wrap(childProcess.ChildProcess.prototype, 'spawn', function (original) { return function () { - const result = original.apply(this, arguments) + var result = original.apply(this, arguments) wrapChildProcess(this) return result } @@ -188,7 +188,7 @@ module.exports = function (ins) { 'spawn' ], function (original) { return function () { - const result = original.apply(this, arguments) + var result = original.apply(this, arguments) wrapChildProcess(result) return result } @@ -200,7 +200,7 @@ module.exports = function (ins) { process._originalNextTick = process.nextTick } - const processors = [] + var processors = [] if (process._nextDomainTick) processors.push('_nextDomainTick') if (process._tickDomainCallback) processors.push('_tickDomainCallback') @@ -211,14 +211,14 @@ module.exports = function (ins) { ) wrap(process, 'nextTick', activatorFirst) - const asynchronizers = [ + var asynchronizers = [ 'setTimeout', 'setInterval' ] if (global.setImmediate) asynchronizers.push('setImmediate') - const timers = require('timers') - const patchGlobalTimers = global.setTimeout === timers.setTimeout + var timers = require('timers') + var patchGlobalTimers = global.setTimeout === timers.setTimeout massWrap( timers, @@ -234,7 +234,7 @@ module.exports = function (ins) { ) } - const dns = require('dns') + var dns = require('dns') massWrap( dns, [ @@ -254,8 +254,8 @@ module.exports = function (ins) { if (dns.resolveNaptr) wrap(dns, 'resolveNaptr', activator) - const fs = require('fs') - let wrappedFsRealpathNative + var fs = require('fs') + var wrappedFsRealpathNative if (fs.realpath.native) { wrappedFsRealpathNative = wrap(fs.realpath, 'native', activator) } @@ -310,10 +310,10 @@ module.exports = function (ins) { if (fs.ftruncate) wrap(fs, 'ftruncate', activator) // Wrap zlib streams - let zlib + var zlib try { zlib = require('zlib') } catch (err) { } if (zlib && zlib.Deflate && zlib.Deflate.prototype) { - const proto = Object.getPrototypeOf(zlib.Deflate.prototype) + var proto = Object.getPrototypeOf(zlib.Deflate.prototype) if (proto._transform) { // streams2 wrap(proto, '_transform', activator) @@ -332,10 +332,10 @@ module.exports = function (ins) { } // Wrap Crypto - let crypto + var crypto try { crypto = require('crypto') } catch (err) { } if (crypto) { - const cryptoFunctions = ['pbkdf2', 'randomBytes'] + var cryptoFunctions = ['pbkdf2', 'randomBytes'] if (!v11plus) cryptoFunctions.push('pseudoRandomBytes') massWrap( crypto, @@ -344,7 +344,7 @@ module.exports = function (ins) { ) } - let instrumentPromise = isNative(global.Promise) + var instrumentPromise = isNative(global.Promise) // In case it's a non-native Promise, but bind have been used so it // looks native. There's still a potential false positive if the @@ -408,7 +408,7 @@ module.exports = function (ins) { } function wrapPromise () { - const Promise = global.Promise + var Promise = global.Promise wrap(Promise.prototype, 'then', wrapThen) // Node.js = 0 && !sourceMapUrl; i--) { + var lines = sourceFile.split(/\r?\n/) + var sourceMapUrl = null + for (var i = lines.length - 1; i >= 0 && !sourceMapUrl; i--) { sourceMapUrl = lines[i].match(SOURCEMAP_REGEX) } @@ -85,6 +85,6 @@ function isInlineMap (url) { } function decodeInlineMap (data) { - const rawData = data.slice(data.indexOf(',') + 1) + var rawData = data.slice(data.indexOf(',') + 1) return Buffer.from(rawData, 'base64').toString() } diff --git a/lib/logging.js b/lib/logging.js index f934bf123f..4727eadade 100644 --- a/lib/logging.js +++ b/lib/logging.js @@ -34,9 +34,9 @@ // - error // - fatal - mapped to "critical" for backward compat -const ecsFormat = require('@elastic/ecs-pino-format') -const pino = require('pino') -const semver = require('semver') +var ecsFormat = require('@elastic/ecs-pino-format') +var pino = require('pino') +var semver = require('semver') const DEFAULT_LOG_LEVEL = 'info' diff --git a/lib/middleware/connect.js b/lib/middleware/connect.js index 69385d9c3b..e6d4848f40 100644 --- a/lib/middleware/connect.js +++ b/lib/middleware/connect.js @@ -7,7 +7,7 @@ 'use strict' module.exports = function connectMiddleware () { - const agent = this + var agent = this return function (err, req, res, next) { agent.captureError(err, { request: req }, function elasticAPMMiddleware () { next(err) diff --git a/lib/opentelemetry-bridge/OTelSpan.js b/lib/opentelemetry-bridge/OTelSpan.js index eda8127e7a..f9341e465d 100644 --- a/lib/opentelemetry-bridge/OTelSpan.js +++ b/lib/opentelemetry-bridge/OTelSpan.js @@ -229,7 +229,7 @@ class OTelSpan { if (u.port !== '') { return u.host // host:port already in URL } else { - const port = httpPortFromScheme(u.protocol.substring(0, u.protocol.length - 1)) + var port = httpPortFromScheme(u.protocol.substring(0, u.protocol.length - 1)) return port > 0 ? u.hostname + ':' + port : u.hostname } } diff --git a/lib/opentelemetry-metrics/ElasticApmMetricExporter.js b/lib/opentelemetry-metrics/ElasticApmMetricExporter.js index 9cf4f3c573..db1b542df5 100644 --- a/lib/opentelemetry-metrics/ElasticApmMetricExporter.js +++ b/lib/opentelemetry-metrics/ElasticApmMetricExporter.js @@ -247,7 +247,7 @@ class ElasticApmMetricExporter { */ _labelsFromOTelMetricAttributes (attrs, metricName) { const keys = Object.keys(attrs) - for (let i = 0; i < keys.length; i++) { + for (var i = 0; i < keys.length; i++) { const k = keys[i] const v = attrs[k] if (Array.isArray(v)) { diff --git a/lib/parsers.js b/lib/parsers.js index 5735c11eca..17103d541f 100644 --- a/lib/parsers.js +++ b/lib/parsers.js @@ -41,9 +41,9 @@ const { * is being captured for an APM error or transaction event. */ function getContextFromRequest (req, conf, type) { - const captureBody = conf.captureBody === type || conf.captureBody === 'all' + var captureBody = conf.captureBody === type || conf.captureBody === 'all' - const context = { + var context = { http_version: req.httpVersion, method: req.method, url: getUrlFromRequest(req), @@ -71,11 +71,11 @@ function getContextFromRequest (req, conf, type) { } } - const contentLength = parseInt(req.headers['content-length'], 10) - const transferEncoding = req.headers['transfer-encoding'] - const chunked = typeof transferEncoding === 'string' && transferEncoding.toLowerCase() === 'chunked' - let body = req.json || req.body || req.payload - const haveBody = body && (chunked || contentLength > 0) + var contentLength = parseInt(req.headers['content-length'], 10) + var transferEncoding = req.headers['transfer-encoding'] + var chunked = typeof transferEncoding === 'string' && transferEncoding.toLowerCase() === 'chunked' + var body = req.json || req.body || req.payload + var haveBody = body && (chunked || contentLength > 0) if (haveBody) { if (!captureBody) { @@ -103,7 +103,7 @@ function getContextFromRequest (req, conf, type) { } function getContextFromResponse (res, conf, isError) { - const context = { + var context = { status_code: res.statusCode, headers: undefined } @@ -132,12 +132,12 @@ function getContextFromResponse (res, conf, isError) { * - `headers` - Required. An object. */ function getUserContextFromRequest (req) { - const user = req.user || basicAuth(req) || req.session + var user = req.user || basicAuth(req) || req.session if (!user) { return } - const context = {} + var context = {} if (typeof user.id === 'string' || typeof user.id === 'number') { context.id = user.id diff --git a/lib/propwrap.js b/lib/propwrap.js index 952d78d0c5..194edc7bb5 100644 --- a/lib/propwrap.js +++ b/lib/propwrap.js @@ -39,11 +39,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -const __defProp = Object.defineProperty -const __getOwnPropDesc = Object.getOwnPropertyDescriptor -const __hasOwnProp = Object.prototype.hasOwnProperty -const __getOwnPropNames = Object.getOwnPropertyNames -const __copyProps = (to, from, except, desc) => { +var __defProp = Object.defineProperty +var __getOwnPropDesc = Object.getOwnPropertyDescriptor +var __hasOwnProp = Object.prototype.hasOwnProperty +var __getOwnPropNames = Object.getOwnPropertyNames +var __copyProps = (to, from, except, desc) => { if ((from && typeof from === 'object') || typeof from === 'function') { for (const key of __getOwnPropNames(from)) { if (!__hasOwnProp.call(to, key) && key !== except) { diff --git a/lib/redact-secrets/index.js b/lib/redact-secrets/index.js index 817e5a275d..5dfdfbefbe 100644 --- a/lib/redact-secrets/index.js +++ b/lib/redact-secrets/index.js @@ -28,8 +28,8 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -const traverse = require('traverse') -const isSecret = require('./is-secret') +var traverse = require('traverse') +var isSecret = require('./is-secret') module.exports = function (redacted) { return { diff --git a/lib/redact-secrets/is-secret.js b/lib/redact-secrets/is-secret.js index 442139665f..a985d702a4 100644 --- a/lib/redact-secrets/is-secret.js +++ b/lib/redact-secrets/is-secret.js @@ -31,7 +31,7 @@ const agent = require('../..') -const KEYS = [ +var KEYS = [ // generic /passw(or)?d/i, /^pw$/, @@ -45,7 +45,7 @@ const KEYS = [ /^connect\.sid$/ // https://github.com/expressjs/session ] -const VALUES = [ +var VALUES = [ /^\d{4}[- ]?\d{4}[- ]?\d{4}[- ]?\d{4}$/ // credit card number ] exports.key = key diff --git a/lib/stacktraces.js b/lib/stacktraces.js index 68d9d7d1d8..b3ed19935e 100644 --- a/lib/stacktraces.js +++ b/lib/stacktraces.js @@ -13,8 +13,8 @@ // A lot of this derived from https://github.com/watson/stackman but was // moved internal to allow breaking compat for perf work. -const fs = require('fs') -const path = require('path') +var fs = require('fs') +var path = require('path') const asyncCache = require('async-cache') const afterAllResults = require('after-all-results') @@ -113,7 +113,7 @@ function stackTraceFromErrStackString (log, err) { if (frames) { const cwd = getCwd(log) - for (let i = 0; i < frames.length; i++) { + for (var i = 0; i < frames.length; i++) { const frame = frames[i] const filename = frame.getFileName() || '' stacktrace.push({ @@ -212,17 +212,17 @@ function getCallSiteTypeNameSafely (callsite) { // From stackman getFunctionNameSanitized(). function getCallSiteFunctionNameSanitized (callsite) { - const fnName = callsite.getFunctionName() + var fnName = callsite.getFunctionName() if (fnName) return fnName - const typeName = getCallSiteTypeNameSafely(callsite) + var typeName = getCallSiteTypeNameSafely(callsite) if (typeName) return typeName + '.' + (callsite.getMethodName() || '') return '' } function addSourceContextToFrame (frame, lines, lineNum, n) { - const index = lineNum - 1 // lines 1-based -> index 0-based - const nBefore = Math.ceil((n - 1) / 2) - const nAfter = Math.floor((n - 1) / 2) + var index = lineNum - 1 // lines 1-based -> index 0-based + var nBefore = Math.ceil((n - 1) / 2) + var nAfter = Math.floor((n - 1) / 2) frame.pre_context = lines.slice(Math.max(0, index - nBefore), index) frame.context_line = lines[index] frame.post_context = lines.slice(index + 1, index + 1 + nAfter) @@ -242,7 +242,7 @@ function getSourceMapConsumer (callsite, cb) { if (isCallSiteNode(callsite)) { process.nextTick(cb, null, null) } else { - const filename = callsite.getFileName() + var filename = callsite.getFileName() if (!filename) { process.nextTick(cb, null, null) } else { @@ -351,7 +351,7 @@ function frameFromCallSite (log, callsite, cwd, sourceLinesAppFrames, sourceLine } // Finish early if we do not need to collect source lines of context. - const linesOfContext = (isApp ? sourceLinesAppFrames : sourceLinesLibraryFrames) + var linesOfContext = (isApp ? sourceLinesAppFrames : sourceLinesLibraryFrames) if (linesOfContext === 0 || !filename || isCallSiteNode(callsite)) { cacheAndCb(frame) return @@ -366,7 +366,7 @@ function frameFromCallSite (log, callsite, cwd, sourceLinesAppFrames, sourceLine const sourceFilename = sourceMapConsumer.sourceRoot ? path.relative(sourceMapConsumer.sourceRoot, mappedFilename) : mappedFilename - const source = sourceMapConsumer.sourceContentFor(sourceFilename, true) + var source = sourceMapConsumer.sourceContentFor(sourceFilename, true) log.trace({ sourceRoot: sourceMapConsumer.sourceRoot, mappedFilename, diff --git a/test/InflightEventSet.test.js b/test/InflightEventSet.test.js index 9712768574..f40a0bac31 100644 --- a/test/InflightEventSet.test.js +++ b/test/InflightEventSet.test.js @@ -6,7 +6,7 @@ 'use strict' -const tape = require('tape') +var tape = require('tape') const { InflightEventSet } = require('../lib/InflightEventSet') diff --git a/test/_agent.js b/test/_agent.js index 3fd915a8ee..90d208c1c2 100644 --- a/test/_agent.js +++ b/test/_agent.js @@ -18,13 +18,13 @@ // t.end() // }) -const Agent = require('../lib/agent') -const symbols = require('../lib/symbols') +var Agent = require('../lib/agent') +var symbols = require('../lib/symbols') -const Filters = require('object-filter-sequence') +var Filters = require('object-filter-sequence') -let uncaughtExceptionListeners = process._events.uncaughtException -let agent +var uncaughtExceptionListeners = process._events.uncaughtException +var agent module.exports = setup diff --git a/test/_assert.js b/test/_assert.js index ac46bda2f0..4349b60a79 100644 --- a/test/_assert.js +++ b/test/_assert.js @@ -6,9 +6,9 @@ 'use strict' -const path = require('path') -const Agent = require('../lib/agent') -const agent = new Agent() +var path = require('path') +var Agent = require('../lib/agent') +var agent = new Agent() agent._config({}) exports.stacktrace = function (t, topFunctionName, topAbsPath, stacktrace, _agent, isError) { @@ -21,17 +21,17 @@ exports.stacktrace = function (t, topFunctionName, topAbsPath, stacktrace, _agen } function stackFrameValidator (t, agent, isError) { - const conf = agent._conf + var conf = agent._conf return function (frame) { - const nodeCore = !path.isAbsolute(frame.abs_path) + var nodeCore = !path.isAbsolute(frame.abs_path) - const lines = isError + var lines = isError ? (frame.library_frame ? conf.sourceLinesErrorLibraryFrames : conf.sourceLinesErrorAppFrames) : (frame.library_frame ? conf.sourceLinesSpanLibraryFrames : conf.sourceLinesSpanAppFrames) - const shouldHaveSource = !nodeCore && lines !== 0 + var shouldHaveSource = !nodeCore && lines !== 0 - const expectedKeys = shouldHaveSource + var expectedKeys = shouldHaveSource ? ['filename', 'lineno', 'function', 'library_frame', 'abs_path', 'pre_context', 'context_line', 'post_context'] : ['filename', 'lineno', 'function', 'library_frame', 'abs_path'] t.deepEqual(Object.keys(frame), expectedKeys, 'frame should have expected properties') diff --git a/test/_is_fastify_incompat.js b/test/_is_fastify_incompat.js index 36d96393c2..7c34298b4b 100644 --- a/test/_is_fastify_incompat.js +++ b/test/_is_fastify_incompat.js @@ -6,7 +6,7 @@ 'use strict' -const semver = require('semver') +var semver = require('semver') /** * Return whether the current 'fastify' version is incompatible with the diff --git a/test/_is_hapi_incompat.js b/test/_is_hapi_incompat.js index 5354b1e5e4..0d1d3168b5 100644 --- a/test/_is_hapi_incompat.js +++ b/test/_is_hapi_incompat.js @@ -6,13 +6,13 @@ 'use strict' -const semver = require('semver') +var semver = require('semver') // 'hapi' and '@hapi/hapi' versions have some challenges with compat with // various versions of node. This method tells you if the current versions // are incompatible. function isHapiIncompat (moduleName) { - const hapiVersion = require(`${moduleName}/package.json`).version + var hapiVersion = require(`${moduleName}/package.json`).version // hapi 17+ requires Node.js 8.9.0 or higher if (semver.lt(process.version, '8.9.0') && semver.gte(hapiVersion, '17.0.0')) { @@ -39,7 +39,7 @@ function isHapiIncompat (moduleName) { // https://github.com/nodejs/node/issues/20516 // // NOTE: Do not use semver.satisfies, as it does not match prereleases - const parsed = semver.parse(process.version) + var parsed = semver.parse(process.version) if (parsed.major === 10 && parsed.minor >= 0 && parsed.minor < 8) { return true } diff --git a/test/_is_mongodb_incompat.js b/test/_is_mongodb_incompat.js index 945e5f1fd2..cb351be82b 100644 --- a/test/_is_mongodb_incompat.js +++ b/test/_is_mongodb_incompat.js @@ -6,7 +6,7 @@ 'use strict' -const semver = require('semver') +var semver = require('semver') /** * Return whether the current 'mongodb' version is incompatible with the diff --git a/test/_is_restify_incompat.js b/test/_is_restify_incompat.js index 7fd260bde8..2f100b2fdf 100644 --- a/test/_is_restify_incompat.js +++ b/test/_is_restify_incompat.js @@ -6,7 +6,7 @@ 'use strict' -const semver = require('semver') +var semver = require('semver') /** * Return whether the current 'restify' version is incompatible with the diff --git a/test/_is_undici_incompat.js b/test/_is_undici_incompat.js index 0e37aad57e..5c444b4a99 100644 --- a/test/_is_undici_incompat.js +++ b/test/_is_undici_incompat.js @@ -6,7 +6,7 @@ 'use strict' -const semver = require('semver') +var semver = require('semver') /** * Return whether the current 'undici' version is incompatible with the diff --git a/test/_mock_apm_server.js b/test/_mock_apm_server.js index 9ecbe75b16..353c970c3d 100644 --- a/test/_mock_apm_server.js +++ b/test/_mock_apm_server.js @@ -46,8 +46,8 @@ class MockAPMServer { } _onRequest (req, res) { - const parsedUrl = new URL(req.url, this.serverUrl) - let instream = req + var parsedUrl = new URL(req.url, this.serverUrl) + var instream = req if (req.headers['content-encoding'] === 'gzip') { instream = req.pipe(zlib.createGunzip()) } else { diff --git a/test/_utils.js b/test/_utils.js index 90b594a1dc..99aaa5184b 100644 --- a/test/_utils.js +++ b/test/_utils.js @@ -15,10 +15,10 @@ const moduleDetailsFromPath = require('module-details-from-path') // Lookup the property "str" (given in dot-notation) in the object "obj". // If the property isn't found, then `undefined` is returned. function dottedLookup (obj, str) { - let o = obj - const fields = str.split('.') - for (let i = 0; i < fields.length; i++) { - const field = fields[i] + var o = obj + var fields = str.split('.') + for (var i = 0; i < fields.length; i++) { + var field = fields[i] if (!Object.prototype.hasOwnProperty.call(o, field)) { return undefined } diff --git a/test/activation-method/activation-method.test.js b/test/activation-method/activation-method.test.js index 4560af0b6c..675cbf627a 100644 --- a/test/activation-method/activation-method.test.js +++ b/test/activation-method/activation-method.test.js @@ -44,7 +44,7 @@ tape.test(`setup: npm install (in ${fixturesDir})`, { skip: haveNodeModules }, t tape.test('metadata.system.agent.activation_method fixtures', function (suite) { // Note: We do not test the "aws-lambda-layer" case, because this would // require simulating an agent install to the special path used in that case. - const cases = [ + var cases = [ { script: 'require1.js', expectedMethod: 'require' diff --git a/test/agent.test.js b/test/agent.test.js index a24f4977b1..458b68311a 100644 --- a/test/agent.test.js +++ b/test/agent.test.js @@ -12,11 +12,11 @@ // we do not need to start the agent at the top of file. Instead, tests create // separate instances of the Agent. -const http = require('http') -const path = require('path') -const os = require('os') +var http = require('http') +var path = require('path') +var os = require('os') -const test = require('tape') +var test = require('tape') const Agent = require('../lib/agent') const { @@ -28,7 +28,7 @@ const { const { findObjInArray } = require('./_utils') const { MockAPMServer } = require('./_mock_apm_server') const { NoopApmClient } = require('../lib/apm-client/noop-apm-client') -const packageJson = require('../package.json') +var packageJson = require('../package.json') // Options to pass to `agent.start()` to turn off some default agent behavior // that is unhelpful for these tests. @@ -170,7 +170,7 @@ test('#startTransaction()', function (t) { t.test('name, type, subtype and action', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - const trans = agent.startTransaction('foo', 'type', 'subtype', 'action') + var trans = agent.startTransaction('foo', 'type', 'subtype', 'action') t.strictEqual(trans.name, 'foo') t.strictEqual(trans.type, 'type') t.strictEqual(trans.subtype, 'subtype') @@ -181,10 +181,10 @@ test('#startTransaction()', function (t) { t.test('options.startTime', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - const startTime = Date.now() - 1000 - const trans = agent.startTransaction('foo', 'bar', { startTime }) + var startTime = Date.now() - 1000 + var trans = agent.startTransaction('foo', 'bar', { startTime }) trans.end() - const duration = trans.duration() + var duration = trans.duration() t.ok(duration > 990, `duration should be circa more than 1s (was: ${duration})`) // we've seen 998.752 in the wild t.ok(duration < 1100, `duration should be less than 1.1s (was: ${duration})`) agent.destroy() @@ -193,8 +193,8 @@ test('#startTransaction()', function (t) { t.test('options.childOf', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - const childOf = '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01' - const trans = agent.startTransaction('foo', 'bar', { childOf }) + var childOf = '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01' + var trans = agent.startTransaction('foo', 'bar', { childOf }) t.strictEqual(trans._context.traceparent.version, '00') t.strictEqual(trans._context.traceparent.traceId, '4bf92f3577b34da6a3ce929d0e0e4736') t.notEqual(trans._context.traceparent.id, '00f067aa0ba902b7') @@ -217,7 +217,7 @@ test('#endTransaction()', function (t) { t.test('with no result', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - const trans = agent.startTransaction() + var trans = agent.startTransaction() t.strictEqual(trans.ended, false) agent.endTransaction() t.strictEqual(trans.ended, true) @@ -228,7 +228,7 @@ test('#endTransaction()', function (t) { t.test('with explicit result', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - const trans = agent.startTransaction() + var trans = agent.startTransaction() t.strictEqual(trans.ended, false) agent.endTransaction('done') t.strictEqual(trans.ended, true) @@ -239,9 +239,9 @@ test('#endTransaction()', function (t) { t.test('with custom endTime', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - const startTime = Date.now() - 1000 - const endTime = startTime + 2000.123 - const trans = agent.startTransaction('foo', 'bar', { startTime }) + var startTime = Date.now() - 1000 + var endTime = startTime + 2000.123 + var trans = agent.startTransaction('foo', 'bar', { startTime }) agent.endTransaction('done', endTime) t.strictEqual(trans.duration(), 2000.123) agent.destroy() @@ -261,7 +261,7 @@ test('#currentTransaction', function (t) { t.test('with active transaction', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - const trans = agent.startTransaction() + var trans = agent.startTransaction() t.strictEqual(agent.currentTransaction, trans) agent.endTransaction() agent.destroy() @@ -279,8 +279,8 @@ test('#currentSpan', function (t) { t.test('with binding span', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - const trans = agent.startTransaction() - const span = agent.startSpan() + var trans = agent.startTransaction() + var span = agent.startSpan() t.strictEqual(agent.currentSpan, span) span.end() trans.end() @@ -290,8 +290,8 @@ test('#currentSpan', function (t) { t.test('with active span', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - const trans = agent.startTransaction() - const span = agent.startSpan() + var trans = agent.startTransaction() + var span = agent.startSpan() process.nextTick(() => { t.strictEqual(agent.currentSpan, span) span.end() @@ -314,7 +314,7 @@ test('#currentTraceparent', function (t) { t.test('with active transaction', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - const trans = agent.startTransaction() + var trans = agent.startTransaction() t.strictEqual(agent.currentTraceparent, trans.traceparent) agent.endTransaction() agent.destroy() @@ -324,7 +324,7 @@ test('#currentTraceparent', function (t) { t.test('with active span', function (t) { const agent = new Agent().start(agentOptsNoopTransport) agent.startTransaction() - const span = agent.startSpan() + var span = agent.startSpan() t.strictEqual(agent.currentTraceparent, span.traceparent) span.end() agent.endTransaction() @@ -346,7 +346,7 @@ test('#currentTraceIds', function (t) { t.test('with active transaction', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - const trans = agent.startTransaction() + var trans = agent.startTransaction() t.deepLooseEqual(agent.currentTraceIds, { 'trace.id': trans.traceId, 'transaction.id': trans.id @@ -360,7 +360,7 @@ test('#currentTraceIds', function (t) { t.test('with active span', function (t) { const agent = new Agent().start(agentOptsNoopTransport) agent.startTransaction() - const span = agent.startSpan() + var span = agent.startSpan() t.deepLooseEqual(agent.currentTraceIds, { 'trace.id': span.traceId, 'span.id': span.id @@ -387,7 +387,7 @@ test('#setTransactionName', function (t) { t.test('active transaction', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - const trans = agent.startTransaction() + var trans = agent.startTransaction() agent.setTransactionName('foo') t.strictEqual(trans.name, 'foo') agent.destroy() @@ -408,7 +408,7 @@ test('#startSpan()', function (t) { t.test('active transaction', function (t) { const agent = new Agent().start(agentOptsNoopTransport) agent.startTransaction() - const span = agent.startSpan('span-name', 'type', 'subtype', 'action') + var span = agent.startSpan('span-name', 'type', 'subtype', 'action') t.ok(span, 'should return a span') t.strictEqual(span.name, 'span-name') t.strictEqual(span.type, 'type') @@ -421,7 +421,7 @@ test('#startSpan()', function (t) { t.test('startSpan with no name results in span.name="unnamed"', function (t) { const agent = new Agent().start(agentOptsNoopTransport) agent.startTransaction() - const span = agent.startSpan() + var span = agent.startSpan() t.ok(span, 'should return a span') t.strictEqual(span.name, 'unnamed') t.strictEqual(span.type, 'custom') @@ -434,10 +434,10 @@ test('#startSpan()', function (t) { t.test('options.startTime', function (t) { const agent = new Agent().start(agentOptsNoopTransport) agent.startTransaction() - const startTime = Date.now() - 1000 - const span = agent.startSpan('span-with-startTime', null, { startTime }) + var startTime = Date.now() - 1000 + var span = agent.startSpan('span-with-startTime', null, { startTime }) span.end() - const duration = span.duration() + var duration = span.duration() t.ok(duration > 990, `duration should be circa more than 1s (was: ${duration})`) // we've seen 998.752 in the wild t.ok(duration < 1100, `duration should be less than 1.1s (was: ${duration})`) agent.destroy() @@ -447,8 +447,8 @@ test('#startSpan()', function (t) { t.test('options.childOf', function (t) { const agent = new Agent().start(agentOptsNoopTransport) agent.startTransaction() - const childOf = '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01' - const span = agent.startSpan(null, null, { childOf }) + var childOf = '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01' + var span = agent.startSpan(null, null, { childOf }) t.strictEqual(span._context.traceparent.version, '00') t.strictEqual(span._context.traceparent.traceId, '4bf92f3577b34da6a3ce929d0e0e4736') t.notEqual(span._context.traceparent.id, '00f067aa0ba902b7') @@ -472,7 +472,7 @@ test('#setUserContext()', function (t) { t.test('active transaction', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - const trans = agent.startTransaction() + var trans = agent.startTransaction() t.strictEqual(agent.setUserContext({ foo: 1 }), true) t.deepEqual(trans._user, { foo: 1 }) agent.destroy() @@ -492,7 +492,7 @@ test('#setCustomContext()', function (t) { t.test('active transaction', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - const trans = agent.startTransaction() + var trans = agent.startTransaction() t.strictEqual(agent.setCustomContext({ foo: 1 }), true) t.deepEqual(trans._custom, { foo: 1 }) agent.destroy() @@ -586,7 +586,7 @@ test('#setLabel()', function (t) { t.test('active transaction', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - const trans = agent.startTransaction() + var trans = agent.startTransaction() t.strictEqual(agent.setLabel('foo', 1), true) t.deepEqual(trans._labels, { foo: '1' }) agent.destroy() @@ -595,7 +595,7 @@ test('#setLabel()', function (t) { t.test('active transaction without label stringification', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - const trans = agent.startTransaction() + var trans = agent.startTransaction() t.strictEqual(agent.setLabel('positive', 1, false), true) t.strictEqual(agent.setLabel('negative', -10, false), true) t.strictEqual(agent.setLabel('boolean-true', true, false), true) @@ -625,7 +625,7 @@ test('#addLabels()', function (t) { t.test('active transaction', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - const trans = agent.startTransaction() + var trans = agent.startTransaction() t.strictEqual(agent.addLabels({ foo: 1, bar: 2 }), true) t.strictEqual(agent.addLabels({ foo: 3 }), true) t.deepEqual(trans._labels, { foo: '3', bar: '2' }) @@ -635,7 +635,7 @@ test('#addLabels()', function (t) { t.test('active transaction without label stringification', function (t) { const agent = new Agent().start(agentOptsNoopTransport) - const trans = agent.startTransaction() + var trans = agent.startTransaction() t.strictEqual(agent.addLabels({ foo: 1, bar: true }, false), true) t.deepEqual(trans._labels, { foo: 1, bar: true }) agent.destroy() @@ -1073,7 +1073,7 @@ test('#flush()', function (t) { { serverUrl } )) const t0 = agent.startTransaction('t0') - for (let i = 0; i < 10; i++) { + for (var i = 0; i < 10; i++) { agent.startSpan('s').end() } t0.end() @@ -1081,7 +1081,7 @@ test('#flush()', function (t) { t.error(err, 'no error passed to agent.flush callback') t.equal(apmServer.events.length, 12, 'apmServer got 12 events') t.equal(apmServer.events[1].transaction.name, 't0', 'event[1] is transaction t0') - for (let i = 2; i < 12; i++) { + for (var i = 2; i < 12; i++) { t.equal(apmServer.events[i].span.name, 's', `event[${i}] is span s`) } @@ -1335,7 +1335,7 @@ test('#captureError()', function (t) { t.test('should not fail on a non string err.message', function (t) { const agent = new Agent().start(ceAgentOpts) - const err = new Error() + var err = new Error() err.message = { foo: 'bar' } agent.captureError(err, function () { t.equal(apmServer.events.length, 2, 'APM server got 2 events') @@ -1863,7 +1863,7 @@ test('#handleUncaughtExceptions()', function (t) { t.test('should not add more than one listener for the uncaughtException event', function (t) { const agent = new Agent().start(agentOptsNoopTransport) agent.handleUncaughtExceptions() - const before = process._events.uncaughtException.length + var before = process._events.uncaughtException.length agent.handleUncaughtExceptions() t.strictEqual(process._events.uncaughtException.length, before) @@ -1951,7 +1951,7 @@ test('patches', function (t) { agent.clearPatches('express') agent.start(agentOptsNoopTransport) - const replacement = { + var replacement = { foo: 'bar' } diff --git a/test/apm-client/http-apm-client.test.js b/test/apm-client/http-apm-client.test.js index e30f343127..d34ad1fb8e 100644 --- a/test/apm-client/http-apm-client.test.js +++ b/test/apm-client/http-apm-client.test.js @@ -8,7 +8,7 @@ const test = require('tape') -const apmVersion = require('../../package').version +var apmVersion = require('../../package').version const { userAgentFromConf } = require('../../lib/apm-client/http-apm-client') diff --git a/test/benchmarks/001-transaction-and-span-no-stack-trace.js b/test/benchmarks/001-transaction-and-span-no-stack-trace.js index fa7e32d508..e3ba291390 100644 --- a/test/benchmarks/001-transaction-and-span-no-stack-trace.js +++ b/test/benchmarks/001-transaction-and-span-no-stack-trace.js @@ -15,7 +15,7 @@ bench('transaction-and-span-no-stack-trace', { spanStackTraceMinDuration: -1 }, setup () { - const agent = this.benchmark.agent + var agent = this.benchmark.agent }, fn (deferred) { if (agent) agent.startTransaction() diff --git a/test/benchmarks/002-transaction-and-span-overhead-realistic-size.js b/test/benchmarks/002-transaction-and-span-overhead-realistic-size.js index 4f6d9aa44d..37721cd475 100644 --- a/test/benchmarks/002-transaction-and-span-overhead-realistic-size.js +++ b/test/benchmarks/002-transaction-and-span-overhead-realistic-size.js @@ -17,14 +17,14 @@ const bench = require('./utils/bench') bench('transaction-and-span-overhead-realistic-size', { setup () { - const agent = this.benchmark.agent - const callstack = this.benchmark.callstack + var agent = this.benchmark.agent + var callstack = this.benchmark.callstack // To avoid randomness, but still generate what appears to be natural random // call stacks, number of spans etc, use a pre-defined set of numbers - const numbers = [2, 5, 10, 1, 2, 21, 2, 5, 6, 9, 1, 11, 9, 8, 12] - const numbersSpanIndex = 5 - const numbersStackLevelIndex = 0 + var numbers = [2, 5, 10, 1, 2, 21, 2, 5, 6, 9, 1, 11, 9, 8, 12] + var numbersSpanIndex = 5 + var numbersStackLevelIndex = 0 function addSpan (amount, cb) { setImmediate(() => { diff --git a/test/benchmarks/003-transaction-and-span-with-stack-trace.js b/test/benchmarks/003-transaction-and-span-with-stack-trace.js index 10065d5712..67a828000b 100644 --- a/test/benchmarks/003-transaction-and-span-with-stack-trace.js +++ b/test/benchmarks/003-transaction-and-span-with-stack-trace.js @@ -16,7 +16,7 @@ bench('transaction-and-span-with-stack-trace', { spanFramesMinDuration: '-1ms' }, setup () { - const agent = this.benchmark.agent + var agent = this.benchmark.agent }, fn (deferred) { if (agent) agent.startTransaction() diff --git a/test/benchmarks/004-transaction.js b/test/benchmarks/004-transaction.js index 1a5a077985..35aba5df61 100644 --- a/test/benchmarks/004-transaction.js +++ b/test/benchmarks/004-transaction.js @@ -12,7 +12,7 @@ const bench = require('./utils/bench') bench('transaction', { setup () { - const agent = this.benchmark.agent + var agent = this.benchmark.agent }, fn (deferred) { if (agent) agent.startTransaction() diff --git a/test/benchmarks/005-transaction-reading-file.js b/test/benchmarks/005-transaction-reading-file.js index c8fb5829d0..20864216f4 100644 --- a/test/benchmarks/005-transaction-reading-file.js +++ b/test/benchmarks/005-transaction-reading-file.js @@ -12,9 +12,9 @@ const bench = require('./utils/bench') bench('transaction-reading-file', { setup () { - const agent = this.benchmark.agent - const fs = this.benchmark.fs - const filename = this.benchmark.testFile + var agent = this.benchmark.agent + var fs = this.benchmark.fs + var filename = this.benchmark.testFile }, fn (deferred) { if (agent) agent.startTransaction() diff --git a/test/benchmarks/006-transaction-and-span-overhead-realistic-size-with-stack-trace.js b/test/benchmarks/006-transaction-and-span-overhead-realistic-size-with-stack-trace.js index 36fc820a03..86c216eacc 100644 --- a/test/benchmarks/006-transaction-and-span-overhead-realistic-size-with-stack-trace.js +++ b/test/benchmarks/006-transaction-and-span-overhead-realistic-size-with-stack-trace.js @@ -22,14 +22,14 @@ bench('transaction-and-span-overhead-realistic-size-with-stack-trace', { spanStackTraceMinDuration: 0 // ensure span stacktrace collection }, setup () { - const agent = this.benchmark.agent - const callstack = this.benchmark.callstack + var agent = this.benchmark.agent + var callstack = this.benchmark.callstack // To avoid randomness, but still generate what appears to be natural random // call stacks, number of spans etc, use a pre-defined set of numbers - const numbers = [2, 5, 10, 1, 2, 21, 2, 5, 6, 9, 1, 11, 9, 8, 12] - const numbersSpanIndex = 5 - const numbersStackLevelIndex = 0 + var numbers = [2, 5, 10, 1, 2, 21, 2, 5, 6, 9, 1, 11, 9, 8, 12] + var numbersSpanIndex = 5 + var numbersStackLevelIndex = 0 function addSpan (amount, cb) { setImmediate(() => { diff --git a/test/config.test.js b/test/config.test.js index e641d0408a..4cc0a5625e 100644 --- a/test/config.test.js +++ b/test/config.test.js @@ -6,18 +6,18 @@ 'use strict' -const cp = require('child_process') -const fs = require('fs') -const IncomingMessage = require('http').IncomingMessage -const os = require('os') -const path = require('path') -const util = require('util') - -const isRegExp = require('core-util-is').isRegExp -const mkdirp = require('mkdirp') -const rimraf = require('rimraf') -const semver = require('semver') -const test = require('tape') +var cp = require('child_process') +var fs = require('fs') +var IncomingMessage = require('http').IncomingMessage +var os = require('os') +var path = require('path') +var util = require('util') + +var isRegExp = require('core-util-is').isRegExp +var mkdirp = require('mkdirp') +var rimraf = require('rimraf') +var semver = require('semver') +var test = require('tape') const Agent = require('../lib/agent') const { MockAPMServer } = require('./_mock_apm_server') @@ -33,10 +33,10 @@ const { } = require('../lib/config/schema') const config = require('../lib/config/config') -const Instrumentation = require('../lib/instrumentation') -const apmVersion = require('../package').version -const apmName = require('../package').name -const isHapiIncompat = require('./_is_hapi_incompat') +var Instrumentation = require('../lib/instrumentation') +var apmVersion = require('../package').version +var apmName = require('../package').name +var isHapiIncompat = require('./_is_hapi_incompat') const isMongodbIncompat = require('./_is_mongodb_incompat') const isFastifyIncompat = require('./_is_fastify_incompat') @@ -102,7 +102,7 @@ function assertEncodedError (t, error, result, trans, parent) { // ---- tests -const optionFixtures = [ +var optionFixtures = [ ['abortedErrorThreshold', 'ABORTED_ERROR_THRESHOLD', 25], ['active', 'ACTIVE', true], ['apiKey', 'API_KEY'], @@ -157,8 +157,8 @@ const optionFixtures = [ ['verifyServerCert', 'VERIFY_SERVER_CERT', true] ] -const falsyValues = [false, 'false'] -const truthyValues = [true, 'true'] +var falsyValues = [false, 'false'] +var truthyValues = [true, 'true'] optionFixtures.forEach(function (fixture) { if (fixture[1]) { @@ -187,8 +187,8 @@ optionFixtures.forEach(function (fixture) { var existingValue = process.env[envName] test(`should be configurable by environment variable ${envName}`, function (t) { - const agent = new Agent() - let value + var agent = new Agent() + var value switch (type) { case 'bool': @@ -251,9 +251,9 @@ optionFixtures.forEach(function (fixture) { }) test(`should overwrite option property ${fixture[0]} by ${envName}`, function (t) { - const agent = new Agent() - const opts = {} - let value1, value2 + var agent = new Agent() + var opts = {} + var value1, value2 switch (type) { case 'bool': @@ -326,12 +326,12 @@ optionFixtures.forEach(function (fixture) { if (existingValue) { delete process.env[envName] } - const opts = Object.assign({}, agentOptsNoopTransport) + var opts = Object.assign({}, agentOptsNoopTransport) if (fixture[0] in opts) { delete opts[fixture[0]] } - const agent = new Agent().start(opts) + var agent = new Agent().start(opts) switch (type) { case 'array': @@ -353,7 +353,7 @@ optionFixtures.forEach(function (fixture) { falsyValues.forEach(function (val) { test('should be disabled by environment variable ELASTIC_APM_ACTIVE set to: ' + util.inspect(val), function (t) { - const agent = new Agent() + var agent = new Agent() process.env.ELASTIC_APM_ACTIVE = val agent.start(Object.assign({}, agentOptsNoopTransport, { serviceName: 'foo', secretToken: 'baz' })) t.strictEqual(agent._conf.active, false) @@ -365,7 +365,7 @@ falsyValues.forEach(function (val) { truthyValues.forEach(function (val) { test('should be enabled by environment variable ELASTIC_APM_ACTIVE set to: ' + util.inspect(val), function (t) { - const agent = new Agent() + var agent = new Agent() process.env.ELASTIC_APM_ACTIVE = val agent.start(Object.assign({}, agentOptsNoopTransport, { serviceName: 'foo', secretToken: 'baz' })) t.strictEqual(agent._conf.active, true) @@ -376,8 +376,8 @@ truthyValues.forEach(function (val) { }) test('should log invalid booleans', function (t) { - const agent = new Agent() - const logger = new MockLogger() + var agent = new Agent() + var logger = new MockLogger() agent.start(Object.assign( {}, @@ -390,10 +390,10 @@ test('should log invalid booleans', function (t) { } )) - const warning = findObjInArray(logger.calls, 'type', 'warn') + var warning = findObjInArray(logger.calls, 'type', 'warn') t.strictEqual(warning.message, 'unrecognized boolean value "nope" for "active"') - const debug = findObjInArray(logger.calls, 'type', 'debug') + var debug = findObjInArray(logger.calls, 'type', 'debug') t.strictEqual(debug.message, 'Elastic APM agent disabled (`active` is false)') agent.destroy() @@ -401,8 +401,8 @@ test('should log invalid booleans', function (t) { }) test('it should log deprecated booleans', function (t) { - const agent = new Agent() - const logger = new MockLogger() + var agent = new Agent() + var logger = new MockLogger() agent.start(Object.assign( {}, @@ -416,21 +416,21 @@ test('it should log deprecated booleans', function (t) { } )) - const warning = findObjInArray(logger.calls, 'type', 'warn') + var warning = findObjInArray(logger.calls, 'type', 'warn') t.strictEqual(warning.message, 'the `filterHttpHeaders` config option is deprecated') agent.destroy() t.end() }) -const MINUS_ONE_EQUAL_INFINITY = [ +var MINUS_ONE_EQUAL_INFINITY = [ 'transactionMaxSpans' ] MINUS_ONE_EQUAL_INFINITY.forEach(function (key) { test(key + ' should be Infinity if set to -1', function (t) { - const agent = new Agent() - const opts = {} + var agent = new Agent() + var opts = {} opts[key] = -1 agent.start(Object.assign({}, agentOptsNoopTransport, opts)) t.strictEqual(agent._conf[key], Infinity) @@ -439,15 +439,15 @@ MINUS_ONE_EQUAL_INFINITY.forEach(function (key) { }) }) -const bytesValues = [ +var bytesValues = [ 'apiRequestSize', 'errorMessageMaxLength' ] bytesValues.forEach(function (key) { test(key + ' should be converted to a number', function (t) { - const agent = new Agent() - const opts = {} + var agent = new Agent() + var opts = {} opts[key] = '1mb' agent.start(Object.assign({}, agentOptsNoopTransport, opts)) t.strictEqual(agent._conf[key], 1024 * 1024) @@ -479,8 +479,8 @@ DURATION_OPTS.forEach(function (optSpec) { if (!optSpec.allowNegative) { test(key + ' should guard against a negative time', function (t) { - const agent = new Agent() - const logger = new MockLogger() + var agent = new Agent() + var logger = new MockLogger() agent.start(Object.assign( {}, agentOptsNoopTransport, @@ -506,8 +506,8 @@ DURATION_OPTS.forEach(function (optSpec) { } test(key + ' should guard against a bogus non-time', function (t) { - const agent = new Agent() - const logger = new MockLogger() + var agent = new Agent() + var logger = new MockLogger() agent.start(Object.assign( {}, agentOptsNoopTransport, @@ -532,8 +532,8 @@ DURATION_OPTS.forEach(function (optSpec) { }) test(key + ' should convert minutes to seconds', function (t) { - const agent = new Agent() - const opts = {} + var agent = new Agent() + var opts = {} opts[key] = '1m' agent.start(Object.assign({}, agentOptsNoopTransport, opts)) t.strictEqual(agent._conf[key], 60) @@ -542,8 +542,8 @@ DURATION_OPTS.forEach(function (optSpec) { }) test(key + ' should convert milliseconds to seconds', function (t) { - const agent = new Agent() - const opts = {} + var agent = new Agent() + var opts = {} opts[key] = '2000ms' agent.start(Object.assign({}, agentOptsNoopTransport, opts)) t.strictEqual(agent._conf[key], 2) @@ -552,8 +552,8 @@ DURATION_OPTS.forEach(function (optSpec) { }) test(key + ' should parse seconds', function (t) { - const agent = new Agent() - const opts = {} + var agent = new Agent() + var opts = {} opts[key] = '5s' agent.start(Object.assign({}, agentOptsNoopTransport, opts)) t.strictEqual(agent._conf[key], 5) @@ -562,11 +562,11 @@ DURATION_OPTS.forEach(function (optSpec) { }) test(key + ' should support bare numbers', function (t) { - const agent = new Agent() - const opts = {} + var agent = new Agent() + var opts = {} opts[key] = 10 agent.start(Object.assign({}, agentOptsNoopTransport, opts)) - let expectedVal + var expectedVal switch (optSpec.defaultUnit) { case 's': expectedVal = 10 @@ -583,15 +583,15 @@ DURATION_OPTS.forEach(function (optSpec) { }) }) -const keyValuePairValues = [ +var keyValuePairValues = [ 'addPatch', 'globalLabels' ] keyValuePairValues.forEach(function (key) { - const string = 'foo=bar,baz=buz' - const object = { foo: 'bar', baz: 'buz' } - const pairs = [ + var string = 'foo=bar,baz=buz' + var object = { foo: 'bar', baz: 'buz' } + var pairs = [ [ 'foo', 'bar' @@ -603,8 +603,8 @@ keyValuePairValues.forEach(function (key) { ] test(key + ' should support string form', function (t) { - const agent = new Agent() - const opts = {} + var agent = new Agent() + var opts = {} opts[key] = string agent.start(Object.assign({}, agentOptsNoopTransport, opts)) t.deepEqual(agent._conf[key], pairs) @@ -613,8 +613,8 @@ keyValuePairValues.forEach(function (key) { }) test(key + ' should support object form', function (t) { - const agent = new Agent() - const opts = {} + var agent = new Agent() + var opts = {} opts[key] = object agent.start(Object.assign({}, agentOptsNoopTransport, opts)) t.deepEqual(agent._conf[key], pairs) @@ -623,8 +623,8 @@ keyValuePairValues.forEach(function (key) { }) test(key + ' should support pair form', function (t) { - const agent = new Agent() - const opts = {} + var agent = new Agent() + var opts = {} opts[key] = pairs agent.start(Object.assign({}, agentOptsNoopTransport, opts)) t.deepEqual(agent._conf[key], pairs) @@ -633,7 +633,7 @@ keyValuePairValues.forEach(function (key) { }) }) -const noPrefixValues = [ +var noPrefixValues = [ ['kubernetesNodeName', 'KUBERNETES_NODE_NAME'], ['kubernetesNamespace', 'KUBERNETES_NAMESPACE'], ['kubernetesPodName', 'KUBERNETES_POD_NAME'], @@ -643,7 +643,7 @@ const noPrefixValues = [ noPrefixValues.forEach(function (pair) { const [key, envVar] = pair test(`maps ${envVar} to ${key}`, (t) => { - const agent = new Agent() + var agent = new Agent() process.env[envVar] = 'test' agent.start(agentOptsNoopTransport) delete process.env[envVar] @@ -654,8 +654,8 @@ noPrefixValues.forEach(function (pair) { }) test('should overwrite option property active by ELASTIC_APM_ACTIVE', function (t) { - const agent = new Agent() - const opts = { serviceName: 'foo', secretToken: 'baz', active: true } + var agent = new Agent() + var opts = { serviceName: 'foo', secretToken: 'baz', active: true } process.env.ELASTIC_APM_ACTIVE = 'false' agent.start(Object.assign({}, agentOptsNoopTransport, opts)) t.strictEqual(agent._conf.active, false) @@ -665,7 +665,7 @@ test('should overwrite option property active by ELASTIC_APM_ACTIVE', function ( }) test('should default to empty request ignore arrays', function (t) { - const agent = new Agent() + var agent = new Agent() agent.start(agentOptsNoopTransport) t.strictEqual(agent._conf.ignoreUrlStr.length, 0) t.strictEqual(agent._conf.ignoreUrlRegExp.length, 0) @@ -677,7 +677,7 @@ test('should default to empty request ignore arrays', function (t) { }) test('should separate strings and regexes into their own ignore arrays', function (t) { - const agent = new Agent() + var agent = new Agent() agent.start(Object.assign( {}, agentOptsNoopTransport, @@ -703,7 +703,7 @@ test('should separate strings and regexes into their own ignore arrays', functio }) test('should prepare WildcardMatcher array config vars', function (t) { - const agent = new Agent() + var agent = new Agent() agent.start(Object.assign( {}, agentOptsNoopTransport, @@ -747,7 +747,7 @@ test('invalid serviceName => inactive', function (t) { }) test('valid serviceName => active', function (t) { - const agent = new Agent() + var agent = new Agent() agent.start(Object.assign({}, agentOptsNoopTransport, { serviceName: 'fooBAR0123456789_- ' })) t.strictEqual(agent._conf.active, true) agent.destroy() @@ -901,7 +901,7 @@ test('serviceName/serviceVersion zero-conf: no package.json to find', function ( }) }) -const captureBodyTests = [ +var captureBodyTests = [ { value: 'off', errors: '[REDACTED]', transactions: '[REDACTED]' }, { value: 'transactions', errors: '[REDACTED]', transactions: 'test' }, { value: 'errors', errors: 'test', transactions: '[REDACTED]' }, @@ -921,13 +921,13 @@ captureBodyTests.forEach(function (captureBodyTest) { } )) - const req = new IncomingMessage() + var req = new IncomingMessage() req.socket = { remoteAddress: '127.0.0.1' } req.headers['transfer-encoding'] = 'chunked' req.headers['content-length'] = 4 req.body = 'test' - const trans = agent.startTransaction() + var trans = agent.startTransaction() trans.req = req trans.end() @@ -952,15 +952,15 @@ captureBodyTests.forEach(function (captureBodyTest) { }) }) -const usePathAsTransactionNameTests = [ +var usePathAsTransactionNameTests = [ { value: true, url: '/foo/bar?baz=2', transactionName: 'GET /foo/bar' }, { value: false, url: '/foo/bar?baz=2', transactionName: 'GET unknown route' } ] usePathAsTransactionNameTests.forEach(function (usePathAsTransactionNameTest) { test('usePathAsTransactionName => ' + usePathAsTransactionNameTest.value, function (t) { - let sentTrans - const agent = new Agent() + var sentTrans + var agent = new Agent() agent.start(Object.assign( {}, agentOptsNoopTransport, @@ -986,12 +986,12 @@ usePathAsTransactionNameTests.forEach(function (usePathAsTransactionNameTest) { } )) - const req = new IncomingMessage() + var req = new IncomingMessage() req.socket = { remoteAddress: '127.0.0.1' } req.url = usePathAsTransactionNameTest.url req.method = 'GET' - const trans = agent.startTransaction() + var trans = agent.startTransaction() trans.req = req trans.end() @@ -1007,13 +1007,13 @@ usePathAsTransactionNameTests.forEach(function (usePathAsTransactionNameTest) { }) test('disableInstrumentations', function (t) { - const esVersion = safeGetPackageVersion('@elastic/elasticsearch') + var esVersion = safeGetPackageVersion('@elastic/elasticsearch') // require('apollo-server-core') is a hard crash on nodes < 12.0.0 const apolloServerCoreVersion = require('apollo-server-core/package.json').version - const flattenedModules = Instrumentation.modules.reduce((acc, val) => acc.concat(val), []) - const modules = new Set(flattenedModules) + var flattenedModules = Instrumentation.modules.reduce((acc, val) => acc.concat(val), []) + var modules = new Set(flattenedModules) modules.delete('hapi') // Deprecated, we no longer test this instrumentation. modules.delete('jade') // Deprecated, we no longer test this instrumentation. if (isHapiIncompat('@hapi/hapi')) { @@ -1077,18 +1077,18 @@ test('disableInstrumentations', function (t) { modules.delete('mysql2') function testSlice (t, name, selector) { - const selection = selector(modules) - const selectionSet = new Set(typeof selection === 'string' ? selection.split(',') : selection) + var selection = selector(modules) + var selectionSet = new Set(typeof selection === 'string' ? selection.split(',') : selection) t.test(name + ' -> ' + Array.from(selectionSet).join(','), function (t) { - const agent = new Agent() + var agent = new Agent() agent.start(Object.assign( {}, agentOptsNoopTransport, { disableInstrumentations: selection } )) - const found = new Set() + var found = new Set() agent._instrumentation._patchModule = function (exports, name, version, enabled) { if (!enabled) found.add(name) @@ -1166,12 +1166,12 @@ test('custom transport', function (t) { } const myTransport = new MyTransport() - const agent = new Agent() + var agent = new Agent() agent.start(Object.assign({}, agentOpts, { transport: () => myTransport })) - const error = new Error('error') - const trans = agent.startTransaction('transaction') - const span = agent.startSpan('span') + var error = new Error('error') + var trans = agent.startTransaction('transaction') + var span = agent.startSpan('span') agent.captureError(error) span.end() trans.end() @@ -1210,7 +1210,7 @@ test('addPatch', function (t) { }) test('globalLabels should be received by transport', function (t) { - const globalLabels = { + var globalLabels = { foo: 'bar' } @@ -1264,7 +1264,7 @@ test('instrument: false allows manual instrumentation', function (t) { }) test('parsing of ARRAY and KEY_VALUE opts', function (t) { - const cases = [ + var cases = [ { opts: { transactionIgnoreUrls: ['foo', 'bar'] }, expect: { transactionIgnoreUrls: ['foo', 'bar'] } @@ -1320,13 +1320,13 @@ test('parsing of ARRAY and KEY_VALUE opts', function (t) { ] cases.forEach(function testOneCase ({ opts, env, expect }) { - const origEnv = process.env + var origEnv = process.env try { if (env) { process.env = Object.assign({}, origEnv, env) } - const cfg = config.createConfig(opts) - for (const field in expect) { + var cfg = config.createConfig(opts) + for (var field in expect) { t.deepEqual(cfg[field], expect[field], util.format('opts=%j env=%j -> %j', opts, env, expect)) } @@ -1339,7 +1339,7 @@ test('parsing of ARRAY and KEY_VALUE opts', function (t) { }) test('transactionSampleRate precision', function (t) { - const cases = [ + var cases = [ { opts: { transactionSampleRate: 0 }, expect: { transactionSampleRate: 0 } @@ -1379,13 +1379,13 @@ test('transactionSampleRate precision', function (t) { ] cases.forEach(function testOneCase ({ opts, env, expect }) { - const origEnv = process.env + var origEnv = process.env try { if (env) { process.env = Object.assign({}, origEnv, env) } - const cfg = config.createConfig(opts) - for (const field in expect) { + var cfg = config.createConfig(opts) + for (var field in expect) { t.deepEqual(cfg[field], expect[field], util.format('opts=%j env=%j -> %j', opts, env, expect)) } diff --git a/test/connect.test.js b/test/connect.test.js index 772558ab4a..025f62be82 100644 --- a/test/connect.test.js +++ b/test/connect.test.js @@ -60,8 +60,8 @@ tape.test('apm.middleware.connect()', function (t) { const server = http.createServer(app) server.listen(function () { - const port = server.address().port - const baseUrl = 'http://localhost:' + port + var port = server.address().port + var baseUrl = 'http://localhost:' + port t.comment('test server url: ' + baseUrl) http.get(baseUrl + '/error', function () { diff --git a/test/errors.test.js b/test/errors.test.js index 0ca9a53900..05f7c4201a 100644 --- a/test/errors.test.js +++ b/test/errors.test.js @@ -247,7 +247,7 @@ tape.test('#createAPMError({ logMessage: ... })', function (suite) { }) tape.test('#_moduleNameFromFrames()', function (suite) { - const cases = [ + var cases = [ { name: 'unnamespaced package', frames: [ @@ -355,7 +355,7 @@ tape.test('#_moduleNameFromFrames()', function (suite) { }) tape.test('#attributesFromErr()', function (suite) { - const cases = [ + var cases = [ // 'err' is an Error instance, or a function that returns one. { name: 'no attrs', diff --git a/test/fixtures/do-not-trace-self.js b/test/fixtures/do-not-trace-self.js index ea5b7b3be7..9a30ffbd5c 100644 --- a/test/fixtures/do-not-trace-self.js +++ b/test/fixtures/do-not-trace-self.js @@ -7,7 +7,7 @@ // A small APM-using script used to test that the APM agent's own HTTP // communication with APM server is not traced. -const apm = require('../../').start({ // elastic-apm-node +var apm = require('../../').start({ // elastic-apm-node serviceName: 'test-do-not-trace-self', metricsInterval: 0, apmServerVersion: '8.0.0', diff --git a/test/http-request.test.js b/test/http-request.test.js index bfbbfe6b35..410fd1deaa 100644 --- a/test/http-request.test.js +++ b/test/http-request.test.js @@ -6,7 +6,7 @@ 'use strict' -const test = require('tape') +var test = require('tape') const http = require('http') const { httpRequest } = require('../lib/http-request') diff --git a/test/instrumentation/_async-await.js b/test/instrumentation/_async-await.js index 466099bd1a..544adef3d3 100644 --- a/test/instrumentation/_async-await.js +++ b/test/instrumentation/_async-await.js @@ -10,7 +10,7 @@ exports.promise = promise exports.nonPromise = nonPromise async function promise (delay) { - const res = await promise2(delay) + var res = await promise2(delay) return res.toUpperCase() } @@ -23,6 +23,6 @@ async function promise2 (delay) { } async function nonPromise () { - const res = await 'success' + var res = await 'success' return res.toUpperCase() } diff --git a/test/instrumentation/_shared-promise-tests.js b/test/instrumentation/_shared-promise-tests.js index f786ae025a..63afb11e23 100644 --- a/test/instrumentation/_shared-promise-tests.js +++ b/test/instrumentation/_shared-promise-tests.js @@ -10,7 +10,7 @@ module.exports = function (test, Promise, ins) { test('new Promise -> resolve -> then', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() new Promise(function (resolve) { resolve('foo') }).then(function (data) { @@ -20,14 +20,14 @@ module.exports = function (test, Promise, ins) { }) }) - const catchNames = ['catch'] + var catchNames = ['catch'] // caught is a catch alias and an early ECMAScript standard since abandoned if (Promise.prototype.caught) catchNames.push('caught') catchNames.forEach(function (fnName) { test('new Promise -> reject -> ' + fnName, function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() new Promise(function (resolve, reject) { reject(new Error('foo')) }).then(function () { @@ -42,7 +42,7 @@ module.exports = function (test, Promise, ins) { test('new Promise -> reject -> ' + fnName + ' -> then', function (t) { t.plan(8) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() new Promise(function (resolve, reject) { reject(new Error('foo')) })[fnName](function (err) { @@ -60,7 +60,7 @@ module.exports = function (test, Promise, ins) { test('new Promise -> reject -> then (2nd arg)', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() new Promise(function (resolve, reject) { reject(new Error('foo')) }).then(function () { @@ -75,7 +75,7 @@ module.exports = function (test, Promise, ins) { test('Promise.resolve', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() Promise.resolve('foo') .then(function (data) { t.strictEqual(data, 'foo') @@ -90,7 +90,7 @@ module.exports = function (test, Promise, ins) { test('Promise.reject', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() Promise.reject(new Error('foo')) .then(function () { t.fail('should not resolve') @@ -105,10 +105,10 @@ module.exports = function (test, Promise, ins) { test('Promise.all', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() - const p1 = Promise.resolve(3) - const p2 = 1337 - const p3 = new Promise(function (resolve, reject) { + var trans = ins.startTransaction() + var p1 = Promise.resolve(3) + var p2 = 1337 + var p3 = new Promise(function (resolve, reject) { setTimeout(resolve, 10, 'foo') }) @@ -122,11 +122,11 @@ module.exports = function (test, Promise, ins) { test('Promise.race - 2nd resolve', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() - const p1 = new Promise(function (resolve, reject) { + var trans = ins.startTransaction() + var p1 = new Promise(function (resolve, reject) { setTimeout(resolve, 50, 'one') }) - const p2 = new Promise(function (resolve, reject) { + var p2 = new Promise(function (resolve, reject) { setTimeout(resolve, 10, 'two') }) @@ -140,11 +140,11 @@ module.exports = function (test, Promise, ins) { test('Promise.race - 1st resolve', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() - const p1 = new Promise(function (resolve, reject) { + var trans = ins.startTransaction() + var p1 = new Promise(function (resolve, reject) { setTimeout(resolve, 10, 'one') }) - const p2 = new Promise(function (resolve, reject) { + var p2 = new Promise(function (resolve, reject) { setTimeout(reject, 50, 'two') }) @@ -160,11 +160,11 @@ module.exports = function (test, Promise, ins) { test('Promise.race - 2nd reject', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() - const p1 = new Promise(function (resolve, reject) { + var trans = ins.startTransaction() + var p1 = new Promise(function (resolve, reject) { setTimeout(resolve, 50, 'one') }) - const p2 = new Promise(function (resolve, reject) { + var p2 = new Promise(function (resolve, reject) { setTimeout(reject, 10, 'two') }) @@ -180,7 +180,7 @@ module.exports = function (test, Promise, ins) { test('return new Promise', function (t) { t.plan(12) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() new Promise(function (resolve) { resolve('foo') }).then(function (data) { diff --git a/test/instrumentation/async-await.test.js b/test/instrumentation/async-await.test.js index f5fcc42968..2d796a91d3 100644 --- a/test/instrumentation/async-await.test.js +++ b/test/instrumentation/async-await.test.js @@ -6,25 +6,25 @@ 'use strict' -const agent = require('../..').start({ +var agent = require('../..').start({ serviceName: 'test', captureExceptions: false }) -const test = require('tape') +var test = require('tape') -const ins = agent._instrumentation +var ins = agent._instrumentation -const _async = require('./_async-await') +var _async = require('./_async-await') test('await promise', function (t) { t.plan(4) - const t1 = ins.startTransaction() + var t1 = ins.startTransaction() _async.promise(100).then(function (result) { t.strictEqual(result, 'SUCCESS') t.strictEqual(ins.currTransaction() && ins.currTransaction().id, t1.id) }) - const t2 = ins.startTransaction() + var t2 = ins.startTransaction() _async.promise(50).then(function (result) { t.strictEqual(result, 'SUCCESS') t.strictEqual(ins.currTransaction() && ins.currTransaction().id, t2.id) @@ -33,14 +33,14 @@ test('await promise', function (t) { test('await non-promise', function (t) { t.plan(7) - let n = 0 - const t1 = ins.startTransaction() + var n = 0 + var t1 = ins.startTransaction() _async.nonPromise().then(function (result) { t.strictEqual(++n, 2) // this should be the first then-callback to execute t.strictEqual(result, 'SUCCESS') t.strictEqual(ins.currTransaction() && ins.currTransaction().id, t1.id) }) - const t2 = ins.startTransaction() + var t2 = ins.startTransaction() _async.nonPromise().then(function (result) { t.strictEqual(++n, 3) // this should be the second then-callback to execute t.strictEqual(result, 'SUCCESS') diff --git a/test/instrumentation/context.test.js b/test/instrumentation/context.test.js index da81294dbe..bc06677f5d 100644 --- a/test/instrumentation/context.test.js +++ b/test/instrumentation/context.test.js @@ -6,8 +6,8 @@ 'use strict' -const test = require('tape') -const { getHTTPDestination, getDBDestination } = require('../../lib/instrumentation/context') +var test = require('tape') +var { getHTTPDestination, getDBDestination } = require('../../lib/instrumentation/context') test('#getHTTPDestination', function (t) { t.test('username and pass', (t) => { diff --git a/test/instrumentation/core-async-apis.test.js b/test/instrumentation/core-async-apis.test.js index d17d322f08..e59199f4f8 100644 --- a/test/instrumentation/core-async-apis.test.js +++ b/test/instrumentation/core-async-apis.test.js @@ -6,19 +6,19 @@ 'use strict' -const agent = require('../..').start({ +var agent = require('../..').start({ serviceName: 'test-core-async-apis', captureExceptions: false }) -const test = require('tape') +var test = require('tape') -const ins = agent._instrumentation +var ins = agent._instrumentation test('setTimeout', function (t) { t.plan(2) twice(function () { - const trans = agent.startTransaction() + var trans = agent.startTransaction() setTimeout(function () { t.strictEqual(ins.currTransaction() && ins.currTransaction().id, trans.id) trans.end() @@ -29,7 +29,7 @@ test('setTimeout', function (t) { test('setInterval', function (t) { t.plan(2) twice(function () { - const trans = agent.startTransaction() + var trans = agent.startTransaction() var timer = setInterval(function () { clearInterval(timer) t.strictEqual(ins.currTransaction() && ins.currTransaction().id, trans.id) @@ -41,7 +41,7 @@ test('setInterval', function (t) { test('setImmediate', function (t) { t.plan(2) twice(function () { - const trans = agent.startTransaction() + var trans = agent.startTransaction() setImmediate(function () { t.strictEqual(ins.currTransaction() && ins.currTransaction().id, trans.id) trans.end() @@ -52,7 +52,7 @@ test('setImmediate', function (t) { test('process.nextTick', function (t) { t.plan(2) twice(function () { - const trans = agent.startTransaction() + var trans = agent.startTransaction() process.nextTick(function () { t.strictEqual(ins.currTransaction() && ins.currTransaction().id, trans.id) trans.end() @@ -63,10 +63,10 @@ test('process.nextTick', function (t) { test('pre-defined, pre-resolved shared promise', function (t) { t.plan(4) - const p = Promise.resolve('success') + var p = Promise.resolve('success') twice(function () { - const trans = agent.startTransaction() + var trans = agent.startTransaction() p.then(function (result) { t.strictEqual(result, 'success') t.strictEqual(ins.currTransaction() && ins.currTransaction().id, trans.id) @@ -79,8 +79,8 @@ test('pre-defined, pre-resolved non-shared promise', function (t) { t.plan(4) twice(function () { - const p = Promise.resolve('success') - const trans = agent.startTransaction() + var p = Promise.resolve('success') + var trans = agent.startTransaction() p.then(function (result) { t.strictEqual(result, 'success') t.strictEqual(ins.currTransaction() && ins.currTransaction().id, trans.id) @@ -92,12 +92,12 @@ test('pre-defined, pre-resolved non-shared promise', function (t) { test('pre-defined, post-resolved promise', function (t) { t.plan(4) twice(function () { - const p = new Promise(function (resolve) { + var p = new Promise(function (resolve) { setTimeout(function () { resolve('success') }, 20) }) - const trans = agent.startTransaction() + var trans = agent.startTransaction() p.then(function (result) { t.strictEqual(result, 'success') t.strictEqual(ins.currTransaction() && ins.currTransaction().id, trans.id) @@ -109,8 +109,8 @@ test('pre-defined, post-resolved promise', function (t) { test('post-defined, post-resolved promise', function (t) { t.plan(4) twice(function () { - const trans = agent.startTransaction() - const p = new Promise(function (resolve) { + var trans = agent.startTransaction() + var p = new Promise(function (resolve) { setTimeout(function () { resolve('success') }, 20) diff --git a/test/instrumentation/fs.test.js b/test/instrumentation/fs.test.js index 97d25bafdb..f808254666 100644 --- a/test/instrumentation/fs.test.js +++ b/test/instrumentation/fs.test.js @@ -25,8 +25,8 @@ if (typeof fs.realpath.native === 'function') { // Before https://github.com/elastic/apm-agent-nodejs/issues/2401 this test // would crash with asyncHooks=false tape.test('fs.realpath.native', function (t) { - const trans = apm.startTransaction('t0') - const span = apm.startSpan('s1') + var trans = apm.startTransaction('t0') + var span = apm.startSpan('s1') fs.realpath.native(__filename, function (err, resolvedPath) { t.error(err, 'no error from fs.realpath.native') t.equal(apm.currentSpan, span, 'apm.currentSpan is as expected') diff --git a/test/instrumentation/index.test.js b/test/instrumentation/index.test.js index c4d7700f0c..10e18864d7 100644 --- a/test/instrumentation/index.test.js +++ b/test/instrumentation/index.test.js @@ -6,7 +6,7 @@ 'use strict' -const agent = require('../..').start({ +var agent = require('../..').start({ serviceName: 'test-instrumentation', breakdownMetrics: false, captureExceptions: false, @@ -16,15 +16,15 @@ const agent = require('../..').start({ spanStackTraceMinDuration: 0 // Always have span stacktraces. }) -const EventEmitter = require('events') -const http = require('http') +var EventEmitter = require('events') +var http = require('http') -const test = require('tape') +var test = require('tape') -const mockClient = require('../_mock_http_client') -const findObjInArray = require('../_utils').findObjInArray +var mockClient = require('../_mock_http_client') +var findObjInArray = require('../_utils').findObjInArray -const origCaptureError = agent.captureError +var origCaptureError = agent.captureError test('basic', function (t) { resetAgent(6, function (data) { @@ -65,16 +65,16 @@ test('basic', function (t) { t.end() }) - const ins = agent._instrumentation + var ins = agent._instrumentation generateTransaction(0, function () { generateTransaction(1) }) function generateTransaction (id, cb) { - const trans = ins.startTransaction('foo' + id, 'bar' + id) + var trans = ins.startTransaction('foo' + id, 'bar' + id) trans.result = 'baz' + id - let span = ins.startSpan('t' + id + '0', 'type') + var span = ins.startSpan('t' + id + '0', 'type') process.nextTick(function () { span.end() @@ -101,11 +101,11 @@ test('same tick', function (t) { } t.end() }) - const ins = agent._instrumentation + var ins = agent._instrumentation - const trans = ins.startTransaction('foo') - const t0 = ins.startSpan('t0') - const t1 = ins.startSpan('t1') + var trans = ins.startTransaction('foo') + var t0 = ins.startSpan('t0') + var t1 = ins.startSpan('t1') t1.end() t0.end() trans.end() @@ -124,13 +124,13 @@ test('serial - no parents', function (t) { } t.end() }) - const ins = agent._instrumentation + var ins = agent._instrumentation - const trans = ins.startTransaction('foo') - const t0 = ins.startSpan('t0') + var trans = ins.startTransaction('foo') + var t0 = ins.startSpan('t0') process.nextTick(function () { t0.end() - const t1 = ins.startSpan('t1') + var t1 = ins.startSpan('t1') process.nextTick(function () { t1.end() trans.end() @@ -151,12 +151,12 @@ test('serial - with parents', function (t) { } t.end() }) - const ins = agent._instrumentation + var ins = agent._instrumentation - const trans = ins.startTransaction('foo') - const t0 = ins.startSpan('t0') + var trans = ins.startTransaction('foo') + var t0 = ins.startSpan('t0') process.nextTick(function () { - const t1 = ins.startSpan('t1') + var t1 = ins.startSpan('t1') process.nextTick(function () { t1.end() t0.end() @@ -178,11 +178,11 @@ test('stack branching - no parents', function (t) { } t.end() }) - const ins = agent._instrumentation + var ins = agent._instrumentation - const trans = ins.startTransaction('foo') - const t0 = ins.startSpan('t0') // 1 - const t1 = ins.startSpan('t1') // 2 + var trans = ins.startTransaction('foo') + var t0 = ins.startSpan('t0') // 1 + var t1 = ins.startSpan('t1') // 2 setTimeout(function () { t0.end() // 3 }, 25) @@ -241,15 +241,15 @@ test('captureError should handle opts.captureAttributes', function (t) { agent.captureError = origCaptureError - const ex0 = new Error('ex0') + var ex0 = new Error('ex0') ex0.theProperty = 'this is the property' agent.captureError(ex0) - const ex1 = new Error('ex1') + var ex1 = new Error('ex1') ex1.theProperty = 'this is the property' agent.captureError(ex1, { captureAttributes: true }) - const ex2 = new Error('ex2') + var ex2 = new Error('ex2') ex2.theProperty = 'this is the property' agent.captureError(ex2, { captureAttributes: false }) }) @@ -281,7 +281,7 @@ test('unsampled request transactions should have the correct result', function ( }) server.listen(function () { - const port = server.address().port + var port = server.address().port http.get('http://localhost:' + port, function (res) { res.resume() }) @@ -294,12 +294,12 @@ test('bind', function (t) { t.strictEqual(data.transactions.length, 1) t.end() }) - const ins = agent._instrumentation + var ins = agent._instrumentation - const trans = ins.startTransaction('foo') + var trans = ins.startTransaction('foo') function fn () { - const t0 = ins.startSpan('t0') + var t0 = ins.startSpan('t0') t.equal(t0, null, 'should not get a span, because there is no current transaction') if (t0) t0.end() trans.end() @@ -317,12 +317,12 @@ test('bind', function (t) { t.strictEqual(data.spans[0].name, 't0') t.end() }) - const ins = agent._instrumentation + var ins = agent._instrumentation - const trans = ins.startTransaction('foo') + var trans = ins.startTransaction('foo') - const fn = ins.bindFunction(function () { - const t0 = ins.startSpan('t0') + var fn = ins.bindFunction(function () { + var t0 = ins.startSpan('t0') t.ok(t0, 'should get a span, because run context with transaction was bound to fn') if (t0) t0.end() trans.end() @@ -338,11 +338,11 @@ test('bind', function (t) { t.strictEqual(data.transactions.length, 1) t.end() }) - const ins = agent._instrumentation - const trans = ins.startTransaction('foo') - let listeners + var ins = agent._instrumentation + var trans = ins.startTransaction('foo') + var listeners - const emitter = new EventEmitter() + var emitter = new EventEmitter() ins.bindEmitter(emitter) function myHandler () { } @@ -369,7 +369,7 @@ test('bind', function (t) { trans.end() }) - const methods = [ + var methods = [ 'on', 'once', 'addListener', @@ -383,15 +383,15 @@ test('bind', function (t) { t.strictEqual(data.transactions.length, 1) t.end() }) - const ins = agent._instrumentation + var ins = agent._instrumentation - const trans = ins.startTransaction('foo') + var trans = ins.startTransaction('foo') - const emitter = new EventEmitter() + var emitter = new EventEmitter() // Explicitly *not* using `bindEmitter` here. emitter[method]('foo', function () { - const s1 = ins.startSpan('s1') + var s1 = ins.startSpan('s1') t.equal(s1, null, 'should *not* get span s1') if (s1) s1.end() trans.end() @@ -413,14 +413,14 @@ test('bind', function (t) { t.end() }) - const ins = agent._instrumentation - const trans = ins.startTransaction('foo') + var ins = agent._instrumentation + var trans = ins.startTransaction('foo') - const emitter = new EventEmitter() + var emitter = new EventEmitter() ins.bindEmitter(emitter) emitter[method]('foo', function () { - const s1 = ins.startSpan('s1') + var s1 = ins.startSpan('s1') if (s1) s1.end() trans.end() }) @@ -471,10 +471,10 @@ test('nested spans', function (t) { t.end() }) - const ins = agent._instrumentation + var ins = agent._instrumentation - const trans = ins.startTransaction('foo') - let count = 0 + var trans = ins.startTransaction('foo') + var count = 0 function done () { s1.end() if (++count === 2) { @@ -482,10 +482,10 @@ test('nested spans', function (t) { } } - const s0 = ins.startSpan('s0') + var s0 = ins.startSpan('s0') process.nextTick(function () { process.nextTick(function () { - const s01 = ins.startSpan('s01') + var s01 = ins.startSpan('s01') process.nextTick(function () { s01.end() done() @@ -496,7 +496,7 @@ test('nested spans', function (t) { var s1 = ins.startSpan('s1') process.nextTick(function () { - const s11 = ins.startSpan('s11') + var s11 = ins.startSpan('s11') process.nextTick(function () { s11.end() done() @@ -506,7 +506,7 @@ test('nested spans', function (t) { // Will adopt the t1 span as its parent, // because no new span has been created. process.nextTick(function () { - const s12 = ins.startSpan('s12') + var s12 = ins.startSpan('s12') process.nextTick(function () { s12.end() done() @@ -541,14 +541,14 @@ test('nested transactions', function (t) { t.end() }) - const ins = agent._instrumentation + var ins = agent._instrumentation - const t0 = ins.startTransaction('t0') - const s0 = ins.startSpan('s0') - const t1 = ins.startTransaction('t1', null, { + var t0 = ins.startTransaction('t0') + var s0 = ins.startSpan('s0') + var t1 = ins.startTransaction('t1', null, { childOf: t0._context.toString() }) - const s1 = ins.startSpan('s1') + var s1 = ins.startSpan('s1') s1.end() t1.end() s0.end() diff --git a/test/instrumentation/modules/@apollo/server.test.js b/test/instrumentation/modules/@apollo/server.test.js index 00c36e404e..f1f3f11b3a 100644 --- a/test/instrumentation/modules/@apollo/server.test.js +++ b/test/instrumentation/modules/@apollo/server.test.js @@ -205,8 +205,8 @@ function done (t, query) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 1) - const trans = data.transactions[0] - const span = data.spans[0] + var trans = data.transactions[0] + var span = data.spans[0] t.strictEqual(trans.name, query + ' (/)') t.strictEqual(trans.type, 'graphql') @@ -215,7 +215,7 @@ function done (t, query) { t.strictEqual(span.subtype, 'graphql') t.strictEqual(span.action, 'execute') - const offset = span.timestamp - trans.timestamp + var offset = span.timestamp - trans.timestamp t.ok(offset + span.duration * 1000 < trans.duration * 1000) t.end() diff --git a/test/instrumentation/modules/apollo-server-express.test.js b/test/instrumentation/modules/apollo-server-express.test.js index da12805315..1a6da041ea 100644 --- a/test/instrumentation/modules/apollo-server-express.test.js +++ b/test/instrumentation/modules/apollo-server-express.test.js @@ -11,7 +11,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -const agent = require('../../..').start({ +var agent = require('../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -20,11 +20,11 @@ const agent = require('../../..').start({ spanStackTraceMinDuration: 0 // Always have span stacktraces. }) -const test = require('tape') +var test = require('tape') -const http = require('http') -const express = require('express') -const querystring = require('querystring') +var http = require('http') +var express = require('express') +var querystring = require('querystring') const semver = require('semver') // require('apollo-server-express') is a hard crash for nodes < 12.0.0 const apolloServerExpressVersion = require('apollo-server-express/package.json').version @@ -33,20 +33,20 @@ if (semver.gte(apolloServerExpressVersion, '3.0.0') && semver.lt(process.version process.exit() } -const ApolloServer = require('apollo-server-express').ApolloServer -const gql = require('apollo-server-express').gql +var ApolloServer = require('apollo-server-express').ApolloServer +var gql = require('apollo-server-express').gql -const mockClient = require('../../_mock_http_client') +var mockClient = require('../../_mock_http_client') test('POST /graphql', function (t) { resetAgent(done(t, 'hello')) - const typeDefs = gql` + var typeDefs = gql` type Query { hello: String } ` - const resolvers = { + var resolvers = { Query: { hello () { t.ok(agent._instrumentation.currTransaction(), 'have active transaction') @@ -54,26 +54,26 @@ test('POST /graphql', function (t) { } } } - const query = '{"query":"{ hello }"}' + var query = '{"query":"{ hello }"}' - const app = express() - const apollo = new ApolloServer({ typeDefs, resolvers, uploads: false }) + var app = express() + var apollo = new ApolloServer({ typeDefs, resolvers, uploads: false }) apollo.start().then(function () { apollo.applyMiddleware({ app }) var server = app.listen(function () { - const port = server.address().port - const opts = { + var port = server.address().port + var opts = { method: 'POST', port: port, path: '/graphql', headers: { 'Content-Type': 'application/json' } } - const req = http.request(opts, function (res) { - const chunks = [] + var req = http.request(opts, function (res) { + var chunks = [] res.on('data', chunks.push.bind(chunks)) res.on('end', function () { server.close() - const result = Buffer.concat(chunks).toString() + var result = Buffer.concat(chunks).toString() t.strictEqual(result, '{"data":{"hello":"Hello world!"}}\n', 'client got the expected response body') agent.flush() @@ -87,12 +87,12 @@ test('POST /graphql', function (t) { test('GET /graphql', function (t) { resetAgent(done(t, 'hello')) - const typeDefs = gql` + var typeDefs = gql` type Query { hello: String } ` - const resolvers = { + var resolvers = { Query: { hello () { t.ok(agent._instrumentation.currTransaction(), 'have active transaction') @@ -100,25 +100,25 @@ test('GET /graphql', function (t) { } } } - const query = querystring.stringify({ query: '{ hello }' }) + var query = querystring.stringify({ query: '{ hello }' }) - const app = express() - const apollo = new ApolloServer({ typeDefs, resolvers, uploads: false }) + var app = express() + var apollo = new ApolloServer({ typeDefs, resolvers, uploads: false }) apollo.start().then(function () { apollo.applyMiddleware({ app }) var server = app.listen(function () { - const port = server.address().port - const opts = { + var port = server.address().port + var opts = { method: 'GET', port: port, path: '/graphql?' + query } - const req = http.request(opts, function (res) { - const chunks = [] + var req = http.request(opts, function (res) { + var chunks = [] res.on('data', chunks.push.bind(chunks)) res.on('end', function () { server.close() - const result = Buffer.concat(chunks).toString() + var result = Buffer.concat(chunks).toString() t.strictEqual(result, '{"data":{"hello":"Hello world!"}}\n', 'client got the expected response body') agent.flush() @@ -132,12 +132,12 @@ test('GET /graphql', function (t) { test('POST /graphql - named query', function (t) { resetAgent(done(t, 'HelloQuery hello')) - const typeDefs = gql` + var typeDefs = gql` type Query { hello: String } ` - const resolvers = { + var resolvers = { Query: { hello () { t.ok(agent._instrumentation.currTransaction(), 'have active transaction') @@ -145,26 +145,26 @@ test('POST /graphql - named query', function (t) { } } } - const query = '{"query":"query HelloQuery { hello }"}' + var query = '{"query":"query HelloQuery { hello }"}' - const app = express() - const apollo = new ApolloServer({ typeDefs, resolvers, uploads: false }) + var app = express() + var apollo = new ApolloServer({ typeDefs, resolvers, uploads: false }) apollo.start().then(function () { apollo.applyMiddleware({ app }) var server = app.listen(function () { - const port = server.address().port - const opts = { + var port = server.address().port + var opts = { method: 'POST', port: port, path: '/graphql', headers: { 'Content-Type': 'application/json' } } - const req = http.request(opts, function (res) { - const chunks = [] + var req = http.request(opts, function (res) { + var chunks = [] res.on('data', chunks.push.bind(chunks)) res.on('end', function () { server.close() - const result = Buffer.concat(chunks).toString() + var result = Buffer.concat(chunks).toString() t.strictEqual(result, '{"data":{"hello":"Hello world!"}}\n') agent.flush() }) @@ -177,13 +177,13 @@ test('POST /graphql - named query', function (t) { test('POST /graphql - sort multiple queries', function (t) { resetAgent(done(t, 'hello, life')) - const typeDefs = gql` + var typeDefs = gql` type Query { hello: String life: Int } ` - const resolvers = { + var resolvers = { Query: { hello () { t.ok(agent._instrumentation.currTransaction(), 'have active transaction') @@ -195,26 +195,26 @@ test('POST /graphql - sort multiple queries', function (t) { } } } - const query = '{"query":"{ life, hello }"}' + var query = '{"query":"{ life, hello }"}' - const app = express() - const apollo = new ApolloServer({ typeDefs, resolvers, uploads: false }) + var app = express() + var apollo = new ApolloServer({ typeDefs, resolvers, uploads: false }) apollo.start().then(function () { apollo.applyMiddleware({ app }) var server = app.listen(function () { - const port = server.address().port - const opts = { + var port = server.address().port + var opts = { method: 'POST', port: port, path: '/graphql', headers: { 'Content-Type': 'application/json' } } - const req = http.request(opts, function (res) { - const chunks = [] + var req = http.request(opts, function (res) { + var chunks = [] res.on('data', chunks.push.bind(chunks)) res.on('end', function () { server.close() - const result = Buffer.concat(chunks).toString() + var result = Buffer.concat(chunks).toString() t.strictEqual(result, '{"data":{"life":42,"hello":"Hello world!"}}\n') agent.flush() }) @@ -227,7 +227,7 @@ test('POST /graphql - sort multiple queries', function (t) { test('POST /graphql - sub-query', function (t) { resetAgent(done(t, 'books')) - const books = [ + var books = [ { title: 'Harry Potter and the Chamber of Secrets', author: 'J.K. Rowling', @@ -239,7 +239,7 @@ test('POST /graphql - sub-query', function (t) { publisher: { name: 'ACME' } } ] - const typeDefs = gql` + var typeDefs = gql` type Publisher { name: String } @@ -252,7 +252,7 @@ test('POST /graphql - sub-query', function (t) { books: [Book] } ` - const resolvers = { + var resolvers = { Query: { books () { t.ok(agent._instrumentation.currTransaction(), 'have active transaction') @@ -260,26 +260,26 @@ test('POST /graphql - sub-query', function (t) { } } } - const query = '{"query":"{ books { title author, publisher { name } } }"}' + var query = '{"query":"{ books { title author, publisher { name } } }"}' - const app = express() - const apollo = new ApolloServer({ typeDefs, resolvers, uploads: false }) + var app = express() + var apollo = new ApolloServer({ typeDefs, resolvers, uploads: false }) apollo.start().then(function () { apollo.applyMiddleware({ app }) var server = app.listen(function () { - const port = server.address().port - const opts = { + var port = server.address().port + var opts = { method: 'POST', port: port, path: '/graphql', headers: { 'Content-Type': 'application/json' } } - const req = http.request(opts, function (res) { - const chunks = [] + var req = http.request(opts, function (res) { + var chunks = [] res.on('data', chunks.push.bind(chunks)) res.on('end', function () { server.close() - const result = Buffer.concat(chunks).toString() + var result = Buffer.concat(chunks).toString() t.strictEqual(result, JSON.stringify({ data: { books } }) + '\n') agent.flush() }) @@ -294,8 +294,8 @@ function done (t, query) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 1) - const trans = data.transactions[0] - const span = data.spans[0] + var trans = data.transactions[0] + var span = data.spans[0] t.strictEqual(trans.name, query + ' (/graphql)') t.strictEqual(trans.type, 'graphql') @@ -304,7 +304,7 @@ function done (t, query) { t.strictEqual(span.subtype, 'graphql') t.strictEqual(span.action, 'execute') - const offset = span.timestamp - trans.timestamp + var offset = span.timestamp - trans.timestamp t.ok(offset + span.duration * 1000 < trans.duration * 1000) t.end() diff --git a/test/instrumentation/modules/aws-sdk/dynamodb.test.js b/test/instrumentation/modules/aws-sdk/dynamodb.test.js index 7875a670cf..e18905e26e 100644 --- a/test/instrumentation/modules/aws-sdk/dynamodb.test.js +++ b/test/instrumentation/modules/aws-sdk/dynamodb.test.js @@ -182,7 +182,7 @@ tape.test('AWS DynamoDB: End to End Test', function (test) { endpoint: `http://localhost:${port}` }) agent.startTransaction('myTransaction') - const ddb = new AWS.DynamoDB({ apiVersion: '2012-08-10' }) + var ddb = new AWS.DynamoDB({ apiVersion: '2012-08-10' }) var params = { TableName: 'fixture-table', KeyConditionExpression: 'id = :foo', @@ -230,7 +230,7 @@ tape.test('AWS DynamoDB: End to End Test', function (test) { endpoint: `http://localhost:${port}` }) agent.startTransaction('myTransaction') - const ddb = new AWS.DynamoDB({ apiVersion: '2012-08-10' }) + var ddb = new AWS.DynamoDB({ apiVersion: '2012-08-10' }) ddb.listTables(function (err, data) { t.ok(agent.currentSpan === null, 'no currentSpan in ddb.listTables callback') t.error(err) @@ -260,8 +260,8 @@ tape.test('AWS DynamoDB: End to End Test', function (test) { endpoint: `http://localhost:${port}` }) agent.startTransaction('myTransaction') - const ddb = new AWS.DynamoDB({ apiVersion: '2012-08-10' }) - const params = { + var ddb = new AWS.DynamoDB({ apiVersion: '2012-08-10' }) + var params = { TableName: 'fixture-table', KeyConditionExpression: 'id = :foo', ExpressionAttributeValues: { @@ -292,8 +292,8 @@ tape.test('AWS DynamoDB: End to End Test', function (test) { AWS.config.update({ endpoint: `http://localhost:${port}` }) - const ddb = new AWS.DynamoDB({ apiVersion: '2012-08-10' }) - const params = { + var ddb = new AWS.DynamoDB({ apiVersion: '2012-08-10' }) + var params = { TableName: 'fixture-table', KeyConditionExpression: 'id = :foo', ExpressionAttributeValues: { diff --git a/test/instrumentation/modules/aws-sdk/fixtures/use-s3.js b/test/instrumentation/modules/aws-sdk/fixtures/use-s3.js index d0cfe0ab37..3fdf8e5a5e 100644 --- a/test/instrumentation/modules/aws-sdk/fixtures/use-s3.js +++ b/test/instrumentation/modules/aws-sdk/fixtures/use-s3.js @@ -120,7 +120,7 @@ function useS3 (s3Client, bucketName, cb) { // https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#putObject-property function createObj (_, next) { - const md5 = crypto.createHash('md5').update(content).digest('base64') + var md5 = crypto.createHash('md5').update(content).digest('base64') s3Client.putObject({ Bucket: bucketName, Key: key, diff --git a/test/instrumentation/modules/bluebird/_coroutine.js b/test/instrumentation/modules/bluebird/_coroutine.js index c28cc88390..4d1717e618 100644 --- a/test/instrumentation/modules/bluebird/_coroutine.js +++ b/test/instrumentation/modules/bluebird/_coroutine.js @@ -6,11 +6,11 @@ 'use strict' -const semver = require('semver') -const BLUEBIRD_VERSION = require('bluebird/package').version +var semver = require('semver') +var BLUEBIRD_VERSION = require('bluebird/package').version module.exports = function (test, Promise, ins) { - const bluebird = Promise + var bluebird = Promise test('Promise.coroutine', function (t) { t.plan(10) @@ -39,8 +39,8 @@ module.exports = function (test, Promise, ins) { }) twice(function () { - const trans = ins.startTransaction() - const a = new PingPong(trans) + var trans = ins.startTransaction() + var a = new PingPong(trans) a.ping(0) }) }) @@ -49,7 +49,7 @@ module.exports = function (test, Promise, ins) { test('Promise.coroutine.addYieldHandler', function (t) { t.plan(10) - const Promise = bluebird.getNewLibraryCopy() + var Promise = bluebird.getNewLibraryCopy() Promise.coroutine.addYieldHandler(function (value) { return Promise.delay(value) @@ -79,8 +79,8 @@ module.exports = function (test, Promise, ins) { }) twice(function () { - const trans = ins.startTransaction() - const a = new PingPong(trans) + var trans = ins.startTransaction() + var a = new PingPong(trans) a.ping(0) }) }) @@ -91,7 +91,7 @@ module.exports = function (test, Promise, ins) { test('Promise.spawn', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() Promise.spawn(function * () { return yield Promise.resolve('foo') diff --git a/test/instrumentation/modules/bluebird/bluebird.test.js b/test/instrumentation/modules/bluebird/bluebird.test.js index b4130e937e..2b315a2430 100644 --- a/test/instrumentation/modules/bluebird/bluebird.test.js +++ b/test/instrumentation/modules/bluebird/bluebird.test.js @@ -15,7 +15,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { // expected. require('../../../_promise_rejection').remove() -const agent = require('../../../..').start({ +var agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -23,12 +23,12 @@ const agent = require('../../../..').start({ centralConfig: false }) -const BLUEBIRD_VERSION = require('bluebird/package').version -const Promise = require('bluebird') -const semver = require('semver') -const test = require('tape') +var BLUEBIRD_VERSION = require('bluebird/package').version +var Promise = require('bluebird') +var semver = require('semver') +var test = require('tape') -const ins = agent._instrumentation +var ins = agent._instrumentation require('../../_shared-promise-tests')(test, Promise, ins) require('./_coroutine')(test, Promise, ins) @@ -36,7 +36,7 @@ require('./_coroutine')(test, Promise, ins) test('Promise.prototype.spread - all formal', function (t) { t.plan(6) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() Promise.all(['foo', 'bar']).spread(function (a, b) { t.strictEqual(a, 'foo') t.strictEqual(b, 'bar') @@ -48,8 +48,8 @@ test('Promise.prototype.spread - all formal', function (t) { test('Promise.prototype.spread - all promises', function (t) { t.plan(6) twice(function () { - const trans = ins.startTransaction() - const arr = [resolved('foo'), resolved('bar')] + var trans = ins.startTransaction() + var arr = [resolved('foo'), resolved('bar')] Promise.all(arr).spread(function (a, b) { t.strictEqual(a, 'foo') t.strictEqual(b, 'bar') @@ -61,7 +61,7 @@ test('Promise.prototype.spread - all promises', function (t) { test('Promise.prototype.spread - then formal', function (t) { t.plan(6) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() Promise.delay(1).then(function () { return ['foo', 'bar'] }).spread(function (a, b) { @@ -75,7 +75,7 @@ test('Promise.prototype.spread - then formal', function (t) { test('Promise.prototype.spread - then promises', function (t) { t.plan(6) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() Promise.delay(1).then(function () { return [resolved('foo'), resolved('bar')] }).spread(function (a, b) { @@ -86,12 +86,12 @@ test('Promise.prototype.spread - then promises', function (t) { }) }) -const CATCH_NAMES = ['catch', 'caught'] +var CATCH_NAMES = ['catch', 'caught'] CATCH_NAMES.forEach(function (fnName) { test('new Promise -> reject -> ' + fnName + ' (filtered, first type)', function (t) { t.plan(6) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() rejected(new TypeError('foo')) .then(function () { t.fail('should not resolve') @@ -110,7 +110,7 @@ CATCH_NAMES.forEach(function (fnName) { test('new Promise -> reject -> ' + fnName + ' (filtered, second type)', function (t) { t.plan(6) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() rejected(new ReferenceError('foo')) .then(function () { t.fail('should not resolve') @@ -130,7 +130,7 @@ CATCH_NAMES.forEach(function (fnName) { t.plan(6) twice(function () { setImmediate(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() rejected(new SyntaxError('foo')) .then(function () { t.fail('should not resolve') @@ -150,7 +150,7 @@ CATCH_NAMES.forEach(function (fnName) { test('new Promise -> reject -> ' + fnName + ' (filtered, multi, first type)', function (t) { t.plan(6) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() rejected(new SyntaxError('foo')) .then(function () { t.fail('should not resolve') @@ -169,7 +169,7 @@ CATCH_NAMES.forEach(function (fnName) { test('new Promise -> reject -> ' + fnName + ' (filtered, multi, second type)', function (t) { t.plan(6) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() rejected(new RangeError('foo')) .then(function () { t.fail('should not resolve') @@ -188,7 +188,7 @@ CATCH_NAMES.forEach(function (fnName) { test('new Promise -> reject -> ' + fnName + ' (filtered, multi, catch-all)', function (t) { t.plan(6) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() rejected(new URIError('foo')) .then(function () { t.fail('should not resolve') @@ -207,7 +207,7 @@ CATCH_NAMES.forEach(function (fnName) { test('new Promise -> reject -> ' + fnName + ' (filtered, predicate)', function (t) { t.plan(18) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() rejected(new URIError('foo')) .then(function () { @@ -242,8 +242,8 @@ CATCH_NAMES.forEach(function (fnName) { test('new Promise -> reject -> ' + fnName + ' (filtered, predicate shorthand)', function (t) { t.plan(6) twice(function () { - const trans = ins.startTransaction() - const err = new URIError('foo') + var trans = ins.startTransaction() + var err = new URIError('foo') err.code = 42 rejected(err) .then(function () { @@ -265,7 +265,7 @@ CATCH_NAMES.forEach(function (fnName) { test('new Promise -> reject -> error', function (t) { t.plan(6) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() rejected(new Promise.OperationalError('foo')) .then(function () { t.fail('should not resolve') @@ -279,12 +279,12 @@ test('new Promise -> reject -> error', function (t) { }) }) -const FINALLY_NAMES = ['finally', 'lastly'] +var FINALLY_NAMES = ['finally', 'lastly'] FINALLY_NAMES.forEach(function (fnName) { test('new Promise -> reject -> ' + fnName, function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() rejected('foo') .then(function () { t.fail('should not resolve') @@ -298,7 +298,7 @@ FINALLY_NAMES.forEach(function (fnName) { test('new Promise -> reject -> catch -> ' + fnName, function (t) { t.plan(6) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() rejected('foo') .then(function () { t.fail('should not resolve') @@ -314,7 +314,7 @@ FINALLY_NAMES.forEach(function (fnName) { test('new Promise -> reject -> then -> catch -> ' + fnName + ' -> new Promise -> then', function (t) { t.plan(8) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() rejected('foo') .then(function () { t.fail('should not resolve') @@ -333,8 +333,8 @@ FINALLY_NAMES.forEach(function (fnName) { test('new Promise -> resolve -> then -> ' + fnName + ' -> new Promise -> then', function (t) { t.plan(10) twice(function () { - const trans = ins.startTransaction() - let finallyCalled = false + var trans = ins.startTransaction() + var finallyCalled = false resolved('foo') .then(function (result) { t.strictEqual(result, 'foo') @@ -355,8 +355,8 @@ FINALLY_NAMES.forEach(function (fnName) { test('new Promise -> resolve -> ' + fnName + ' -> new Promise -> then', function (t) { t.plan(8) twice(function () { - const trans = ins.startTransaction() - let finallyCalled = false + var trans = ins.startTransaction() + var finallyCalled = false resolved('foo') .catch(function () { t.fail('should not reject') @@ -379,9 +379,9 @@ test('new Promise -> bind -> then', function (t) { function Obj () {} twice(function () { - const trans = ins.startTransaction() - const obj = new Obj() - const n = obj.n = Math.random() + var trans = ins.startTransaction() + var obj = new Obj() + var n = obj.n = Math.random() resolved('foo') .bind(obj) @@ -400,11 +400,11 @@ if (semver.satisfies(BLUEBIRD_VERSION, '>=2.9.0')) { function Obj () {} twice(function () { - const trans = ins.startTransaction() - const obj = new Obj() - const n = obj.n = Math.random() + var trans = ins.startTransaction() + var obj = new Obj() + var n = obj.n = Math.random() - let p = resolved('foo') + var p = resolved('foo') p = Promise.bind(obj, p) @@ -420,9 +420,9 @@ if (semver.satisfies(BLUEBIRD_VERSION, '>=2.9.0')) { test('Promise.bind - promise, without value', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() - let p = resolved('foo') + var p = resolved('foo') p = Promise.bind(p) @@ -439,11 +439,11 @@ test('Promise.bind - non-promise, without value', function (t) { function Obj () {} twice(function () { - const trans = ins.startTransaction() - const obj = new Obj() - const n = obj.n = Math.random() + var trans = ins.startTransaction() + var obj = new Obj() + var n = obj.n = Math.random() - const p = Promise.bind(obj) + var p = Promise.bind(obj) p.then(function (result) { t.strictEqual(this.n, n) @@ -456,11 +456,11 @@ test('Promise.bind - non-promise, without value', function (t) { test('Promise.join', function (t) { t.plan(8) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() - const p1 = resolved('p1') - const p2 = resolved('p2') - const p3 = resolved('p3') + var p1 = resolved('p1') + var p2 = resolved('p2') + var p3 = resolved('p3') Promise.join(p1, p2, p3, function (a, b, c) { t.strictEqual(a, 'p1') @@ -471,12 +471,12 @@ test('Promise.join', function (t) { }) }) -const TRY_NAMES = ['try', 'attempt'] +var TRY_NAMES = ['try', 'attempt'] TRY_NAMES.forEach(function (fnName) { test('Promise.' + fnName + ' -> return value', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() Promise[fnName](function () { return 'foo' }).then(function (result) { @@ -491,7 +491,7 @@ TRY_NAMES.forEach(function (fnName) { test('Promise.' + fnName + ' -> throw', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() Promise[fnName](function () { throw new Error('foo') }).then(function () { @@ -506,7 +506,7 @@ TRY_NAMES.forEach(function (fnName) { test('Promise.' + fnName + ' with args value', function (t) { t.plan(6) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() Promise[fnName](function (value) { t.strictEqual(value, 'bar') return 'foo' @@ -522,7 +522,7 @@ TRY_NAMES.forEach(function (fnName) { test('Promise.' + fnName + ' with args array', function (t) { t.plan(6) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() Promise[fnName](function () { t.deepEqual([].slice.call(arguments), [1, 2, 3]) return 'foo' @@ -538,8 +538,8 @@ TRY_NAMES.forEach(function (fnName) { test('Promise.' + fnName + ' with context', function (t) { t.plan(8) twice(function () { - const trans = ins.startTransaction() - const obj = {} + var trans = ins.startTransaction() + var obj = {} Promise[fnName](function (value) { t.strictEqual(value, undefined) t.strictEqual(this, obj) @@ -557,7 +557,7 @@ TRY_NAMES.forEach(function (fnName) { test('Promise.method -> return value', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() Promise.method(function () { return 'foo' })().then(function (result) { @@ -572,7 +572,7 @@ test('Promise.method -> return value', function (t) { test('Promise.method -> throw', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() Promise.method(function () { throw new Error('foo') })().then(function () { @@ -587,11 +587,11 @@ test('Promise.method -> throw', function (t) { test('Promise.all', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() - const p1 = resolved('p1') - const p2 = resolved('p2') - const p3 = resolved('p3') + var p1 = resolved('p1') + var p2 = resolved('p2') + var p3 = resolved('p3') Promise.all([p1, p2, p3]).then(function (result) { t.deepEqual(result, ['p1', 'p2', 'p3']) @@ -603,11 +603,11 @@ test('Promise.all', function (t) { test('new Promise -> all', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() - const p1 = resolved('p1') - const p2 = resolved('p2') - const p3 = resolved('p3') + var p1 = resolved('p1') + var p2 = resolved('p2') + var p3 = resolved('p3') resolved([p1, p2, p3]).all().then(function (result) { t.deepEqual(result, ['p1', 'p2', 'p3']) @@ -619,9 +619,9 @@ test('new Promise -> all', function (t) { test('Promise.props', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() - const props = { + var props = { p1: resolved('p1'), p2: resolved('p2'), p3: resolved('p3') @@ -637,9 +637,9 @@ test('Promise.props', function (t) { test('new Promise -> props', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() - const props = { + var props = { p1: resolved('p1'), p2: resolved('p2'), p3: resolved('p3') @@ -655,15 +655,15 @@ test('new Promise -> props', function (t) { test('Promise.any', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() - const p1 = new Promise(function (resolve, reject) { + var p1 = new Promise(function (resolve, reject) { setTimeout(function () { resolve('p1') }, 100) }) - const p2 = rejected('p2') - const p3 = resolved('p3') + var p2 = rejected('p2') + var p3 = resolved('p3') Promise.any([p1, p2, p3]).then(function (result) { t.strictEqual(result, 'p3') @@ -675,15 +675,15 @@ test('Promise.any', function (t) { test('new Promise -> any', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() - const p1 = new Promise(function (resolve, reject) { + var p1 = new Promise(function (resolve, reject) { setTimeout(function () { resolve('p1') }, 100) }) - const p2 = rejected('p2') - const p3 = resolved('p3') + var p2 = rejected('p2') + var p3 = resolved('p3') resolved([p1, p2, p3]).any().then(function (result) { t.strictEqual(result, 'p3') @@ -695,16 +695,16 @@ test('new Promise -> any', function (t) { test('Promise.some', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() - const p1 = new Promise(function (resolve, reject) { + var p1 = new Promise(function (resolve, reject) { setTimeout(function () { resolve('p1') }, 100) }) - const p2 = resolved('p2') - const p3 = rejected('p3') - const p4 = resolved('p4') + var p2 = resolved('p2') + var p3 = rejected('p3') + var p4 = resolved('p4') Promise.some([p1, p2, p3, p4], 2).then(function (result) { t.deepEqual(result, ['p2', 'p4']) @@ -716,16 +716,16 @@ test('Promise.some', function (t) { test('new Promise -> some', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() - const p1 = new Promise(function (resolve, reject) { + var p1 = new Promise(function (resolve, reject) { setTimeout(function () { resolve('p1') }, 100) }) - const p2 = resolved('p2') - const p3 = rejected('p3') - const p4 = resolved('p4') + var p2 = resolved('p2') + var p3 = rejected('p3') + var p4 = resolved('p4') resolved([p1, p2, p3, p4]).some(2).then(function (result) { t.deepEqual(result, ['p2', 'p4']) @@ -737,7 +737,7 @@ test('new Promise -> some', function (t) { test('Promise.map', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() Promise.map([1, 2, 3], function (value) { return resolved(value) @@ -751,7 +751,7 @@ test('Promise.map', function (t) { test('new Promise -> map', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() resolved([1, 2, 3]).map(function (value) { return resolved(value) @@ -765,7 +765,7 @@ test('new Promise -> map', function (t) { test('Promise.reduce', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() Promise.reduce([1, 2, 3], function (total, value) { return new Promise(function (resolve, reject) { @@ -783,7 +783,7 @@ test('Promise.reduce', function (t) { test('new Promise -> reduce', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() resolved([1, 2, 3]).reduce(function (total, value) { return new Promise(function (resolve, reject) { @@ -801,8 +801,8 @@ test('new Promise -> reduce', function (t) { test('Promise.filter', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() - const arr = [resolved(1), resolved(2), resolved(3), resolved(4)] + var trans = ins.startTransaction() + var arr = [resolved(1), resolved(2), resolved(3), resolved(4)] Promise.filter(arr, function (value) { return value > 2 @@ -816,8 +816,8 @@ test('Promise.filter', function (t) { test('new Promise -> filter', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() - const arr = [resolved(1), resolved(2), resolved(3), resolved(4)] + var trans = ins.startTransaction() + var arr = [resolved(1), resolved(2), resolved(3), resolved(4)] resolved(arr).filter(function (value) { return value > 2 @@ -834,12 +834,12 @@ test('new Promise -> filter', function (t) { test('Promise.each', function (t) { t.plan(24) twice(function () { - const trans = ins.startTransaction() - const arr = [resolved(1), resolved(2), resolved(3)] - const results = [1, 2, 3] + var trans = ins.startTransaction() + var arr = [resolved(1), resolved(2), resolved(3)] + var results = [1, 2, 3] Promise.each(arr, function (item, index, length) { - const expected = results.shift() + var expected = results.shift() t.strictEqual(item, expected) t.strictEqual(index, expected - 1, 'index should be expected - 1') t.strictEqual(length, 3, 'length should be 3') @@ -854,12 +854,12 @@ test('Promise.each', function (t) { test('new Promise -> each', function (t) { t.plan(24) twice(function () { - const trans = ins.startTransaction() - const arr = [resolved(1), resolved(2), resolved(3)] - const results = [1, 2, 3] + var trans = ins.startTransaction() + var arr = [resolved(1), resolved(2), resolved(3)] + var results = [1, 2, 3] resolved(arr).each(function (item, index, length) { - const expected = results.shift() + var expected = results.shift() t.strictEqual(item, expected) t.strictEqual(index, expected - 1, 'index should be expected - 1') t.strictEqual(length, 3, 'length should be 3') @@ -872,16 +872,16 @@ if (semver.satisfies(BLUEBIRD_VERSION, '>=3')) { test('Promise.mapSeries', function (t) { t.plan(24) twice(function () { - const trans = ins.startTransaction() - const p1 = resolved(1) - const p2 = resolved(2) - const p3 = resolved(3) - const arr = [p2, p3, p1] - const results = [2, 3, 1] - let i = 0 + var trans = ins.startTransaction() + var p1 = resolved(1) + var p2 = resolved(2) + var p3 = resolved(3) + var arr = [p2, p3, p1] + var results = [2, 3, 1] + var i = 0 Promise.mapSeries(arr, function (item, index, length) { - const expected = results.shift() + var expected = results.shift() t.strictEqual(item, expected) t.strictEqual(index, i++) t.strictEqual(length, 3, 'length should be 3') @@ -893,16 +893,16 @@ if (semver.satisfies(BLUEBIRD_VERSION, '>=3')) { test('new Promise -> mapSeries', function (t) { t.plan(24) twice(function () { - const trans = ins.startTransaction() - const p1 = resolved(1) - const p2 = resolved(2) - const p3 = resolved(3) - const arr = [p2, p3, p1] - const results = [2, 3, 1] - let i = 0 + var trans = ins.startTransaction() + var p1 = resolved(1) + var p2 = resolved(2) + var p3 = resolved(3) + var arr = [p2, p3, p1] + var results = [2, 3, 1] + var i = 0 resolved(arr).mapSeries(function (item, index, length) { - const expected = results.shift() + var expected = results.shift() t.strictEqual(item, expected) t.strictEqual(index, i++) t.strictEqual(length, 3, 'length should be 3') @@ -915,7 +915,7 @@ if (semver.satisfies(BLUEBIRD_VERSION, '>=3')) { test('Promise.using', function (t) { t.plan(6) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() Promise.using(getResource(), function (resource) { t.strictEqual(resource, 'foo') @@ -933,11 +933,11 @@ test('Promise.using', function (t) { test('Promise.promisify', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() - const readFile = Promise.promisify(require('fs').readFile) + var trans = ins.startTransaction() + var readFile = Promise.promisify(require('fs').readFile) readFile(__filename, 'utf8').then(function (contents) { - const firstLine = contents.split('\n')[0] + var firstLine = contents.split('\n')[0] t.strictEqual(firstLine, '/*', 'firstLine') t.strictEqual(ins.currTransaction().id, trans.id, 'currentTransaction().id') }) @@ -947,9 +947,9 @@ test('Promise.promisify', function (t) { test('Promise.promisifyAll', function (t) { t.plan(8) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() - const obj = { + var obj = { success (cb) { setImmediate(function () { cb(null, 'foo') @@ -982,14 +982,14 @@ test('Promise.promisifyAll', function (t) { }) }) -const fromCallbackNames = [] +var fromCallbackNames = [] if (semver.satisfies(BLUEBIRD_VERSION, '>=2.9.0')) fromCallbackNames.push('fromNode') if (semver.satisfies(BLUEBIRD_VERSION, '>=3')) fromCallbackNames.push('fromCallback') fromCallbackNames.forEach(function (fnName) { test('Promise.' + fnName + ' - resolve', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() Promise[fnName](function (cb) { setImmediate(function () { @@ -1007,7 +1007,7 @@ fromCallbackNames.forEach(function (fnName) { test('Promise.' + fnName + ' - reject', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() Promise[fnName](function (cb) { setImmediate(function () { @@ -1023,13 +1023,13 @@ fromCallbackNames.forEach(function (fnName) { }) }) -const asCallbackNames = ['nodeify'] +var asCallbackNames = ['nodeify'] if (semver.satisfies(BLUEBIRD_VERSION, '>=2.9.15')) asCallbackNames.push('asCallback') asCallbackNames.forEach(function (fnName) { test('new Promise -> ' + fnName + ' (resolve)', function (t) { t.plan(10) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() getSomething().then(function (value) { t.strictEqual(value, 'foo') @@ -1051,7 +1051,7 @@ asCallbackNames.forEach(function (fnName) { test('new Promise -> ' + fnName + ' (reject)', function (t) { t.plan(10) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() getSomething() .then(function () { @@ -1077,12 +1077,12 @@ asCallbackNames.forEach(function (fnName) { test('Promise.delay', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() - const start = Date.now() + var trans = ins.startTransaction() + var start = Date.now() Promise.delay(50).then(function () { - const expected = start + 49 // timings are hard - const now = Date.now() + var expected = start + 49 // timings are hard + var now = Date.now() t.ok(expected <= now, 'start + 49 should be <= ' + now + ' - was ' + expected) t.strictEqual(ins.currTransaction().id, trans.id) }) @@ -1092,12 +1092,12 @@ test('Promise.delay', function (t) { test('new Promise -> delay', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() - const start = Date.now() + var trans = ins.startTransaction() + var start = Date.now() Promise.resolve('foo').delay(50).then(function () { - const expected = start + 49 // timings are hard - const now = Date.now() + var expected = start + 49 // timings are hard + var now = Date.now() t.ok(expected <= now, 'start + 49 should be <= ' + now + ' - was ' + expected) t.strictEqual(ins.currTransaction().id, trans.id) }) @@ -1107,7 +1107,7 @@ test('new Promise -> delay', function (t) { test('new Promise -> timeout (resolve in time)', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() resolved('foo') .timeout(50) @@ -1124,7 +1124,7 @@ test('new Promise -> timeout (resolve in time)', function (t) { test('new Promise -> timeout (reject in time)', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() rejected('foo') .timeout(50) @@ -1145,8 +1145,8 @@ test('new Promise -> timeout (timed out)', function (t) { t.plan(6) twice(function () { - const trans = ins.startTransaction() - const start = Date.now() + var trans = ins.startTransaction() + var start = Date.now() new Promise(function (resolve, reject) { setTimeout(function () { @@ -1157,8 +1157,8 @@ test('new Promise -> timeout (timed out)', function (t) { }).catch(function (err) { // You would think elapsed would always be >=50ms, but in busy CI I have // seen slightly *less than* 50ms. - const elapsedMs = Date.now() - start - const diffMs = Math.abs(50 - elapsedMs) + var elapsedMs = Date.now() - start + var diffMs = Math.abs(50 - elapsedMs) t.ok(diffMs <= SLOP_MS, `.timeout(50) resulted in 50 +/- ${SLOP_MS}, actual elapsed was ${elapsedMs}ms`) t.ok(err instanceof Promise.TimeoutError, 'err') t.strictEqual(ins.currTransaction().id, trans.id, 'transaction.id') @@ -1169,7 +1169,7 @@ test('new Promise -> timeout (timed out)', function (t) { test('new Promise -> reject -> tap -> catch', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() rejected('foo') .tap(function () { t.fail('should not call tap') @@ -1187,7 +1187,7 @@ test('new Promise -> reject -> tap -> catch', function (t) { test('new Promise -> resolve -> tap -> then (no return)', function (t) { t.plan(6) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() resolved('foo') .tap(function (value) { t.strictEqual(value, 'foo') @@ -1202,7 +1202,7 @@ test('new Promise -> resolve -> tap -> then (no return)', function (t) { test('new Promise -> resolve -> tap -> then (return)', function (t) { t.plan(6) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() resolved('foo') .tap(function (value) { t.strictEqual(value, 'foo') @@ -1218,8 +1218,8 @@ test('new Promise -> resolve -> tap -> then (return)', function (t) { test('new Promise -> call', function (t) { t.plan(8) twice(function () { - const trans = ins.startTransaction() - const obj = { + var trans = ins.startTransaction() + var obj = { foo (a, b) { t.strictEqual(a, 1) t.strictEqual(b, 2) @@ -1238,7 +1238,7 @@ test('new Promise -> call', function (t) { test('new Promise -> get', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() resolved({ foo: 42 }) .get('foo') .then(function (value) { @@ -1248,12 +1248,12 @@ test('new Promise -> get', function (t) { }) }) -const RETURN_NAMES = ['return', 'thenReturn'] +var RETURN_NAMES = ['return', 'thenReturn'] RETURN_NAMES.forEach(function (fnName) { test('new Promise -> ' + fnName, function (t) { t.plan(8) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() resolved('foo') .then(function (value) { t.deepEqual(value, 'foo') @@ -1267,12 +1267,12 @@ RETURN_NAMES.forEach(function (fnName) { }) }) -const THROW_NAMES = ['throw', 'thenThrow'] +var THROW_NAMES = ['throw', 'thenThrow'] THROW_NAMES.forEach(function (fnName) { test('new Promise -> ' + fnName, function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() resolved('foo')[fnName](new Error('bar')) .then(function () { t.fail('should not resolve') @@ -1289,7 +1289,7 @@ if (semver.satisfies(BLUEBIRD_VERSION, '>=3')) { test('new Promise -> resolve -> catchReturn', function (t) { t.plan(8) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() resolved('foo') .then(function (value) { t.deepEqual(value, 'foo') @@ -1306,7 +1306,7 @@ if (semver.satisfies(BLUEBIRD_VERSION, '>=3')) { test('new Promise -> reject -> catchReturn', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() rejected('foo') .then(function () { t.fail('should not resolve') @@ -1322,7 +1322,7 @@ if (semver.satisfies(BLUEBIRD_VERSION, '>=3')) { test('new Promise -> resolve -> catchThrow', function (t) { t.plan(8) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() resolved('foo') .then(function (value) { t.deepEqual(value, 'foo') @@ -1342,7 +1342,7 @@ if (semver.satisfies(BLUEBIRD_VERSION, '>=3')) { test('new Promise -> reject -> catchThrow', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() rejected('foo') .then(function () { t.fail('should not resolve') @@ -1363,7 +1363,7 @@ if (semver.satisfies(BLUEBIRD_VERSION, '>=2.3.6')) { test('new Promise -> reflect', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() resolved('foo').reflect().then(function (p) { t.ok(p.isFulfilled()) t.strictEqual(ins.currTransaction().id, trans.id) @@ -1375,7 +1375,7 @@ if (semver.satisfies(BLUEBIRD_VERSION, '>=2.3.6')) { test('new Promise -> settle', function (t) { t.plan(6) twice(function () { - const trans = ins.startTransaction() + var trans = ins.startTransaction() Promise.settle([resolved('foo')]).then(function (result) { t.strictEqual(result.length, 1) t.ok(result[0].isFulfilled()) diff --git a/test/instrumentation/modules/bluebird/cancel.test.js b/test/instrumentation/modules/bluebird/cancel.test.js index c2c88e6a8e..861495e0c8 100644 --- a/test/instrumentation/modules/bluebird/cancel.test.js +++ b/test/instrumentation/modules/bluebird/cancel.test.js @@ -11,7 +11,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -const agent = require('../../../..').start({ +var agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -19,24 +19,24 @@ const agent = require('../../../..').start({ centralConfig: false }) -const BLUEBIRD_VERSION = require('bluebird/package').version -const Promise = require('bluebird') -const semver = require('semver') -const test = require('tape') +var BLUEBIRD_VERSION = require('bluebird/package').version +var Promise = require('bluebird') +var semver = require('semver') +var test = require('tape') -const ins = agent._instrumentation +var ins = agent._instrumentation if (semver.satisfies(BLUEBIRD_VERSION, '>=3')) { Promise.config({ cancellation: true }) - const CANCEL_NAMES = ['cancel', 'break'] + var CANCEL_NAMES = ['cancel', 'break'] CANCEL_NAMES.forEach(function (fnName) { test('Promise.prototype.' + fnName, function (t) { t.plan(8) twice(function () { - const trans = ins.startTransaction() - let cancelled = false - const p = new Promise(function (resolve, reject, onCancel) { + var trans = ins.startTransaction() + var cancelled = false + var p = new Promise(function (resolve, reject, onCancel) { setTimeout(function () { resolve('foo') }, 100) @@ -65,9 +65,9 @@ if (semver.satisfies(BLUEBIRD_VERSION, '>=3')) { test('Promise.prototype.cancel', function (t) { t.plan(4) twice(function () { - const trans = ins.startTransaction() - const p = new Promise(function () {}).cancellable() - const err = new Error() + var trans = ins.startTransaction() + var p = new Promise(function () {}).cancellable() + var err = new Error() p.cancel(err) p.then(t.fail, function (e) { t.strictEqual(e, err) diff --git a/test/instrumentation/modules/elasticsearch.test.js b/test/instrumentation/modules/elasticsearch.test.js index dfc513ea39..39860c77e1 100644 --- a/test/instrumentation/modules/elasticsearch.test.js +++ b/test/instrumentation/modules/elasticsearch.test.js @@ -12,9 +12,9 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { } process.env.ELASTIC_APM_TEST = true -const host = (process.env.ES_HOST || 'localhost') + ':9200' +var host = (process.env.ES_HOST || 'localhost') + ':9200' -const agent = require('../../..').start({ +var agent = require('../../..').start({ serviceName: 'test-elasticsearch-legacy-client', captureExceptions: false, metricsInterval: 0, @@ -24,20 +24,20 @@ const agent = require('../../..').start({ spanCompressionEnabled: false }) -const elasticsearch = require('elasticsearch') -const pkg = require('elasticsearch/package.json') -const semver = require('semver') -const test = require('tape') +var elasticsearch = require('elasticsearch') +var pkg = require('elasticsearch/package.json') +var semver = require('semver') +var test = require('tape') -const mockClient = require('../../_mock_http_client') -const findObjInArray = require('../../_utils').findObjInArray +var mockClient = require('../../_mock_http_client') +var findObjInArray = require('../../_utils').findObjInArray test('client.ping with callback', function userLandCode (t) { resetAgent(assertApmDataAndEnd(t, 'HEAD /', `http://${host}/`)) agent.startTransaction('foo') - const client = new elasticsearch.Client({ host: host }) + var client = new elasticsearch.Client({ host: host }) client.ping(function (err) { t.error(err, 'no error from client.ping') @@ -52,7 +52,7 @@ test('client.ping with promise', function userLandCode (t) { agent.startTransaction('foo') - const client = new elasticsearch.Client({ host: host }) + var client = new elasticsearch.Client({ host: host }) client.ping().then(function () { agent.endTransaction() @@ -68,8 +68,8 @@ test('client.search with callback', function userLandCode (t) { agent.startTransaction('foo') - const client = new elasticsearch.Client({ host: host }) - const query = { q: 'pants' } + var client = new elasticsearch.Client({ host: host }) + var query = { q: 'pants' } client.search(query, function (err) { t.error(err) @@ -84,10 +84,10 @@ test('client.search with abort', function userLandCode (t) { agent.startTransaction('foo') - const client = new elasticsearch.Client({ host: host }) - const query = { q: 'pants' } + var client = new elasticsearch.Client({ host: host }) + var query = { q: 'pants' } - const req = client.search(query) + var req = client.search(query) t.ok(agent.currentSpan === null, 'no currentSpan in sync code after elasticsearch client command') setImmediate(() => { @@ -99,7 +99,7 @@ test('client.search with abort', function userLandCode (t) { if (semver.satisfies(pkg.version, '>= 10')) { test('client.searchTemplate with callback', function userLandCode (t) { - const body = { + var body = { source: { query: { query_string: { @@ -121,7 +121,7 @@ if (semver.satisfies(pkg.version, '>= 10')) { agent.startTransaction('foo') - const client = new elasticsearch.Client({ host: host }) + var client = new elasticsearch.Client({ host: host }) client.searchTemplate({ body }, function (err) { t.error(err) @@ -134,7 +134,7 @@ if (semver.satisfies(pkg.version, '>= 10')) { if (semver.satisfies(pkg.version, '>= 13')) { test('client.msearch with callback', function userLandCode (t) { - const body = [ + var body = [ {}, { query: { @@ -145,13 +145,13 @@ if (semver.satisfies(pkg.version, '>= 13')) { } ] - const statement = body.map(JSON.stringify).join('\n') + '\n' + var statement = body.map(JSON.stringify).join('\n') + '\n' resetAgent(assertApmDataAndEnd(t, 'POST /_msearch', `http://${host}/_msearch`, statement)) agent.startTransaction('foo') - const client = new elasticsearch.Client({ host: host }) + var client = new elasticsearch.Client({ host: host }) client.msearch({ body }, function (err) { t.error(err) @@ -162,7 +162,7 @@ if (semver.satisfies(pkg.version, '>= 13')) { }) test('client.msearchTempate with callback', function userLandCode (t) { - const body = [ + var body = [ {}, { source: { @@ -178,13 +178,13 @@ if (semver.satisfies(pkg.version, '>= 13')) { } ] - const statement = body.map(JSON.stringify).join('\n') + '\n' + var statement = body.map(JSON.stringify).join('\n') + '\n' resetAgent(assertApmDataAndEnd(t, 'POST /_msearch/template', `http://${host}/_msearch/template`, statement)) agent.startTransaction('foo') - const client = new elasticsearch.Client({ host: host }) + var client = new elasticsearch.Client({ host: host }) client.msearchTemplate({ body }, function (err) { t.error(err) @@ -200,7 +200,7 @@ test('client.count with callback', function userLandCode (t) { agent.startTransaction('foo') - const client = new elasticsearch.Client({ host: host }) + var client = new elasticsearch.Client({ host: host }) client.count(function (err) { t.error(err) agent.endTransaction() @@ -212,7 +212,7 @@ test('client.count with callback', function userLandCode (t) { test('client with host=', function userLandCode (t) { resetAgent(assertApmDataAndEnd(t, 'HEAD /', `http://${host}/`)) agent.startTransaction('foo') - const client = new elasticsearch.Client({ host: [host] }) + var client = new elasticsearch.Client({ host: [host] }) client.ping(function (err) { t.error(err) agent.endTransaction() @@ -224,7 +224,7 @@ test('client with host=', function userLandCode (t) { test('client with hosts=', function userLandCode (t) { resetAgent(assertApmDataAndEnd(t, 'HEAD /', `http://${host}/`)) agent.startTransaction('foo') - const client = new elasticsearch.Client({ hosts: [host, host] }) + var client = new elasticsearch.Client({ hosts: [host, host] }) client.ping(function (err) { t.error(err) agent.endTransaction() @@ -240,7 +240,7 @@ test('client with hosts="http://host:port"', function userLandCode (t) { if (!hostWithProto.startsWith('http')) { hostWithProto = 'http://' + host } - const client = new elasticsearch.Client({ hosts: hostWithProto }) + var client = new elasticsearch.Client({ hosts: hostWithProto }) client.ping(function (err) { t.error(err) agent.endTransaction() @@ -253,7 +253,7 @@ test('client with host=', function userLandCode (t) { resetAgent(assertApmDataAndEnd(t, 'HEAD /', `http://${host}/`)) agent.startTransaction('foo') const [hostname, port] = host.split(':') - const client = new elasticsearch.Client({ + var client = new elasticsearch.Client({ host: [{ host: hostname, port: port }] }) client.ping(function (err) { @@ -269,7 +269,7 @@ function assertApmDataAndEnd (t, expectedName, expectedHttpUrl, expectedDbStatem t.strictEqual(data.transactions.length, 1, 'should have 1 transaction') t.strictEqual(data.spans.length, 1, 'should have 1 span') - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, 'foo', 'transaction name should be "foo"') t.strictEqual(trans.type, 'custom', 'transaction type should be "custom"') diff --git a/test/instrumentation/modules/express-queue.test.js b/test/instrumentation/modules/express-queue.test.js index 74eedf331b..9d7700f6e2 100644 --- a/test/instrumentation/modules/express-queue.test.js +++ b/test/instrumentation/modules/express-queue.test.js @@ -11,7 +11,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -const agent = require('../../..').start({ +var agent = require('../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -19,23 +19,23 @@ const agent = require('../../..').start({ centralConfig: false }) -const http = require('http') +var http = require('http') -const express = require('express') -const queue = require('express-queue') -const test = require('tape') +var express = require('express') +var queue = require('express-queue') +var test = require('tape') -const mockClient = require('../../_mock_http_client') -const findObjInArray = require('../../_utils').findObjInArray +var mockClient = require('../../_mock_http_client') +var findObjInArray = require('../../_utils').findObjInArray test('express-queue', function (t) { resetAgent(done(t, 'done')) - const app = express() + var app = express() app.use(queue({ activeLimit: 1, queuedLimit: -1 })) app.get('/', function (req, res) { setImmediate(function () { - const span = agent.startSpan('foo', 'bar') + var span = agent.startSpan('foo', 'bar') setImmediate(function () { if (span) span.end() res.end('done') @@ -44,10 +44,10 @@ test('express-queue', function (t) { }) var server = app.listen(function () { - const port = server.address().port - const path = '/' + var port = server.address().port + var path = '/' - const tasks = [] + var tasks = [] for (let i = 0; i < 5; i++) { tasks.push(request(port, path)) } @@ -63,7 +63,7 @@ test('express-queue', function (t) { function request (port, path) { return new Promise((resolve, reject) => { - const opts = { + var opts = { method: 'GET', port: port, path: path, @@ -72,8 +72,8 @@ function request (port, path) { } } - const req = http.request(opts, function (res) { - const chunks = [] + var req = http.request(opts, function (res) { + var chunks = [] res.on('error', reject) res.on('data', chunks.push.bind(chunks)) res.on('end', function () { @@ -98,7 +98,7 @@ function done (t, query) { t.strictEqual(span.name, 'foo', 'span name should be foo') t.strictEqual(span.type, 'bar', 'span name should be bar') - const offset = span.timestamp - trans.timestamp + var offset = span.timestamp - trans.timestamp t.ok(offset + span.duration * 1000 < trans.duration * 1000, 'span should have valid timings') }) diff --git a/test/instrumentation/modules/express/basic.test.js b/test/instrumentation/modules/express/basic.test.js index df1ae86227..96d9d916a7 100644 --- a/test/instrumentation/modules/express/basic.test.js +++ b/test/instrumentation/modules/express/basic.test.js @@ -11,7 +11,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -const agent = require('../../../..').start({ +var agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: true, @@ -19,21 +19,21 @@ const agent = require('../../../..').start({ centralConfig: false }) -const http = require('http') +var http = require('http') -const express = require('express') -const test = require('tape') +var express = require('express') +var test = require('tape') -const mockClient = require('../../../_mock_http_client') +var mockClient = require('../../../_mock_http_client') -const nestedRouteTestCases = [ +var nestedRouteTestCases = [ [], // no nesting ['/', ''], ['/sub', '/sub'], ['/sub/:id', '/sub/42'] ] -const routeTestCases = [ +var routeTestCases = [ ['use', '/', 'GET', '/'], ['use', '/', 'POST', '/'], ['get', '/', 'GET', '/'], @@ -104,14 +104,14 @@ test('error intercept', function (t) { resetAgent(function (data) { t.strictEqual(data.transactions.length, 1, 'has a transaction') - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, 'GET /', 'transaction name is GET /') t.strictEqual(trans.type, 'request', 'transaction type is request') }) - let request - const error = new Error('wat') - const captureError = agent.captureError + var request + var error = new Error('wat') + var captureError = agent.captureError agent.captureError = function (err, data) { t.strictEqual(err, error, 'has the expected error') t.ok(data, 'captured data with error') @@ -121,7 +121,7 @@ test('error intercept', function (t) { agent.captureError = captureError }) - const app = express() + var app = express() app.set('env', 'production') app.get('/', function (req, res, next) { @@ -150,12 +150,12 @@ test('ignore 404 errors', function (t) { resetAgent(function (data) { t.strictEqual(data.transactions.length, 1, 'has a transaction') - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, 'GET unknown route', 'transaction name is GET unknown route') t.strictEqual(trans.type, 'request', 'transaction type is request') }) - const captureError = agent.captureError + var captureError = agent.captureError agent.captureError = function (_, data) { t.fail('it should not capture 404 errors') } @@ -163,7 +163,7 @@ test('ignore 404 errors', function (t) { agent.captureError = captureError }) - const app = express() + var app = express() app.set('env', 'production') app.use(function (req, res) { @@ -186,12 +186,12 @@ test('ignore invalid errors', function (t) { resetAgent(function (data) { t.strictEqual(data.transactions.length, 1, 'has a transaction') - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, 'GET /', 'transaction name is GET /') t.strictEqual(trans.type, 'request', 'transaction type is request') }) - const captureError = agent.captureError + var captureError = agent.captureError agent.captureError = function (_, data) { t.fail('should not capture invalid errors') } @@ -199,7 +199,7 @@ test('ignore invalid errors', function (t) { agent.captureError = captureError }) - const app = express() + var app = express() app.set('env', 'production') app.get('/', function (req, res, next) { @@ -226,12 +226,12 @@ test('do not inherit past route names', function (t) { resetAgent(function (data) { t.strictEqual(data.transactions.length, 1, 'has a transaction') - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, 'GET /', 'transaction name is GET /') t.strictEqual(trans.type, 'request', 'transaction type is request') }) - const captureError = agent.captureError + var captureError = agent.captureError agent.captureError = function (_, data) { t.fail('should not capture invalid errors') } @@ -239,7 +239,7 @@ test('do not inherit past route names', function (t) { agent.captureError = captureError }) - const app = express() + var app = express() app.set('env', 'production') app.get('/', function (req, res, next) { @@ -267,12 +267,12 @@ test('sub-routers include base path', function (t) { resetAgent(function (data) { t.strictEqual(data.transactions.length, 1, 'has a transaction') - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, 'GET /hello/:name', 'transaction name is GET /hello/:name') t.strictEqual(trans.type, 'request', 'transaction type is request') }) - const captureError = agent.captureError + var captureError = agent.captureError agent.captureError = function (_, data) { t.fail('should not capture invalid errors') } @@ -280,12 +280,12 @@ test('sub-routers include base path', function (t) { agent.captureError = captureError }) - const router = express.Router() + var router = express.Router() router.get('/:name', (req, res) => { res.end(`hello, ${req.params.name}`) }) - const app = express() + var app = express() app.set('env', 'production') app.use('/hello', router) @@ -305,24 +305,24 @@ test('sub-routers throw exception', function (t) { resetAgent(function (data) { t.strictEqual(data.transactions.length, 1, 'has a transaction') - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, 'GET /api/:name', 'transaction name is GET /api/:name') t.strictEqual(trans.type, 'request', 'transaction type is request') }) - const error = new Error('hello') - const captureError = agent.captureError + var error = new Error('hello') + var captureError = agent.captureError agent.captureError = function () {} t.on('end', function () { agent.captureError = captureError }) - const router = express.Router() + var router = express.Router() router.get('/:name', (req, res) => { throw error }) - const app = express() + var app = express() app.set('env', 'production') app.use('/api', router) @@ -340,23 +340,23 @@ test('sub-router handler calls next(exception)', function (t) { resetAgent(function (data) { t.strictEqual(data.transactions.length, 1, 'has a transaction') - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, 'GET /api/:name', 'transaction name is GET /api/:name') t.strictEqual(trans.type, 'request', 'transaction type is request') }) // Ignore captureError handling for this test. - const captureError = agent.captureError + var captureError = agent.captureError agent.captureError = function () {} t.on('end', function () { agent.captureError = captureError }) - const router = express.Router() + var router = express.Router() router.get('/:name', (_req, _res, next) => { next(new Error('boom')) }) - const app = express() + var app = express() app.set('env', 'production') app.use('/api', router) @@ -376,23 +376,23 @@ test('sub-router handler calls next(non-exception)', function (t) { resetAgent(function (data) { t.strictEqual(data.transactions.length, 1, 'has a transaction') - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, 'GET /api/:name', 'transaction name is GET /api/:name') t.strictEqual(trans.type, 'request', 'transaction type is request') }) // Ignore captureError handling for this test. - const captureError = agent.captureError + var captureError = agent.captureError agent.captureError = function () {} t.on('end', function () { agent.captureError = captureError }) - const router = express.Router() + var router = express.Router() router.get('/:name', (_req, _res, next) => { next('this is some truthy value that is not "route" or "router"') }) - const app = express() + var app = express() app.set('env', 'production') app.use('/api', router) @@ -410,26 +410,26 @@ test('sub-router handler calls next("route")', function (t) { resetAgent(function (data) { t.strictEqual(data.transactions.length, 1, 'has a transaction') - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, 'GET /api/other-endpoint', 'transaction name is GET /api/other-endpoint') t.strictEqual(trans.type, 'request', 'transaction type is request') }) // Ignore captureError handling for this test. - const captureError = agent.captureError + var captureError = agent.captureError agent.captureError = function () {} t.on('end', function () { agent.captureError = captureError }) - const router = express.Router() + var router = express.Router() router.get('/:name', (_req, _res, next) => { next('route') }) router.get('/other-endpoint', (_req, res) => { res.end('hi from other-endpoint') }) - const app = express() + var app = express() app.set('env', 'production') app.use('/api', router) @@ -488,8 +488,8 @@ function get (server, opts, cb) { Object.assign(opts, { port: server.address().port }) - const req = http.request(opts, function (res) { - const chunks = [] + var req = http.request(opts, function (res) { + var chunks = [] res.setEncoding('utf8') res.on('error', cb) res.on('data', chunks.push.bind(chunks)) diff --git a/test/instrumentation/modules/fastify/fastify.test.js b/test/instrumentation/modules/fastify/fastify.test.js index 6719113ddd..cc07c9a91d 100644 --- a/test/instrumentation/modules/fastify/fastify.test.js +++ b/test/instrumentation/modules/fastify/fastify.test.js @@ -79,7 +79,7 @@ test('captureBody', function (t) { resetAgent(data => { t.strictEqual(data.transactions.length, 1) - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, 'POST /postSomeData', 'transaction.name') t.strictEqual(trans.type, 'request', 'transaction.type') t.strictEqual(trans.result, 'HTTP 2xx', 'transaction.result') diff --git a/test/instrumentation/modules/finalhandler.test.js b/test/instrumentation/modules/finalhandler.test.js index 77ed8c2db5..41b8ff1786 100644 --- a/test/instrumentation/modules/finalhandler.test.js +++ b/test/instrumentation/modules/finalhandler.test.js @@ -11,7 +11,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -const agent = require('../../..').start({ +var agent = require('../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: true, @@ -19,13 +19,13 @@ const agent = require('../../..').start({ centralConfig: false }) -const http = require('http') +var http = require('http') -const express = require('express') -const finalhandler = require('finalhandler') -const test = require('tape') +var express = require('express') +var finalhandler = require('finalhandler') +var test = require('tape') -const mockClient = require('../../_mock_http_client') +var mockClient = require('../../_mock_http_client') function makeTest (makeServer) { return function (t) { @@ -34,14 +34,14 @@ function makeTest (makeServer) { resetAgent(function (data) { t.strictEqual(data.transactions.length, 1, 'has a transaction') - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, 'GET /', 'transaction name is GET /') t.strictEqual(trans.type, 'request', 'transaction type is request') }) - let request - const error = new Error('wat') - const captureError = agent.captureError + var request + var error = new Error('wat') + var captureError = agent.captureError agent.captureError = function (err, data) { t.strictEqual(err, error, 'has the expected error') t.ok(data, 'captured data with error') @@ -51,12 +51,12 @@ function makeTest (makeServer) { agent.captureError = captureError }) - const server = makeServer(error, req => { + var server = makeServer(error, req => { request = req }) server.listen(function () { - const port = server.address().port + var port = server.address().port http.get(`http://localhost:${port}`, res => { t.strictEqual(res.statusCode, 500) res.resume() @@ -71,7 +71,7 @@ function makeTest (makeServer) { test('basic http', makeTest((error, setRequest) => { return http.createServer((req, res) => { - const done = finalhandler(req, res) + var done = finalhandler(req, res) agent.setTransactionName('GET /') setRequest(req) done(error) @@ -79,7 +79,7 @@ test('basic http', makeTest((error, setRequest) => { })) test('express done', makeTest((error, setRequest) => { - const app = express() + var app = express() app.get('/', (req, res, next) => { setRequest(req) @@ -90,7 +90,7 @@ test('express done', makeTest((error, setRequest) => { })) test('express throw', makeTest((error, setRequest) => { - const app = express() + var app = express() app.get('/', (req, res, next) => { setRequest(req) @@ -101,7 +101,7 @@ test('express throw', makeTest((error, setRequest) => { })) test('express with error handler', makeTest((error, setRequest) => { - const app = express() + var app = express() app.get('/', (req, res, next) => { setRequest(req) diff --git a/test/instrumentation/modules/generic-pool.test.js b/test/instrumentation/modules/generic-pool.test.js index abb6d6e222..4e1377825e 100644 --- a/test/instrumentation/modules/generic-pool.test.js +++ b/test/instrumentation/modules/generic-pool.test.js @@ -11,7 +11,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -const agent = require('../../..').start({ +var agent = require('../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -19,18 +19,18 @@ const agent = require('../../..').start({ centralConfig: false }) -const genericPool = require('generic-pool') -const test = require('tape') +var genericPool = require('generic-pool') +var test = require('tape') -const ins = global.ins = agent._instrumentation +var ins = global.ins = agent._instrumentation if (genericPool.createPool) { test('v3.x', function (t) { - let active = 0 + var active = 0 - const pool = genericPool.createPool({ + var pool = genericPool.createPool({ create () { - const p = new Promise(function (resolve, reject) { + var p = new Promise(function (resolve, reject) { process.nextTick(function () { resolve({ id: ++active }) }) @@ -48,7 +48,7 @@ if (genericPool.createPool) { } }) - const t1 = ins.startTransaction() + var t1 = ins.startTransaction() pool.acquire().then(function (resource) { t.strictEqual(resource.id, 1) @@ -59,7 +59,7 @@ if (genericPool.createPool) { }) t.strictEqual(ins.currTransaction().id, t1.id) - const t2 = ins.startTransaction() + var t2 = ins.startTransaction() pool.acquire().then(function (resource) { t.strictEqual(resource.id, 1) @@ -79,9 +79,9 @@ if (genericPool.createPool) { }) } else { test('v2.x', function (t) { - let active = 0 + var active = 0 - const pool = new genericPool.Pool({ + var pool = new genericPool.Pool({ create (cb) { process.nextTick(function () { cb(null, { id: ++active }) @@ -92,7 +92,7 @@ if (genericPool.createPool) { } }) - const t1 = ins.startTransaction() + var t1 = ins.startTransaction() pool.acquire(function (err, resource) { t.error(err) @@ -102,7 +102,7 @@ if (genericPool.createPool) { }) t.strictEqual(ins.currTransaction().id, t1.id) - const t2 = ins.startTransaction() + var t2 = ins.startTransaction() pool.acquire(function (err, resource) { t.error(err) diff --git a/test/instrumentation/modules/graphql.test.js b/test/instrumentation/modules/graphql.test.js index 045fa4f71f..4163f0d126 100644 --- a/test/instrumentation/modules/graphql.test.js +++ b/test/instrumentation/modules/graphql.test.js @@ -11,7 +11,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -const agent = require('../../..').start({ +var agent = require('../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -26,10 +26,10 @@ if (semver.satisfies(graphqlVer, '>=16') && !semver.satisfies(process.version, ' process.exit() } -const graphql = require('graphql') -const test = require('tape') +var graphql = require('graphql') +var test = require('tape') -const mockClient = require('../../_mock_http_client') +var mockClient = require('../../_mock_http_client') // See explanation of these in "lib/instrumentation/modules/graphql.js". const onlySupportsPositionalArgs = semver.lt(graphqlVer, '0.10.0') @@ -40,13 +40,13 @@ if (!onlySupportsSingleArg) { test('graphql.graphql(...) - positional args', function (t) { resetAgent(done(t)) - const schema = graphql.buildSchema('type Query { hello: String }') - const rootValue = { + var schema = graphql.buildSchema('type Query { hello: String }') + var rootValue = { hello () { return 'Hello world!' } } - const query = '{ hello }' + var query = '{ hello }' agent.startTransaction('foo') @@ -64,13 +64,13 @@ if (!onlySupportsPositionalArgs) { test('graphql.graphql(...) - single GraphQLArgs arg', function (t) { resetAgent(done(t)) - const schema = graphql.buildSchema('type Query { hello: String }') - const rootValue = { + var schema = graphql.buildSchema('type Query { hello: String }') + var rootValue = { hello () { return 'Hello world!' } } - const query = '{ hello }' + var query = '{ hello }' agent.startTransaction('foo') @@ -87,13 +87,13 @@ if (!onlySupportsPositionalArgs) { test('graphql.graphql - invalid query', function (t) { resetAgent(done(t, 'Unknown Query')) - const schema = graphql.buildSchema('type Query { hello: String }') - const rootValue = { + var schema = graphql.buildSchema('type Query { hello: String }') + var rootValue = { hello () { return 'Hello world!' } } - const query = '{ hello' + var query = '{ hello' agent.startTransaction('foo') @@ -115,19 +115,19 @@ test('graphql.graphql - transaction ended', function (t) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 0) - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, 'foo') t.strictEqual(trans.type, 'custom') }) - const schema = graphql.buildSchema('type Query { hello: String }') - const rootValue = { + var schema = graphql.buildSchema('type Query { hello: String }') + var rootValue = { hello () { return 'Hello world!' } } - const query = '{ hello }' + var query = '{ hello }' agent.startTransaction('foo').end() @@ -143,15 +143,15 @@ if (!onlySupportsSingleArg) { test('graphql.execute(...) - positional args', function (t) { resetAgent(done(t)) - const schema = graphql.buildSchema('type Query { hello: String }') - const rootValue = { + var schema = graphql.buildSchema('type Query { hello: String }') + var rootValue = { hello () { return Promise.resolve('Hello world!') } } - const query = '{ hello }' - const source = new graphql.Source(query) - const documentAST = graphql.parse(source) + var query = '{ hello }' + var source = new graphql.Source(query) + var documentAST = graphql.parse(source) agent.startTransaction('foo') @@ -172,21 +172,21 @@ test('graphql.execute - transaction ended', function (t) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 0) - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, 'foo') t.strictEqual(trans.type, 'custom') }) - const schema = graphql.buildSchema('type Query { hello: String }') - const rootValue = { + var schema = graphql.buildSchema('type Query { hello: String }') + var rootValue = { hello () { return Promise.resolve('Hello world!') } } - const query = '{ hello }' - const source = new graphql.Source(query) - const document = graphql.parse(source) + var query = '{ hello }' + var source = new graphql.Source(query) + var document = graphql.parse(source) agent.startTransaction('foo').end() @@ -201,16 +201,16 @@ if (!onlySupportsPositionalArgs) { test('graphql.execute(...) - single ExecutionArgs arg', function (t) { resetAgent(done(t)) - const schema = graphql.buildSchema('type Query { hello: String }') - const rootValue = { + var schema = graphql.buildSchema('type Query { hello: String }') + var rootValue = { hello () { return Promise.resolve('Hello world!') } } - const query = '{ hello }' - const source = new graphql.Source(query) - const documentAST = graphql.parse(source) - const args = { + var query = '{ hello }' + var source = new graphql.Source(query) + var documentAST = graphql.parse(source) + var args = { schema: schema, document: documentAST, rootValue: rootValue @@ -232,19 +232,19 @@ if (semver.satisfies(graphqlVer, '>=0.12')) { test('graphql.execute sync', function (t) { resetAgent(done(t)) - const schema = graphql.buildSchema('type Query { hello: String }') - const rootValue = { + var schema = graphql.buildSchema('type Query { hello: String }') + var rootValue = { hello () { return 'Hello world!' } } - const query = '{ hello }' - const source = new graphql.Source(query) - const document = graphql.parse(source) + var query = '{ hello }' + var source = new graphql.Source(query) + var document = graphql.parse(source) agent.startTransaction('foo') - const response = graphql.execute(...buildExecuteArgs({ schema, document, rootValue })) + var response = graphql.execute(...buildExecuteArgs({ schema, document, rootValue })) t.ok(agent.currentSpan === null, 'no currentSpan in sync code after .execute(...)') agent.endTransaction() @@ -260,8 +260,8 @@ function done (t, spanNameSuffix) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 1) - const trans = data.transactions[0] - const span = data.spans[0] + var trans = data.transactions[0] + var span = data.spans[0] t.strictEqual(trans.name, 'foo') t.strictEqual(trans.type, 'custom') @@ -270,7 +270,7 @@ function done (t, spanNameSuffix) { t.strictEqual(span.subtype, 'graphql') t.strictEqual(span.action, 'execute') - const offset = span.timestamp - trans.timestamp + var offset = span.timestamp - trans.timestamp t.ok(offset + span.duration * 1000 < trans.duration * 1000) t.end() diff --git a/test/instrumentation/modules/handlebars.test.js b/test/instrumentation/modules/handlebars.test.js index 4c4b73ca1c..55e566d72e 100644 --- a/test/instrumentation/modules/handlebars.test.js +++ b/test/instrumentation/modules/handlebars.test.js @@ -13,7 +13,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.env.ELASTIC_APM_TEST = true -const agent = require('../../..').start({ +var agent = require('../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -22,18 +22,18 @@ const agent = require('../../..').start({ spanStackTraceMinDuration: 0 // Always have span stacktraces. }) -const handlebars = require('handlebars') -const test = require('tape') +var handlebars = require('handlebars') +var test = require('tape') -const mockClient = require('../../_mock_http_client') -const findObjInArray = require('../../_utils').findObjInArray +var mockClient = require('../../_mock_http_client') +var findObjInArray = require('../../_utils').findObjInArray test('handlebars compile and render', function userLandCode (t) { resetAgent(function (data) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 2) - const trans = data.transactions[0] + var trans = data.transactions[0] t.ok(/^foo\d$/.test(trans.name)) t.strictEqual(trans.type, 'custom') @@ -55,7 +55,7 @@ test('handlebars compile and render', function userLandCode (t) { agent.startTransaction('foo1') - const template = handlebars.compile('Hello, {{name}}!') + var template = handlebars.compile('Hello, {{name}}!') template({ name: 'world' }) agent.endTransaction() diff --git a/test/instrumentation/modules/hapi/set-framework-hapihapi.test.js b/test/instrumentation/modules/hapi/set-framework-hapihapi.test.js index a361aca72f..a16d6b2c0e 100644 --- a/test/instrumentation/modules/hapi/set-framework-hapihapi.test.js +++ b/test/instrumentation/modules/hapi/set-framework-hapihapi.test.js @@ -11,7 +11,7 @@ const agent = require('../../../..').start({ metricsInterval: 0 }) -const isHapiIncompat = require('../../../_is_hapi_incompat') +var isHapiIncompat = require('../../../_is_hapi_incompat') if (isHapiIncompat('@hapi/hapi')) { // Skip out of this test. console.log(`# SKIP this version of '@hapi/hapi' is incompatible with node ${process.version}`) diff --git a/test/instrumentation/modules/hapi/shared.js b/test/instrumentation/modules/hapi/shared.js index aae117ecc2..24323fbee5 100644 --- a/test/instrumentation/modules/hapi/shared.js +++ b/test/instrumentation/modules/hapi/shared.js @@ -7,7 +7,7 @@ 'use strict' module.exports = (moduleName) => { - const agent = require('../../../..').start({ + var agent = require('../../../..').start({ serviceName: 'test-hapi', captureExceptions: false, logLevel: 'off', @@ -17,23 +17,23 @@ module.exports = (moduleName) => { captureBody: 'all' }) - const isHapiIncompat = require('../../../_is_hapi_incompat') + var isHapiIncompat = require('../../../_is_hapi_incompat') if (isHapiIncompat(moduleName)) { // Skip out of this test. console.log(`# SKIP this version of ${moduleName} is incompatible with node ${process.version}`) process.exit() } - const http = require('http') + var http = require('http') - const Hapi = require(moduleName) - const pkg = require(moduleName + '/package.json') - const semver = require('semver') - const test = require('tape') + var Hapi = require(moduleName) + var pkg = require(moduleName + '/package.json') + var semver = require('semver') + var test = require('tape') - const mockClient = require('../../../_mock_http_client') + var mockClient = require('../../../_mock_http_client') - const originalCaptureError = agent.captureError + var originalCaptureError = agent.captureError function noop () {} @@ -41,7 +41,7 @@ module.exports = (moduleName) => { resetAgent(2, function (data) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.errors.length, 1) - const request = data.errors[0].context.request + var request = data.errors[0].context.request t.strictEqual(request.method, 'GET') t.strictEqual(request.url.pathname, '/captureError') t.strictEqual(request.url.search, '?foo=bar') @@ -133,7 +133,7 @@ module.exports = (moduleName) => { resetAgent() - const server = makeServer() + var server = makeServer() initServer(server, function (err) { server.stop(noop) t.error(err, 'start error') @@ -149,7 +149,7 @@ module.exports = (moduleName) => { t.plan(6) - const customError = new Error('custom error') + var customError = new Error('custom error') resetAgent() @@ -180,7 +180,7 @@ module.exports = (moduleName) => { t.plan(6) - const customError = 'custom error' + var customError = 'custom error' resetAgent() @@ -211,7 +211,7 @@ module.exports = (moduleName) => { t.plan(6) - const customError = { + var customError = { error: 'I forgot to turn this into an actual Error' } @@ -238,7 +238,7 @@ module.exports = (moduleName) => { test('server error logging with Error', function (t) { t.plan(6) - const customError = new Error('custom error') + var customError = new Error('custom error') resetAgent() @@ -262,7 +262,7 @@ module.exports = (moduleName) => { test('server error logging with Error does not affect event tags', function (t) { t.plan(8) - const customError = new Error('custom error') + var customError = new Error('custom error') resetAgent() @@ -278,7 +278,7 @@ module.exports = (moduleName) => { var server = makeServer() - const emitter = server.events || server + var emitter = server.events || server emitter.on('log', function (event, tags) { t.deepEqual(event.tags, ['error']) }) @@ -297,7 +297,7 @@ module.exports = (moduleName) => { test('server error logging with String', function (t) { t.plan(6) - const customError = 'custom error' + var customError = 'custom error' resetAgent() @@ -321,7 +321,7 @@ module.exports = (moduleName) => { test('server error logging with Object', function (t) { t.plan(6) - const customError = { + var customError = { error: 'I forgot to turn this into an actual Error' } @@ -347,7 +347,7 @@ module.exports = (moduleName) => { test('request error logging with Error', function (t) { t.plan(13) - const customError = new Error('custom error') + var customError = new Error('custom error') resetAgent(1, function (data) { assert(t, data, { status: 'HTTP 2xx', name: 'GET /error' }) @@ -392,7 +392,7 @@ module.exports = (moduleName) => { test('request error logging with Error does not affect event tags', function (t) { t.plan(15) - const customError = new Error('custom error') + var customError = new Error('custom error') resetAgent(1, function (data) { assert(t, data, { status: 'HTTP 2xx', name: 'GET /error' }) @@ -421,7 +421,7 @@ module.exports = (moduleName) => { }) }) - const emitter = server.events || server + var emitter = server.events || server emitter.on('request', function (req, event, tags) { if (event.channel === 'internal') return t.deepEqual(event.tags, ['elastic-apm', 'error']) @@ -448,7 +448,7 @@ module.exports = (moduleName) => { test('request error logging with String', function (t) { t.plan(13) - const customError = 'custom error' + var customError = 'custom error' resetAgent(1, function (data) { assert(t, data, { status: 'HTTP 2xx', name: 'GET /error' }) @@ -493,7 +493,7 @@ module.exports = (moduleName) => { test('request error logging with Object', function (t) { t.plan(13) - const customError = { + var customError = { error: 'I forgot to turn this into an actual Error' } @@ -555,7 +555,7 @@ module.exports = (moduleName) => { http.get('http://localhost:' + port + '/error', function (res) { t.strictEqual(res.statusCode, 500) res.on('data', function (chunk) { - const data = JSON.parse(chunk.toString()) + var data = JSON.parse(chunk.toString()) t.deepEqual(data, { statusCode: 500, error: 'Internal Server Error', @@ -572,7 +572,7 @@ module.exports = (moduleName) => { function makeServer (opts) { // Specify 'localhost' to avoid Hapi default of '0.0.0.0' which ties to // IPv4. We want a later HTTP client request using 'localhost' to work. - let server + var server if (semver.satisfies(pkg.version, '<17')) { server = new Hapi.Server() opts = opts || {} @@ -610,7 +610,7 @@ module.exports = (moduleName) => { } function startServer (cb) { - const server = buildServer() + var server = buildServer() runServer(server, cb) return server } @@ -618,7 +618,7 @@ module.exports = (moduleName) => { function handler (fn) { if (semver.satisfies(pkg.version, '>=17')) return fn return function (request, reply) { - const p = new Promise(function (resolve, reject) { + var p = new Promise(function (resolve, reject) { resolve(fn(request)) }) p.then(reply, reply) @@ -626,7 +626,7 @@ module.exports = (moduleName) => { } function buildServer () { - const server = makeServer() + var server = makeServer() server.route({ method: 'GET', @@ -668,7 +668,7 @@ module.exports = (moduleName) => { t.strictEqual(data.transactions.length, 1) - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, results.name) t.strictEqual(trans.type, 'request') diff --git a/test/instrumentation/modules/http/_assert.js b/test/instrumentation/modules/http/_assert.js index b1c0f7e751..cfe7d05373 100644 --- a/test/instrumentation/modules/http/_assert.js +++ b/test/instrumentation/modules/http/_assert.js @@ -12,7 +12,7 @@ function assert (t, data) { t.strictEqual(data.transactions.length, 1, 'should have one transaction') t.strictEqual(data.spans.length, 0, 'should have zero spans') - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, 'GET unknown route', 'should have expected transaction name') t.strictEqual(trans.type, 'request', 'should have expected transaction type') diff --git a/test/instrumentation/modules/http/_echo_server.js b/test/instrumentation/modules/http/_echo_server.js index de4104a389..aeaec537ce 100644 --- a/test/instrumentation/modules/http/_echo_server.js +++ b/test/instrumentation/modules/http/_echo_server.js @@ -6,20 +6,20 @@ 'use strict' -const http = require('http') -const https = require('https') -const zlib = require('zlib') +var http = require('http') +var https = require('https') +var zlib = require('zlib') -const pem = require('https-pem') +var pem = require('https-pem') process.title = 'echo-server' -const server = process.argv[2] === 'https' +var server = process.argv[2] === 'https' ? https.createServer(pem) : http.createServer() server.on('request', function (req, res) { - const acceptEncoding = req.headers['accept-encoding'] || '' + var acceptEncoding = req.headers['accept-encoding'] || '' if (/\bdeflate\b/.test(acceptEncoding)) { res.writeHead(200, { 'Content-Encoding': 'deflate' }) diff --git a/test/instrumentation/modules/http/_echo_server_util.js b/test/instrumentation/modules/http/_echo_server_util.js index 1ed259d3ed..5fd9290d24 100644 --- a/test/instrumentation/modules/http/_echo_server_util.js +++ b/test/instrumentation/modules/http/_echo_server_util.js @@ -6,18 +6,18 @@ 'use strict' -const exec = require('child_process').exec -const path = require('path') +var exec = require('child_process').exec +var path = require('path') exports.echoServer = echoServer function echoServer (type, cb) { if (typeof type === 'function') return echoServer('http', type) - const script = path.join(__dirname, '_echo_server.js') - const cp = exec(`node "${script}" ${type}`) + var script = path.join(__dirname, '_echo_server.js') + var cp = exec(`node "${script}" ${type}`) cp.stderr.pipe(process.stderr) cp.stdout.once('data', function (chunk) { - const port = chunk.trim().split('\n')[0] + var port = chunk.trim().split('\n')[0] cb(cp, port) }) } diff --git a/test/instrumentation/modules/http/aborted-requests-disabled.test.js b/test/instrumentation/modules/http/aborted-requests-disabled.test.js index c9962334db..a1bd167242 100644 --- a/test/instrumentation/modules/http/aborted-requests-disabled.test.js +++ b/test/instrumentation/modules/http/aborted-requests-disabled.test.js @@ -18,15 +18,15 @@ const agent = require('../../../..').start({ errorOnAbortedRequests: false }) -const http = require('http') +var http = require('http') -const test = require('tape') +var test = require('tape') -const mockClient = require('../../../_mock_http_client') +var mockClient = require('../../../_mock_http_client') test('client-side abort - call end', function (t) { resetAgent() - let clientReq + var clientReq t.strictEqual(agent._apmClient._writes.length, 0, 'should not have any samples to begin with') @@ -62,7 +62,7 @@ test('client-side abort - call end', function (t) { }) server.listen(function () { - const port = server.address().port + var port = server.address().port clientReq = http.get('http://localhost:' + port, function (res) { t.fail('should not call http.get callback') }) @@ -74,7 +74,7 @@ test('client-side abort - call end', function (t) { test('client-side abort - don\'t call end', function (t) { resetAgent() - let clientReq + var clientReq t.strictEqual(agent._apmClient._writes.length, 0, 'should not have any samples to begin with') @@ -94,7 +94,7 @@ test('client-side abort - don\'t call end', function (t) { }) server.listen(function () { - const port = server.address().port + var port = server.address().port clientReq = http.get('http://localhost:' + port, function (res) { t.fail('should not call http.get callback') }) @@ -106,8 +106,8 @@ test('client-side abort - don\'t call end', function (t) { test('server-side abort - call end', function (t) { resetAgent() - let timedout = false - let closeEvent = false + var timedout = false + var closeEvent = false t.strictEqual(agent._apmClient._writes.length, 0, 'should not have any samples to begin with') @@ -132,8 +132,8 @@ test('server-side abort - call end', function (t) { server.setTimeout(100) server.listen(function () { - const port = server.address().port - const clientReq = http.get('http://localhost:' + port, function (res) { + var port = server.address().port + var clientReq = http.get('http://localhost:' + port, function (res) { t.fail('should not call http.get callback') }) clientReq.on('error', function (err) { @@ -145,8 +145,8 @@ test('server-side abort - call end', function (t) { test('server-side abort - don\'t call end', function (t) { resetAgent() - let timedout = false - let closeEvent = false + var timedout = false + var closeEvent = false t.strictEqual(agent._apmClient._writes.length, 0, 'should not have any samples to begin with') @@ -167,8 +167,8 @@ test('server-side abort - don\'t call end', function (t) { server.setTimeout(100) server.listen(function () { - const port = server.address().port - const clientReq = http.get('http://localhost:' + port, function (res) { + var port = server.address().port + var clientReq = http.get('http://localhost:' + port, function (res) { t.fail('should not call http.get callback') }) clientReq.on('error', function (err) { diff --git a/test/instrumentation/modules/http/aborted-requests-enabled.test.js b/test/instrumentation/modules/http/aborted-requests-enabled.test.js index a29fe86f35..f0ca18a553 100644 --- a/test/instrumentation/modules/http/aborted-requests-enabled.test.js +++ b/test/instrumentation/modules/http/aborted-requests-enabled.test.js @@ -19,17 +19,17 @@ const agent = require('../../../..').start({ errorOnAbortedRequests: true }) -const http = require('http') +var http = require('http') -const test = require('tape') +var test = require('tape') -const assert = require('./_assert') -const mockClient = require('../../../_mock_http_client') +var assert = require('./_assert') +var mockClient = require('../../../_mock_http_client') -const addEndedTransaction = agent._instrumentation.addEndedTransaction +var addEndedTransaction = agent._instrumentation.addEndedTransaction test('client-side abort below error threshold - call end', { timeout: 10000 }, function (t) { - let clientReq + var clientReq t.plan(9) t.on('end', function () { @@ -81,7 +81,7 @@ test('client-side abort below error threshold - call end', { timeout: 10000 }, f }) server.listen(function () { - const port = server.address().port + var port = server.address().port clientReq = get('http://localhost:' + port, function (res) { t.fail('should not call http.get callback') }) @@ -92,7 +92,7 @@ test('client-side abort below error threshold - call end', { timeout: 10000 }, f }) test('client-side abort above error threshold - call end', function (t) { - let clientReq + var clientReq t.plan(10) resetAgent(function (data) { @@ -126,7 +126,7 @@ test('client-side abort above error threshold - call end', function (t) { }) server.listen(function () { - const port = server.address().port + var port = server.address().port clientReq = get('http://localhost:' + port, function (res) { t.fail('should not call http.get callback') }) @@ -137,7 +137,7 @@ test('client-side abort above error threshold - call end', function (t) { }) test('client-side abort below error threshold - don\'t call end', function (t) { - let clientReq + var clientReq resetAgent(function () { t.fail('should not send any data') }) @@ -165,7 +165,7 @@ test('client-side abort below error threshold - don\'t call end', function (t) { }) server.listen(function () { - const port = server.address().port + var port = server.address().port clientReq = get('http://localhost:' + port, function (res) { t.fail('should not call http.get callback') }) @@ -176,7 +176,7 @@ test('client-side abort below error threshold - don\'t call end', function (t) { }) test('client-side abort above error threshold - don\'t call end', function (t) { - let clientReq + var clientReq resetAgent(function () { t.fail('should not send any data') }) @@ -203,7 +203,7 @@ test('client-side abort above error threshold - don\'t call end', function (t) { }) server.listen(function () { - const port = server.address().port + var port = server.address().port clientReq = get('http://localhost:' + port, function (res) { t.fail('should not call http.get callback') }) @@ -214,8 +214,8 @@ test('client-side abort above error threshold - don\'t call end', function (t) { }) test('server-side abort below error threshold and socket closed - call end', function (t) { - let timedout = false - let ended = false + var timedout = false + var ended = false t.plan(11) resetAgent(assert.bind(null, t)) @@ -245,8 +245,8 @@ test('server-side abort below error threshold and socket closed - call end', fun server.setTimeout((agent._conf.abortedErrorThreshold * 1000) / 2) server.listen(function () { - const port = server.address().port - const clientReq = get('http://localhost:' + port, function (res) { + var port = server.address().port + var clientReq = get('http://localhost:' + port, function (res) { t.fail('should not call http.get callback') }) clientReq.on('error', function (err) { @@ -257,8 +257,8 @@ test('server-side abort below error threshold and socket closed - call end', fun }) test('server-side abort above error threshold and socket closed - call end', function (t) { - let timedout = false - let ended = false + var timedout = false + var ended = false t.plan(13) resetAgent(assert.bind(null, t)) @@ -289,8 +289,8 @@ test('server-side abort above error threshold and socket closed - call end', fun server.setTimeout((agent._conf.abortedErrorThreshold * 1000) + 10) server.listen(function () { - const port = server.address().port - const clientReq = get('http://localhost:' + port, function (res) { + var port = server.address().port + var clientReq = get('http://localhost:' + port, function (res) { t.fail('should not call http.get callback') }) clientReq.on('error', function (err) { @@ -301,8 +301,8 @@ test('server-side abort above error threshold and socket closed - call end', fun }) test('server-side abort below error threshold and socket closed - don\'t call end', function (t) { - let timedout = false - const ended = false + var timedout = false + var ended = false t.plan(3) resetAgent(function () { @@ -329,8 +329,8 @@ test('server-side abort below error threshold and socket closed - don\'t call en server.setTimeout((agent._conf.abortedErrorThreshold * 1000) / 2) server.listen(function () { - const port = server.address().port - const clientReq = get('http://localhost:' + port, function (res) { + var port = server.address().port + var clientReq = get('http://localhost:' + port, function (res) { t.fail('should not call http.get callback') }) clientReq.on('error', function (err) { @@ -341,8 +341,8 @@ test('server-side abort below error threshold and socket closed - don\'t call en }) test('server-side abort above error threshold and socket closed - don\'t call end', function (t) { - let timedout = false - const ended = false + var timedout = false + var ended = false t.plan(5) resetAgent(function () { @@ -370,8 +370,8 @@ test('server-side abort above error threshold and socket closed - don\'t call en server.setTimeout((agent._conf.abortedErrorThreshold * 1000) + 50) server.listen(function () { - const port = server.address().port - const clientReq = get('http://localhost:' + port, function (res) { + var port = server.address().port + var clientReq = get('http://localhost:' + port, function (res) { t.fail('should not call http.get callback') }) clientReq.on('error', function (err) { @@ -409,7 +409,7 @@ test('server-side abort below error threshold but socket not closed - call end', server.setTimeout((agent._conf.abortedErrorThreshold * 1000) / 2) server.listen(function () { - const port = server.address().port + var port = server.address().port get('http://localhost:' + port, function (res) { res.on('end', function () { t.strictEqual(agent._apmClient._writes.length, 1, 'should send transactions') @@ -447,7 +447,7 @@ test('server-side abort above error threshold but socket not closed - call end', server.setTimeout((agent._conf.abortedErrorThreshold * 1000) + 10) server.listen(function () { - const port = server.address().port + var port = server.address().port get('http://localhost:' + port, function (res) { res.on('end', function () { t.strictEqual(agent._apmClient._writes.length, 1, 'should send transactions') diff --git a/test/instrumentation/modules/http/basic.test.js b/test/instrumentation/modules/http/basic.test.js index f198560b49..1ab6ba8e34 100644 --- a/test/instrumentation/modules/http/basic.test.js +++ b/test/instrumentation/modules/http/basic.test.js @@ -16,13 +16,13 @@ const agent = require('../../../..').start({ spanStackTraceMinDuration: 0 // Always have span stacktraces. }) -const http = require('http') +var http = require('http') -const test = require('tape') +var test = require('tape') -const assert = require('./_assert') -const mockClient = require('../../../_mock_http_client') -const { TraceParent } = require('../../../../lib/tracecontext/traceparent') +var assert = require('./_assert') +var mockClient = require('../../../_mock_http_client') +var { TraceParent } = require('../../../../lib/tracecontext/traceparent') test('http.createServer', function (t) { t.test('direct callback', function (t) { @@ -112,8 +112,8 @@ test('new http.Server', function (t) { function sendRequest (server, timeout, useElasticHeader) { server.listen(function () { - const port = server.address().port - const context = TraceParent.startOrResume(null, { + var port = server.address().port + var context = TraceParent.startOrResume(null, { transactionSampleRate: 1.0 }) @@ -125,7 +125,7 @@ function sendRequest (server, timeout, useElasticHeader) { headers.traceparent = contextValue } - const req = http.request({ + var req = http.request({ hostname: 'localhost', port: port, path: '/', @@ -147,9 +147,9 @@ function sendRequest (server, timeout, useElasticHeader) { function onRequest (t, useElasticHeader) { return function onRequestHandler (req, res) { - const traceparent = useElasticHeader ? req.headers['elastic-apm-traceparent'] : req.headers.traceparent - const parent = TraceParent.fromString(traceparent) - const traceContext = agent.currentTransaction._context + var traceparent = useElasticHeader ? req.headers['elastic-apm-traceparent'] : req.headers.traceparent + var parent = TraceParent.fromString(traceparent) + var traceContext = agent.currentTransaction._context t.strictEqual(parent.traceId, traceContext.traceparent.traceId, 'traceContext trace id matches parent trace id') t.notEqual(parent.id, traceContext.traceparent.id, 'traceContext id does not match parent id') t.strictEqual(parent.flags, traceContext.traceparent.flags, 'traceContext flags matches parent flags') diff --git a/test/instrumentation/modules/http/bind-write-head-to-transaction.test.js b/test/instrumentation/modules/http/bind-write-head-to-transaction.test.js index 0c5d952fbb..9160b04658 100644 --- a/test/instrumentation/modules/http/bind-write-head-to-transaction.test.js +++ b/test/instrumentation/modules/http/bind-write-head-to-transaction.test.js @@ -16,29 +16,29 @@ const agent = require('../../../..').start({ spanStackTraceMinDuration: 0 // Always have span stacktraces. }) -const http = require('http') +var http = require('http') -const test = require('tape') +var test = require('tape') -const mockClient = require('../../../_mock_http_client') +var mockClient = require('../../../_mock_http_client') test('response writeHead is bound to transaction', function (t) { resetAgent(data => { t.strictEqual(data.transactions.length, 1, 'has a transaction') - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.result, 'HTTP 2xx', 'has correct result') t.end() }) - const server = http.createServer(function (req, res) { + var server = http.createServer(function (req, res) { agent._instrumentation.supersedeWithEmptyRunContext() res.end() }) server.listen(function () { - const port = server.address().port + var port = server.address().port http.get(`http://localhost:${port}`, function (res) { res.resume() res.on('end', () => { diff --git a/test/instrumentation/modules/http/github-179.test.js b/test/instrumentation/modules/http/github-179.test.js index a148f9b19b..05f69c55e5 100644 --- a/test/instrumentation/modules/http/github-179.test.js +++ b/test/instrumentation/modules/http/github-179.test.js @@ -6,35 +6,35 @@ 'use strict' -const agent = require('../../../..').start({ +var agent = require('../../../..').start({ serviceName: 'test', captureExceptions: false, metricsInterval: 0, centralConfig: false }) -const zlib = require('zlib') -const http = require('http') -const PassThrough = require('stream').PassThrough +var zlib = require('zlib') +var http = require('http') +var PassThrough = require('stream').PassThrough -const mimicResponse = require('mimic-response') -const test = require('tape') +var mimicResponse = require('mimic-response') +var test = require('tape') -const echoServer = require('./_echo_server_util').echoServer +var echoServer = require('./_echo_server_util').echoServer test('https://github.com/opbeat/opbeat-node/issues/179', function (t) { echoServer(function (cp, port) { - const opts = { + var opts = { port: port, headers: { 'Accept-Encoding': 'gzip' } } agent.startTransaction() - const req = http.request(opts, function (res) { + var req = http.request(opts, function (res) { process.nextTick(function () { - const unzip = zlib.createUnzip() - const stream = new PassThrough() + var unzip = zlib.createUnzip() + var stream = new PassThrough() // This would previously copy res.emit to the stream object which // shouldn't happen since res.emit is supposed to be on the res.prototype diff --git a/test/instrumentation/modules/http/github-423.test.js b/test/instrumentation/modules/http/github-423.test.js index c31aee7d79..e74e2fe50f 100644 --- a/test/instrumentation/modules/http/github-423.test.js +++ b/test/instrumentation/modules/http/github-423.test.js @@ -13,8 +13,8 @@ require('../../../..').start({ centralConfig: false }) -const gotVer = require('got/package.json').version -const semver = require('semver') +var gotVer = require('got/package.json').version +var semver = require('semver') if (semver.gte(gotVer, '10.0.0') && semver.lt(process.version, '10.16.0')) { // got@10 requires node v10 for JS syntax, and v10.16.0 for the added // zlib.brotliCompress. @@ -30,28 +30,28 @@ if (semver.gte(gotVer, '11.0.0') && semver.satisfies(process.version, '>=14.0.0 process.exit() } -const http = require('http') -const zlib = require('zlib') -const fs = require('fs') +var http = require('http') +var zlib = require('zlib') +var fs = require('fs') -const got = require('got') -const test = require('tape') +var got = require('got') +var test = require('tape') -const fileSize = fs.readFileSync(__filename, 'utf8').length +var fileSize = fs.readFileSync(__filename, 'utf8').length test('https://github.com/elastic/apm-agent-nodejs/issues/423', function (t) { // Start dummy remote server to fetch gzip'ed data from - const remote = http.createServer(function (req, res) { + var remote = http.createServer(function (req, res) { res.setHeader('Content-Encoding', 'gzip') fs.createReadStream(__filename).pipe(zlib.createGzip()).pipe(res) }) remote.listen(function () { - const port = remote.address().port - const url = 'http://localhost:' + port + var port = remote.address().port + var url = 'http://localhost:' + port // Start simple server that performs got-request on every request - const server = http.createServer(function (req, res) { + var server = http.createServer(function (req, res) { got(url).then(function (response) { t.strictEqual(response.body.length, fileSize, 'body should be expected size') t.ok(response.body.includes('Copyright Elasticsearch'), 'body should be uncompressed') @@ -60,8 +60,8 @@ test('https://github.com/elastic/apm-agent-nodejs/issues/423', function (t) { }) server.listen(function () { - const port = server.address().port - const url = 'http://localhost:' + port + var port = server.address().port + var url = 'http://localhost:' + port http.get(url, function (res) { res.resume() diff --git a/test/instrumentation/modules/http/ignore-url-does-not-leak-trans.test.js b/test/instrumentation/modules/http/ignore-url-does-not-leak-trans.test.js index 406c9b8c50..6d11ac6c1a 100644 --- a/test/instrumentation/modules/http/ignore-url-does-not-leak-trans.test.js +++ b/test/instrumentation/modules/http/ignore-url-does-not-leak-trans.test.js @@ -47,15 +47,15 @@ if (Number(process.versions.node.split('.')[0]) <= 8 && process.exit() } -const http = require('http') -const test = require('tape') +var http = require('http') +var test = require('tape') test('an ignored incoming http URL does not leak previous transaction', function (t) { // Start an outer transaction that should not "leak" into the server handler // for ignored URLs. - const prevTrans = apm.startTransaction('prevTrans') + var prevTrans = apm.startTransaction('prevTrans') - const server = http.createServer(function (req, res) { + var server = http.createServer(function (req, res) { t.equal(apm.currentTransaction, null, 'current transaction in ignored URL handler is null') const span = apm.startSpan('aSpan') t.ok(span === null, 'no spans are created in ignored URL handler') @@ -66,7 +66,7 @@ test('an ignored incoming http URL does not leak previous transaction', function }) server.listen(function onListen () { - const opts = { + var opts = { port: server.address().port, path: '/ignore-this-path' } diff --git a/test/instrumentation/modules/http/ignoring.test.js b/test/instrumentation/modules/http/ignoring.test.js index 7277b31e71..ebd1567fae 100644 --- a/test/instrumentation/modules/http/ignoring.test.js +++ b/test/instrumentation/modules/http/ignoring.test.js @@ -16,11 +16,11 @@ const agent = require('../../../..').start({ spanStackTraceMinDuration: 0 // Always have span stacktraces. }) -const http = require('http') +var http = require('http') -const test = require('tape') +var test = require('tape') -const mockClient = require('../../../_mock_http_client') +var mockClient = require('../../../_mock_http_client') const { WildcardMatcher } = require('../../../../lib/wildcard-matcher') @@ -137,12 +137,12 @@ function assertNoMatch (t, data) { } function request (path, headers, cb) { - const server = http.createServer(function (req, res) { + var server = http.createServer(function (req, res) { res.end() }) server.listen(function () { - const opts = { + var opts = { port: server.address().port, path: path, headers: headers diff --git a/test/instrumentation/modules/http/node-prefixed-http-require.test.js b/test/instrumentation/modules/http/node-prefixed-http-require.test.js index 3073b1e81b..dd8ba3ef1e 100644 --- a/test/instrumentation/modules/http/node-prefixed-http-require.test.js +++ b/test/instrumentation/modules/http/node-prefixed-http-require.test.js @@ -33,7 +33,7 @@ const test = require('tape') const { findObjInArray } = require('../../../_utils') test('node:http instrumentation works', function (t) { - const server = http.createServer(function (req, res) { + var server = http.createServer(function (req, res) { res.end('pong') }) diff --git a/test/instrumentation/modules/http/outgoing.test.js b/test/instrumentation/modules/http/outgoing.test.js index 9ff46bf442..1c8273535c 100644 --- a/test/instrumentation/modules/http/outgoing.test.js +++ b/test/instrumentation/modules/http/outgoing.test.js @@ -16,38 +16,38 @@ const agent = require('../../../..').start({ spanStackTraceMinDuration: 0 // Always have span stacktraces. }) -const http = require('http') -const https = require('https') +var http = require('http') +var https = require('https') const { URL } = require('url') -const endOfStream = require('end-of-stream') -const semver = require('semver') -const test = require('tape') +var endOfStream = require('end-of-stream') +var semver = require('semver') +var test = require('tape') -const echoServer = require('./_echo_server_util').echoServer -const mockClient = require('../../../_mock_http_client') -const { TraceParent } = require('../../../../lib/tracecontext/traceparent') +var echoServer = require('./_echo_server_util').echoServer +var mockClient = require('../../../_mock_http_client') +var { TraceParent } = require('../../../../lib/tracecontext/traceparent') -const methods = ['request', 'get'] +var methods = ['request', 'get'] const nodeHttpRequestSupportsSeparateUrlArg = semver.gte(process.version, '10.9.0') // // http // test('http.request(options)', echoTest('http', {}, (port, cb) => { - const options = { port } - const req = http.request(options) + var options = { port } + var req = http.request(options) req.on('response', cb) return req })) test('http.request(options, callback)', echoTest('http', {}, (port, cb) => { - const options = { port } + var options = { port } return http.request(options, cb) })) test('http: consider useElasticTraceparentHeader config option', echoTest('http', { useElasticTraceparentHeader: false }, (port, cb) => { - const options = { port } + var options = { port } return http.request(options, cb) })) @@ -87,28 +87,28 @@ test('http.request(options, callback) - aborted on data', abortTest('http', (por methods.forEach(function (name) { test(`http.${name}(urlString)`, echoTest('http', {}, (port, cb) => { - const urlString = `http://localhost:${port}` - const req = http[name](urlString) + var urlString = `http://localhost:${port}` + var req = http[name](urlString) req.on('response', cb) return req })) test(`http.${name}(urlString, callback)`, echoTest('http', {}, (port, cb) => { - const urlString = `http://localhost:${port}` + var urlString = `http://localhost:${port}` return http[name](urlString, cb) })) test(`http.${name}(urlObject)`, echoTest('http', {}, (port, cb) => { - const urlString = `http://localhost:${port}` - const urlObject = new URL(urlString) - const req = http[name](urlObject) + var urlString = `http://localhost:${port}` + var urlObject = new URL(urlString) + var req = http[name](urlObject) req.on('response', cb) return req })) test(`http.${name}(urlObject, callback)`, echoTest('http', {}, (port, cb) => { - const urlString = `http://localhost:${port}` - const urlObject = new URL(urlString) + var urlString = `http://localhost:${port}` + var urlObject = new URL(urlString) return http[name](urlObject, cb) })) }) @@ -192,51 +192,51 @@ test('http.request(..., bogusCb) errors on the bogusCb', { timeout: 5000 }, t => // https // test('https.request(options)', echoTest('https', {}, (port, cb) => { - const options = { port, rejectUnauthorized: false } - const req = https.request(options) + var options = { port, rejectUnauthorized: false } + var req = https.request(options) req.on('response', cb) return req })) test('https.request(options, callback)', echoTest('https', {}, (port, cb) => { - const options = { port, rejectUnauthorized: false } + var options = { port, rejectUnauthorized: false } return https.request(options, cb) })) test('https: consider useElasticTraceparentHeader config option', echoTest('https', { useElasticTraceparentHeader: false }, (port, cb) => { - const options = { port, rejectUnauthorized: false } + var options = { port, rejectUnauthorized: false } return https.request(options, cb) })) methods.forEach(function (name) { if (nodeHttpRequestSupportsSeparateUrlArg) { test(`https.${name}(urlString, options)`, echoTest('https', {}, (port, cb) => { - const urlString = `https://localhost:${port}` - const options = { rejectUnauthorized: false } - const req = https[name](urlString, options) + var urlString = `https://localhost:${port}` + var options = { rejectUnauthorized: false } + var req = https[name](urlString, options) req.on('response', cb) return req })) test(`https.${name}(urlString, options, callback)`, echoTest('https', {}, (port, cb) => { - const urlString = `https://localhost:${port}` - const options = { rejectUnauthorized: false } + var urlString = `https://localhost:${port}` + var options = { rejectUnauthorized: false } return https[name](urlString, options, cb) })) test(`https.${name}(urlObject, options)`, echoTest('https', {}, (port, cb) => { - const urlString = `https://localhost:${port}` - const urlObject = new URL(urlString) - const options = { rejectUnauthorized: false } - const req = https[name](urlObject, options) + var urlString = `https://localhost:${port}` + var urlObject = new URL(urlString) + var options = { rejectUnauthorized: false } + var req = https[name](urlObject, options) req.on('response', cb) return req })) test(`https.${name}(urlObject, options, callback)`, echoTest('https', {}, (port, cb) => { - const urlString = `https://localhost:${port}` - const urlObject = new URL(urlString) - const options = { rejectUnauthorized: false } + var urlString = `https://localhost:${port}` + var urlObject = new URL(urlString) + var options = { rejectUnauthorized: false } return https[name](urlObject, options, cb) })) } @@ -272,15 +272,15 @@ function echoTest (type, opts, handler) { cp.kill() }) - const trans = agent.startTransaction() - const req = handler(port, res => { + var trans = agent.startTransaction() + var req = handler(port, res => { res.on('end', function () { agent.endTransaction() }) res.resume() }) - const traceparent = req.getHeader('traceparent') + var traceparent = req.getHeader('traceparent') t.ok(traceparent, 'should have traceparent header') if (opts && opts.useElasticTraceparentHeader === false) { t.strictEqual(req.getHeader('elastic-apm-traceparent'), undefined) @@ -288,8 +288,8 @@ function echoTest (type, opts, handler) { t.ok(req.getHeader('elastic-apm-traceparent'), 'should have elastic-apm-traceparent header') } - const expected = TraceParent.fromString(trans._context.toString()) - const received = TraceParent.fromString(traceparent) + var expected = TraceParent.fromString(trans._context.toString()) + var received = TraceParent.fromString(traceparent) t.strictEqual(received.version, expected.version, 'traceparent header has matching version') t.strictEqual(received.traceId, expected.traceId, 'traceparent header has matching traceId') t.ok(/^[\da-f]{16}$/.test(expected.id), 'traceparent header has valid id') diff --git a/test/instrumentation/modules/http/request.test.js b/test/instrumentation/modules/http/request.test.js index 4881506a13..197fd66756 100644 --- a/test/instrumentation/modules/http/request.test.js +++ b/test/instrumentation/modules/http/request.test.js @@ -16,24 +16,24 @@ const agent = require('../../../..').start({ spanStackTraceMinDuration: 0 // Always have span stacktraces. }) -const http = require('http') +var http = require('http') -const test = require('tape') -const express = require('express') -const request = require('request') +var test = require('tape') +var express = require('express') +var request = require('request') -const mockClient = require('../../../_mock_http_client') -const findObjInArray = require('../../../_utils').findObjInArray +var mockClient = require('../../../_mock_http_client') +var findObjInArray = require('../../../_utils').findObjInArray test('request', function (t) { resetAgent(function (data) { t.strictEqual(data.transactions.length, 2) t.strictEqual(data.spans.length, 1) - const sub = data.transactions[0] + var sub = data.transactions[0] t.strictEqual(sub.name, 'GET /test') - const root = data.transactions[1] + var root = data.transactions[1] t.strictEqual(root.name, 'GET /') t.strictEqual(root.outcome, 'success') const span = findObjInArray(data.spans, 'transaction_id', root.id) @@ -44,7 +44,7 @@ test('request', function (t) { t.end() }) - const app = express() + var app = express() var server = http.createServer(app) app.get('/test', (req, res) => { @@ -63,7 +63,7 @@ test('Outcome', function (t) { t.strictEqual(data.transactions.length, 2) t.strictEqual(data.spans.length, 1) - const root = data.transactions[1] + var root = data.transactions[1] t.strictEqual(root.name, 'GET /') t.strictEqual(root.outcome, 'failure') const span = findObjInArray(data.spans, 'transaction_id', root.id) @@ -74,7 +74,7 @@ test('Outcome', function (t) { t.end() }) - const app = express() + var app = express() var server = http.createServer(app) app.get('/test', (req, res) => { @@ -96,8 +96,8 @@ function resetAgent (cb) { function sendRequest (server, timeout) { server.listen(function () { - const port = server.address().port - const req = http.get('http://localhost:' + port, function (res) { + var port = server.address().port + var req = http.get('http://localhost:' + port, function (res) { if (timeout) throw new Error('should not get to here') res.resume() }) diff --git a/test/instrumentation/modules/http/sse.test.js b/test/instrumentation/modules/http/sse.test.js index 556ee00c9b..741e390103 100644 --- a/test/instrumentation/modules/http/sse.test.js +++ b/test/instrumentation/modules/http/sse.test.js @@ -16,11 +16,11 @@ const agent = require('../../../..').start({ spanStackTraceMinDuration: 0 // Always have span stacktraces. }) -const http = require('http') +var http = require('http') -const test = require('tape') +var test = require('tape') -const mockClient = require('../../../_mock_http_client') +var mockClient = require('../../../_mock_http_client') test('normal response', function (t) { resetAgent(2, function (data) { @@ -28,8 +28,8 @@ test('normal response', function (t) { t.end() }) - const server = http.createServer(function (req, res) { - const span = agent.startSpan('foo', 'bar') + var server = http.createServer(function (req, res) { + var span = agent.startSpan('foo', 'bar') setTimeout(function () { if (span) span.end() res.end() @@ -45,9 +45,9 @@ test('SSE response with explicit headers', function (t) { t.end() }) - const server = http.createServer(function (req, res) { + var server = http.createServer(function (req, res) { res.writeHead(200, { 'Content-Type': 'text/event-stream' }) - const span = agent.startSpan('foo', 'bar') + var span = agent.startSpan('foo', 'bar') setTimeout(function () { if (span) span.end() res.end() @@ -63,10 +63,10 @@ test('SSE response with implicit headers', function (t) { t.end() }) - const server = http.createServer(function (req, res) { + var server = http.createServer(function (req, res) { res.setHeader('Content-type', 'text/event-stream; foo') res.write('data: hello world\n\n') - const span = agent.startSpan('foo', 'bar') + var span = agent.startSpan('foo', 'bar') setTimeout(function () { if (span) span.end() res.end() @@ -80,8 +80,8 @@ function assertNonSSEResponse (t, data) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 1) - const trans = data.transactions[0] - const span = data.spans[0] + var trans = data.transactions[0] + var span = data.spans[0] t.strictEqual(trans.name, 'GET unknown route') t.strictEqual(trans.context.request.method, 'GET') @@ -93,7 +93,7 @@ function assertSSEResponse (t, data) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 0) - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, 'GET unknown route') t.strictEqual(trans.context.request.method, 'GET') @@ -101,7 +101,7 @@ function assertSSEResponse (t, data) { function request (server) { server.listen(function () { - const port = server.address().port + var port = server.address().port http.request({ port: port }, function (res) { res.on('end', function () { server.close() diff --git a/test/instrumentation/modules/http2.test.js b/test/instrumentation/modules/http2.test.js index bdf2700731..e2b549fabb 100644 --- a/test/instrumentation/modules/http2.test.js +++ b/test/instrumentation/modules/http2.test.js @@ -6,25 +6,25 @@ 'use strict' -const agent = require('../../..').start({ +var agent = require('../../..').start({ serviceName: 'test', captureExceptions: false, metricsInterval: 0, centralConfig: false, cloudProvider: 'none' }) -const ins = agent._instrumentation +var ins = agent._instrumentation -const fs = require('fs') -const https = require('https') -const http2 = require('http2') +var fs = require('fs') +var https = require('https') +var http2 = require('http2') -const semver = require('semver') -const pem = require('https-pem') -const test = require('tape') +var semver = require('semver') +var pem = require('https-pem') +var test = require('tape') -const mockClient = require('../../_mock_http_client') -const findObjInArray = require('../../_utils').findObjInArray +var mockClient = require('../../_mock_http_client') +var findObjInArray = require('../../_utils').findObjInArray const constants = require('../../../lib/constants') if (semver.satisfies(process.version, '8.x')) { @@ -32,9 +32,9 @@ if (semver.satisfies(process.version, '8.x')) { process.exit() } -const isSecure = [false, true] +var isSecure = [false, true] isSecure.forEach(secure => { - const method = secure ? 'createSecureServer' : 'createServer' + var method = secure ? 'createSecureServer' : 'createServer' test(`http2.${method} compatibility mode`, t => { t.plan(16) @@ -49,7 +49,7 @@ isSecure.forEach(secure => { }) function onRequest (req, res) { - const trans = ins.currTransaction() + var trans = ins.currTransaction() t.ok(trans, 'have current transaction') t.strictEqual(trans.type, 'request') @@ -59,22 +59,22 @@ isSecure.forEach(secure => { res.end('foo') } - let port + var port var server = secure ? http2.createSecureServer(pem, onRequest) : http2.createServer(onRequest) - const onError = err => t.error(err) + var onError = err => t.error(err) server.on('error', onError) server.on('socketError', onError) server.listen(() => { port = server.address().port - const client = connect(secure, port) + var client = connect(secure, port) client.on('error', onError) client.on('socketError', onError) - const req = client.request({ ':path': '/' }) + var req = client.request({ ':path': '/' }) assertResponse(t, req, 'foo') req.resume() req.on('end', () => client.destroy()) @@ -90,17 +90,17 @@ isSecure.forEach(secure => { server.close() }) - let port + var port var server = secure ? http2.createSecureServer(pem) : http2.createServer() - const onError = err => t.error(err) + var onError = err => t.error(err) server.on('error', onError) server.on('socketError', onError) server.on('stream', function (stream, headers) { - const trans = ins.currTransaction() + var trans = ins.currTransaction() t.ok(trans, 'have current transaction') t.strictEqual(trans.type, 'request') @@ -113,11 +113,11 @@ isSecure.forEach(secure => { server.listen(() => { port = server.address().port - const client = connect(secure, port) + var client = connect(secure, port) client.on('error', onError) client.on('socketError', onError) - const req = client.request({ ':path': '/' }) + var req = client.request({ ':path': '/' }) assertResponse(t, req, 'foo') req.resume() req.on('end', () => client.destroy()) @@ -133,17 +133,17 @@ isSecure.forEach(secure => { server.close() }) - let port + var port var server = secure ? http2.createSecureServer(pem) : http2.createServer() - const onError = err => t.error(err) + var onError = err => t.error(err) server.on('error', onError) server.on('socketError', onError) server.on('stream', function (stream, headers) { - const trans = ins.currTransaction() + var trans = ins.currTransaction() t.ok(trans, 'have current transaction') t.strictEqual(trans.type, 'request') @@ -163,11 +163,11 @@ isSecure.forEach(secure => { server.listen(() => { port = server.address().port - const client = connect(secure, port) + var client = connect(secure, port) client.on('error', onError) client.on('socketError', onError) - const req = client.request({ ':path': '/' }) + var req = client.request({ ':path': '/' }) assertResponse(t, req, '') // Do not expect 'foo' to get through. req.resume() req.on('end', () => client.destroy()) @@ -183,17 +183,17 @@ isSecure.forEach(secure => { server.close() }) - let port + var port var server = secure ? http2.createSecureServer(pem) : http2.createServer() - const onError = err => t.error(err) + var onError = err => t.error(err) server.on('error', onError) server.on('socketError', onError) server.on('stream', function (stream, headers) { - const trans = ins.currTransaction() + var trans = ins.currTransaction() t.ok(trans, 'have current transaction') t.strictEqual(trans.type, 'request') @@ -213,11 +213,11 @@ isSecure.forEach(secure => { server.listen(() => { port = server.address().port - const client = connect(secure, port) + var client = connect(secure, port) client.on('error', onError) client.on('socketError', onError) - const req = client.request({ ':path': '/' }) + var req = client.request({ ':path': '/' }) assertResponse(t, req, fs.readFileSync(__filename).toString()) req.resume() req.on('end', () => client.destroy()) @@ -233,17 +233,17 @@ isSecure.forEach(secure => { server.close() }) - let port + var port var server = secure ? http2.createSecureServer(pem) : http2.createServer() - const onError = err => t.error(err) + var onError = err => t.error(err) server.on('error', onError) server.on('socketError', onError) server.on('stream', function (stream, headers) { - const trans = ins.currTransaction() + var trans = ins.currTransaction() t.ok(trans, 'have current transaction') t.strictEqual(trans.type, 'request') @@ -255,11 +255,11 @@ isSecure.forEach(secure => { server.listen(() => { port = server.address().port - const client = connect(secure, port) + var client = connect(secure, port) client.on('error', onError) client.on('socketError', onError) - const req = client.request({ ':path': '/' }) + var req = client.request({ ':path': '/' }) assertResponse(t, req, fs.readFileSync(__filename).toString()) req.resume() req.on('end', () => client.destroy()) @@ -270,7 +270,7 @@ isSecure.forEach(secure => { test(`http2.${method} ignore push streams`, t => { addShouldCall(t) - const done = after(3, () => { + var done = after(3, () => { client.destroy() t.end() }) @@ -281,18 +281,18 @@ isSecure.forEach(secure => { done() }) - let port - let client + var port + var client var server = secure ? http2.createSecureServer(pem) : http2.createServer() - const onError = err => t.error(err) + var onError = err => t.error(err) server.on('error', onError) server.on('socketError', onError) server.on('stream', function (stream, headers) { - const trans = ins.currTransaction() + var trans = ins.currTransaction() t.ok(trans, 'have current transaction') t.strictEqual(trans.type, 'request') @@ -333,7 +333,7 @@ isSecure.forEach(secure => { assertResponse(t, stream, 'some pushed data', done) })) - const req = client.request({ ':path': '/' }) + var req = client.request({ ':path': '/' }) assertResponse(t, req, 'foo') req.end() }) @@ -346,13 +346,13 @@ isSecure.forEach(secure => { t.strictEqual(data.transactions.length, 2) t.strictEqual(data.spans.length, 1) - const sub = data.transactions[0] + var sub = data.transactions[0] assertPath(t, sub, secure, port, '/sub', '2.0') - const root = data.transactions[1] + var root = data.transactions[1] assertPath(t, root, secure, port, '/', '2.0') - const span = findObjInArray(data.spans, 'transaction_id', root.id) + var span = findObjInArray(data.spans, 'transaction_id', root.id) t.ok(span, 'root transaction should have span') t.strictEqual(span.type, 'external') t.strictEqual(span.subtype, 'http') @@ -380,22 +380,22 @@ isSecure.forEach(secure => { server.close() }) - let port + var port var server = secure ? http2.createSecureServer(pem) : http2.createServer() - const onError = err => t.error(err) + var onError = err => t.error(err) server.on('error', onError) server.on('socketError', onError) server.on('stream', function (stream, headers) { - const trans = ins.currTransaction() + var trans = ins.currTransaction() t.ok(trans, 'have current transaction') t.strictEqual(trans.type, 'request') if (headers[':path'] === '/') { - const client = connect(secure, port) + var client = connect(secure, port) client.on('error', onError) client.on('socketError', onError) @@ -404,7 +404,7 @@ isSecure.forEach(secure => { ':status': 200 }) - const req = client.request({ ':path': '/sub' }) + var req = client.request({ ':path': '/sub' }) t.ok(agent.currentSpan === null, 'the http2 span should not spill into user code') req.on('end', () => { t.ok(agent.currentSpan === null, 'the http2 span should *not* be the currentSpan in user event handlers') @@ -422,11 +422,11 @@ isSecure.forEach(secure => { server.listen(() => { port = server.address().port - const client = connect(secure, port) + var client = connect(secure, port) client.on('error', onError) client.on('socketError', onError) - const req = client.request({ ':path': '/' }) + var req = client.request({ ':path': '/' }) assertResponse(t, req, 'foo') req.resume() req.on('end', () => client.destroy()) @@ -446,11 +446,11 @@ test('handling HTTP/1.1 request to http2.createSecureServer with allowHTTP1:true tx = data.transactions[0] }) - let port - const serverOpts = Object.assign({ allowHTTP1: true }, pem) - const server = http2.createSecureServer(serverOpts) + var port + var serverOpts = Object.assign({ allowHTTP1: true }, pem) + var server = http2.createSecureServer(serverOpts) server.on('request', function onRequest (req, res) { - const trans = ins.currTransaction() + var trans = ins.currTransaction() t.ok(trans, 'have current transaction') t.strictEqual(trans.type, 'request') res.writeHead(200, { 'content-type': 'text/plain' }) @@ -463,7 +463,7 @@ test('handling HTTP/1.1 request to http2.createSecureServer with allowHTTP1:true port = server.address().port // Make an HTTP/1.1 request. - const getOpts = { + var getOpts = { agent: new https.Agent(), protocol: 'https:', host: 'localhost', @@ -472,7 +472,7 @@ test('handling HTTP/1.1 request to http2.createSecureServer with allowHTTP1:true ALPNProtocols: ['http/1.1'], rejectUnauthorized: false } - const req = https.get(getOpts, function (res) { + var req = https.get(getOpts, function (res) { assertResponse(t, res, 'foo', function () { // Assert the APM transaction is as expected for an HTTP/1.x request. t.ok(tx, 'got the transaction') @@ -488,7 +488,7 @@ test('handling HTTP/1.1 request to http2.createSecureServer with allowHTTP1:true }) }) -const matchId = /^[\da-f]{16}$/ +var matchId = /^[\da-f]{16}$/ function assertPath (t, trans, secure, port, path, httpVersion) { t.ok(trans) @@ -593,7 +593,7 @@ function assert (t, data, secure, port) { // Top-level props of the transaction need to be checked individually // because there are a few dynamic properties - const trans = data.transactions[0] + var trans = data.transactions[0] assertPath(t, trans, secure, port, '/', '2.0') } @@ -609,8 +609,8 @@ function assertResponse (t, stream, expected, done) { } function connect (secure, port) { - const proto = secure ? 'https' : 'http' - const opts = { rejectUnauthorized: false } + var proto = secure ? 'https' : 'http' + var opts = { rejectUnauthorized: false } return http2.connect(`${proto}://localhost:${port}`, opts) } @@ -621,18 +621,18 @@ function resetAgent (expected, cb) { } function addShouldCall (t) { - const calls = [] - const realEnd = t.end + var calls = [] + var realEnd = t.end t.end = function end () { - for (let i = 0; i < calls.length; i++) { + for (var i = 0; i < calls.length; i++) { t.strictEqual(calls[i].called, true, 'should have called function') } return realEnd.apply(this, arguments) } t.shouldCall = function shouldCall (fn) { - const record = { called: false } + var record = { called: false } calls.push(record) return function shouldCallWrap () { record.called = true diff --git a/test/instrumentation/modules/ioredis.test.js b/test/instrumentation/modules/ioredis.test.js index 2309811a7f..aab52d3d0a 100644 --- a/test/instrumentation/modules/ioredis.test.js +++ b/test/instrumentation/modules/ioredis.test.js @@ -11,7 +11,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -const agent = require('../../..').start({ +var agent = require('../../..').start({ serviceName: 'test-ioredis', captureExceptions: false, metricsInterval: 0, @@ -20,27 +20,27 @@ const agent = require('../../..').start({ spanCompressionEnabled: false }) -const ioredisVer = require('ioredis/package.json').version -const semver = require('semver') +var ioredisVer = require('ioredis/package.json').version +var semver = require('semver') if (semver.gte(ioredisVer, '5.0.0') && semver.lt(process.version, '12.22.0')) { console.log(`# SKIP ioredis@${ioredisVer} does not support node ${process.version}`) process.exit() } -const Redis = require('ioredis') -const test = require('tape') +var Redis = require('ioredis') +var test = require('tape') -const findObjInArray = require('../../_utils').findObjInArray -const mockClient = require('../../_mock_http_client') +var findObjInArray = require('../../_utils').findObjInArray +var mockClient = require('../../_mock_http_client') test('not nested', function (t) { resetAgent(done(t)) - const redis = new Redis(process.env.REDIS_HOST) + var redis = new Redis(process.env.REDIS_HOST) agent.startTransaction('foo', 'bar') - let calls = 0 + var calls = 0 redis.flushall(function (err, reply) { t.error(err) @@ -79,14 +79,14 @@ test('not nested', function (t) { test('nested', function (t) { resetAgent(done(t)) - const redis = new Redis(process.env.REDIS_HOST) + var redis = new Redis(process.env.REDIS_HOST) agent.startTransaction('foo', 'bar') redis.flushall(function (err, reply) { t.error(err) t.strictEqual(reply, 'OK') - let calls = 0 + var calls = 0 redis.set('foo', 'bar') redis.get('foo', function (err, result) { @@ -142,7 +142,7 @@ test('error capture, no unhandledRejection on command error is introduced', func }, 0) }) - const redis = new Redis(process.env.REDIS_HOST) + var redis = new Redis(process.env.REDIS_HOST) const trans = agent.startTransaction('foo', 'bar') redis.hset('a', 'b', 'c') redis.get('a', function (err, result) { @@ -155,7 +155,7 @@ test('error capture, no unhandledRejection on command error is introduced', func function done (t) { return function (data, cb) { - const groups = [ + var groups = [ 'FLUSHALL', 'SET', 'GET', @@ -169,7 +169,7 @@ function done (t) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, groups.length) - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, 'foo') t.strictEqual(trans.type, 'bar') diff --git a/test/instrumentation/modules/koa-router/shared.js b/test/instrumentation/modules/koa-router/shared.js index e4f9863506..c921d2e79e 100644 --- a/test/instrumentation/modules/koa-router/shared.js +++ b/test/instrumentation/modules/koa-router/shared.js @@ -7,7 +7,7 @@ 'use strict' module.exports = (moduleName) => { - const agent = require('../../../..').start({ + var agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -25,14 +25,14 @@ module.exports = (moduleName) => { process.exit() } - const http = require('http') + var http = require('http') - const Koa = require('koa') - const test = require('tape') + var Koa = require('koa') + var test = require('tape') - const Router = require(moduleName) + var Router = require(moduleName) - const mockClient = require('../../../_mock_http_client') + var mockClient = require('../../../_mock_http_client') test('route naming', function (t) { t.plan(8) @@ -107,7 +107,7 @@ module.exports = (moduleName) => { }) function startServer (cb) { - const server = buildServer() + var server = buildServer() server.listen(function () { cb(server.address().port) }) @@ -115,10 +115,10 @@ module.exports = (moduleName) => { } function buildServer () { - const app = new Koa() - const router = new Router() - const parentRouter = new Router() - const childRouter = new Router({ + var app = new Koa() + var router = new Router() + var parentRouter = new Router() + var childRouter = new Router({ prefix: '/prefix2' }) @@ -152,7 +152,7 @@ module.exports = (moduleName) => { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 0) - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, results.name) t.strictEqual(trans.type, 'request') diff --git a/test/instrumentation/modules/memcached.test.js b/test/instrumentation/modules/memcached.test.js index 69876cdaf3..fa2b0b49ad 100644 --- a/test/instrumentation/modules/memcached.test.js +++ b/test/instrumentation/modules/memcached.test.js @@ -12,7 +12,7 @@ if (process.platform === 'win32') { process.exit() } -const agent = require('../../..').start({ +var agent = require('../../..').start({ serviceName: 'test-memcached', captureExceptions: false, metricsInterval: '0s', @@ -21,10 +21,10 @@ const agent = require('../../..').start({ spanCompressionEnabled: false }) -const test = require('tape') -const mockClient = require('../../_mock_http_client') +var test = require('tape') +var mockClient = require('../../_mock_http_client') -const host = process.env.MEMCACHED_HOST || '127.0.0.1' +var host = process.env.MEMCACHED_HOST || '127.0.0.1' test('memcached', function (t) { resetAgent(function (data) { @@ -86,8 +86,8 @@ test('memcached', function (t) { t.end() }) - const Memcached = require('memcached') - const cache = new Memcached(`${host}:11211`, { timeout: 500 }) + var Memcached = require('memcached') + var cache = new Memcached(`${host}:11211`, { timeout: 500 }) agent.startTransaction('myTrans') cache.set('foo', 'bar', 300, (err) => { t.ok(agent.currentSpan === null, 'memcached span should not be currentSpan in callback') diff --git a/test/instrumentation/modules/mimic-response.test.js b/test/instrumentation/modules/mimic-response.test.js index 9f5c5d5fd7..cf927f76d5 100644 --- a/test/instrumentation/modules/mimic-response.test.js +++ b/test/instrumentation/modules/mimic-response.test.js @@ -11,18 +11,18 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -const agent = require('../../..').start({ +var agent = require('../../..').start({ serviceName: 'test', captureExceptions: false, metricsInterval: 0, centralConfig: false }) -const stream = require('stream') -const mimicResponse = require('mimic-response') -const test = require('tape') +var stream = require('stream') +var mimicResponse = require('mimic-response') +var test = require('tape') -const cases = [ +var cases = [ { name: 'none bound', source: false, target: false }, { name: 'source bound', source: true, target: false }, { name: 'target bound', source: false, target: true }, diff --git a/test/instrumentation/modules/mongodb-core.test.js b/test/instrumentation/modules/mongodb-core.test.js index bc045aaf8c..f2bdb63e40 100644 --- a/test/instrumentation/modules/mongodb-core.test.js +++ b/test/instrumentation/modules/mongodb-core.test.js @@ -11,7 +11,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -const agent = require('../../..').start({ +var agent = require('../../..').start({ serviceName: 'test-mongodb-core', captureExceptions: false, metricsInterval: 0, @@ -20,19 +20,19 @@ const agent = require('../../..').start({ spanCompressionEnabled: false }) -const Server = require('mongodb-core').Server -const semver = require('semver') -const test = require('tape') -const mongodbCoreVersion = require('mongodb-core/package').version +var Server = require('mongodb-core').Server +var semver = require('semver') +var test = require('tape') +var mongodbCoreVersion = require('mongodb-core/package').version -const mockClient = require('../../_mock_http_client') +var mockClient = require('../../_mock_http_client') test('instrument simple command', function (t) { // Because a variable number of events to the APM server is possible (see // the "Note ... additional spans" below), we cannot use the 'expected' arg // to `mockClient` here. resetAgent(function (data) { - const expectedSpanNamesInOrder = [ + var expectedSpanNamesInOrder = [ 'system.$cmd.ismaster', 'elasticapm.test.insert', 'elasticapm.test.update', @@ -42,7 +42,7 @@ test('instrument simple command', function (t) { ] t.strictEqual(data.transactions.length, 1) - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, 'foo', 'transaction.name') t.strictEqual(trans.type, 'bar', 'transaction.type') t.strictEqual(trans.result, 'success', 'transaction.result') @@ -61,7 +61,7 @@ test('instrument simple command', function (t) { // `contextManager != "patch"`. // - mongodb-core@1.x includes `elasticapm.$cmd.command` spans after the // insert, update, and remove commands. - for (let i = 0; i < data.spans.length; i++) { + for (var i = 0; i < data.spans.length; i++) { const span = data.spans[i] if (semver.lt(mongodbCoreVersion, '2.0.0')) { if (span.name === 'admin.$cmd.ismaster' && i === 0) { @@ -82,7 +82,7 @@ test('instrument simple command', function (t) { t.strictEqual(span.subtype, 'mongodb', 'span has expected subtype') t.strictEqual(span.action, 'query', 'span has expected action') t.strictEqual(span.parent_id, trans.id, 'span is a direct child of transaction') - const offset = span.timestamp - trans.timestamp + var offset = span.timestamp - trans.timestamp t.ok(offset + span.duration * 1000 < trans.duration * 1000, `span ends (${span.timestamp / 1000 + span.duration}ms) before the transaction (${trans.timestamp / 1000 + trans.duration}ms)`) const dbInstance = expectedSpanNamesInOrder[0].slice(0, expectedSpanNamesInOrder[0].lastIndexOf('.')) @@ -110,7 +110,7 @@ test('instrument simple command', function (t) { t.end() }) - const server = new Server({ host: process.env.MONGODB_HOST }) + var server = new Server({ host: process.env.MONGODB_HOST }) agent.startTransaction('foo', 'bar') @@ -132,7 +132,7 @@ test('instrument simple command', function (t) { t.error(err, 'no error from remove') t.strictEqual(results.result.n, 1) - const cursor = _server.cursor('elasticapm.test', { find: 'elasticapm.test', query: {} }) + var cursor = _server.cursor('elasticapm.test', { find: 'elasticapm.test', query: {} }) cursor.next(function (err, doc) { t.error(err, 'no error from cursor.next') t.strictEqual(doc.a, 2, 'doc.a') diff --git a/test/instrumentation/modules/mysql/_utils.js b/test/instrumentation/modules/mysql/_utils.js index 27cac2caa9..de0741d3c7 100644 --- a/test/instrumentation/modules/mysql/_utils.js +++ b/test/instrumentation/modules/mysql/_utils.js @@ -6,12 +6,12 @@ 'use strict' -const mysql = require('mysql') +var mysql = require('mysql') exports.reset = reset exports.credentials = credentials -const DEFAULTS = { +var DEFAULTS = { host: process.env.MYSQL_HOST || 'localhost', user: process.env.MYSQL_USER || 'root', password: process.env.MYSQL_PASSWORD, @@ -27,7 +27,7 @@ function credentials (conf) { } function reset (cb) { - const client = mysql.createConnection(credentials({ database: 'mysql' })) + var client = mysql.createConnection(credentials({ database: 'mysql' })) client.connect(function (err) { if (err) throw err diff --git a/test/instrumentation/modules/mysql/mysql.test.js b/test/instrumentation/modules/mysql/mysql.test.js index 1913837caa..bd63205649 100644 --- a/test/instrumentation/modules/mysql/mysql.test.js +++ b/test/instrumentation/modules/mysql/mysql.test.js @@ -11,7 +11,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -const agent = require('../../../..').start({ +var agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -20,18 +20,18 @@ const agent = require('../../../..').start({ spanCompressionEnabled: false }) -const mysql = require('mysql') -const mysqlVersion = require('mysql/package.json').version -const semver = require('semver') -const test = require('tape') +var mysql = require('mysql') +var mysqlVersion = require('mysql/package.json').version +var semver = require('semver') +var test = require('tape') -const utils = require('./_utils') -const mockClient = require('../../../_mock_http_client') -const findObjInArray = require('../../../_utils').findObjInArray +var utils = require('./_utils') +var mockClient = require('../../../_mock_http_client') +var findObjInArray = require('../../../_utils').findObjInArray -let queryable -const connectionOptions = utils.credentials() -const factories = [ +var queryable +var connectionOptions = utils.credentials() +var factories = [ [createConnection, 'connection'], [createPool, 'pool'], [createPoolAndGetConnection, 'pool > connection'], @@ -40,16 +40,16 @@ const factories = [ ] factories.forEach(function (f) { - const factory = f[0] - const type = f[1] + var factory = f[0] + var type = f[1] // Prior to mysql v2.4 pool.query would not return a Query object. // See: https://github.com/mysqljs/mysql/pull/830 - const skipStreamTest = type === 'pool' && semver.satisfies(mysqlVersion, '<2.4.0') + var skipStreamTest = type === 'pool' && semver.satisfies(mysqlVersion, '<2.4.0') // Prior to mysql v2.2 pool.query required a callback. // See: https://github.com/mysqljs/mysql/pull/585 - const skipNoCallbackTest = type === 'pool' && semver.satisfies(mysqlVersion, '<2.2.0') + var skipNoCallbackTest = type === 'pool' && semver.satisfies(mysqlVersion, '<2.2.0') test('mysql.' + factory.name, function (t) { t.on('end', teardown) @@ -114,7 +114,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + 1 AS solution' factory(function () { agent.startTransaction('foo') - const query = mysql.createQuery(sql, basicQueryCallback(t)) + var query = mysql.createQuery(sql, basicQueryCallback(t)) queryable.query(query) t.equal(agent.currentSpan, null, 'mysql span should not bleed into calling code') }) @@ -128,7 +128,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + ? AS solution' factory(function () { agent.startTransaction('foo') - const query = mysql.createQuery(sql, [1], basicQueryCallback(t)) + var query = mysql.createQuery(sql, [1], basicQueryCallback(t)) queryable.query(query) t.equal(agent.currentSpan, null, 'mysql span should not bleed into calling code') }) @@ -143,7 +143,7 @@ factories.forEach(function (f) { }) var sql = 'SELECT 1 + 1 AS solution' factory(function () { - const trans = agent.startTransaction('foo') + var trans = agent.startTransaction('foo') queryable.query(sql) t.equal(agent.currentSpan, null, 'mysql span should not bleed into calling code') setTimeout(function () { @@ -164,7 +164,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + 1 AS solution' factory(function () { agent.startTransaction('foo') - const stream = queryable.query(sql) + var stream = queryable.query(sql) t.equal(agent.currentSpan, null, 'mysql span should not bleed into calling code') basicQueryStream(stream, t) }) @@ -178,7 +178,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + ? AS solution' factory(function () { agent.startTransaction('foo') - const stream = queryable.query(sql, [1]) + var stream = queryable.query(sql, [1]) t.equal(agent.currentSpan, null, 'mysql span should not bleed into calling code') basicQueryStream(stream, t) }) @@ -192,7 +192,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + 1 AS solution' factory(function () { agent.startTransaction('foo') - const stream = queryable.query({ sql: sql }) + var stream = queryable.query({ sql: sql }) t.equal(agent.currentSpan, null, 'mysql span should not bleed into calling code') basicQueryStream(stream, t) }) @@ -206,7 +206,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + ? AS solution' factory(function () { agent.startTransaction('foo') - const stream = queryable.query({ sql: sql }, [1]) + var stream = queryable.query({ sql: sql }, [1]) t.equal(agent.currentSpan, null, 'mysql span should not bleed into calling code') basicQueryStream(stream, t) }) @@ -220,8 +220,8 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + 1 AS solution' factory(function () { agent.startTransaction('foo') - const query = mysql.createQuery(sql) - const stream = queryable.query(query) + var query = mysql.createQuery(sql) + var stream = queryable.query(query) t.equal(agent.currentSpan, null, 'mysql span should not bleed into calling code') basicQueryStream(stream, t) }) @@ -235,8 +235,8 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + ? AS solution' factory(function () { agent.startTransaction('foo') - const query = mysql.createQuery(sql, [1]) - const stream = queryable.query(query) + var query = mysql.createQuery(sql, [1]) + var stream = queryable.query(query) t.equal(agent.currentSpan, null, 'mysql span should not bleed into calling code') basicQueryStream(stream, t) }) @@ -249,7 +249,7 @@ factories.forEach(function (f) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 3) - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, 'foo') @@ -264,8 +264,8 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + ? AS solution' factory(function () { - let n = 0 - const trans = agent.startTransaction('foo') + var n = 0 + var trans = agent.startTransaction('foo') queryable.query(sql, [1], function (err, rows, fields) { t.error(err) @@ -294,7 +294,7 @@ factories.forEach(function (f) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 3) - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, 'foo') @@ -309,8 +309,8 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + ? AS solution' createPool(function () { - let n = 0 - const trans = agent.startTransaction('foo') + var n = 0 + var trans = agent.startTransaction('foo') queryable.getConnection(function (err, conn) { t.error(err) @@ -348,7 +348,7 @@ factories.forEach(function (f) { resetAgent(6, function (data) { t.strictEqual(data.transactions.length, 3) t.strictEqual(data.spans.length, 3) - const names = data.transactions.map(function (trans) { + var names = data.transactions.map(function (trans) { return trans.name }).sort() t.deepEqual(names, ['bar', 'baz', 'foo']) @@ -366,7 +366,7 @@ factories.forEach(function (f) { factory(function () { setImmediate(function () { - const trans = agent.startTransaction('foo') + var trans = agent.startTransaction('foo') queryable.query(sql, [1], function (err, rows, fields) { t.error(err) t.strictEqual(rows[0].solution, 2) @@ -375,7 +375,7 @@ factories.forEach(function (f) { }) setImmediate(function () { - const trans = agent.startTransaction('bar') + var trans = agent.startTransaction('bar') queryable.query(sql, [2], function (err, rows, fields) { t.error(err) t.strictEqual(rows[0].solution, 3) @@ -384,7 +384,7 @@ factories.forEach(function (f) { }) setImmediate(function () { - const trans = agent.startTransaction('baz') + var trans = agent.startTransaction('baz') queryable.query(sql, [3], function (err, rows, fields) { t.error(err) t.strictEqual(rows[0].solution, 4) @@ -432,7 +432,7 @@ function basicQueryCallback (t) { } function basicQueryStream (stream, t) { - let results = 0 + var results = 0 stream.on('error', function (err) { t.equal(agent.currentSpan, null, 'mysql span should not be active in user code') t.error(err) @@ -453,8 +453,8 @@ function assertBasicQuery (t, sql, data) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 1) - const trans = data.transactions[0] - const span = data.spans[0] + var trans = data.transactions[0] + var span = data.spans[0] t.strictEqual(trans.name, 'foo') assertSpan(t, span, sql) diff --git a/test/instrumentation/modules/mysql/pool-release-1.test.js b/test/instrumentation/modules/mysql/pool-release-1.test.js index 562a80d549..e625c429df 100644 --- a/test/instrumentation/modules/mysql/pool-release-1.test.js +++ b/test/instrumentation/modules/mysql/pool-release-1.test.js @@ -11,7 +11,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -const agent = require('../../../..').start({ +var agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -19,10 +19,10 @@ const agent = require('../../../..').start({ centralConfig: false }) -const mysql = require('mysql') -const test = require('tape') +var mysql = require('mysql') +var test = require('tape') -const utils = require('./_utils') +var utils = require('./_utils') test('release connection prior to transaction', function (t) { createPool(function (pool) { diff --git a/test/instrumentation/modules/mysql2/_utils.js b/test/instrumentation/modules/mysql2/_utils.js index 4fecb287bd..3cd1b1d766 100644 --- a/test/instrumentation/modules/mysql2/_utils.js +++ b/test/instrumentation/modules/mysql2/_utils.js @@ -6,12 +6,12 @@ 'use strict' -const mysql = require('mysql2') +var mysql = require('mysql2') exports.reset = reset exports.credentials = credentials -const DEFAULTS = { +var DEFAULTS = { host: process.env.MYSQL_HOST || 'localhost', user: process.env.MYSQL_USER || 'root', password: process.env.MYSQL_PASSWORD, @@ -27,7 +27,7 @@ function credentials (conf) { } function reset (cb) { - const client = mysql.createConnection(credentials({ database: 'mysql' })) + var client = mysql.createConnection(credentials({ database: 'mysql' })) client.connect(function (err) { if (err) throw err diff --git a/test/instrumentation/modules/mysql2/mysql.test.js b/test/instrumentation/modules/mysql2/mysql.test.js index f949eefa22..340a787135 100644 --- a/test/instrumentation/modules/mysql2/mysql.test.js +++ b/test/instrumentation/modules/mysql2/mysql.test.js @@ -19,7 +19,7 @@ if (semver.gte(mysql2Ver, '3.0.0') && semver.lt(process.version, '14.6.0')) { process.exit() } -const agent = require('../../../..').start({ +var agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -28,30 +28,30 @@ const agent = require('../../../..').start({ spanCompressionEnabled: false }) -const mysql = require('mysql2') -const mysqlPromise = require('mysql2/promise') -const test = require('tape') +var mysql = require('mysql2') +var mysqlPromise = require('mysql2/promise') +var test = require('tape') -const utils = require('./_utils') -const mockClient = require('../../../_mock_http_client') -const findObjInArray = require('../../../_utils').findObjInArray +var utils = require('./_utils') +var mockClient = require('../../../_mock_http_client') +var findObjInArray = require('../../../_utils').findObjInArray -const connectionOptions = utils.credentials() -let queryable -let queryablePromise -const factories = [ +var connectionOptions = utils.credentials() +var queryable +var queryablePromise +var factories = [ [createConnection, 'connection', true], [createPool, 'pool', true], [createPoolAndGetConnection, 'pool > connection', true], [createPoolClusterAndGetConnection, 'poolCluster > connection', false], [createPoolClusterAndGetConnectionViaOf, 'poolCluster > of > connection', false] ] -const executors = [ +var executors = [ 'query', 'execute' ] -const universalArgumentSets = [ +var universalArgumentSets = [ { names: ['sql'], query: 'SELECT 1 + 1 AS solution', @@ -74,7 +74,7 @@ const universalArgumentSets = [ } ] -const callbackArgumentSets = [ +var callbackArgumentSets = [ { names: ['query'], query: 'SELECT 1 + 1 AS solution', @@ -88,27 +88,27 @@ const callbackArgumentSets = [ ] factories.forEach(function (f) { - const factory = f[0] - const type = f[1] - const hasPromises = f[2] + var factory = f[0] + var type = f[1] + var hasPromises = f[2] test('mysql2.' + factory.name, function (t) { t.on('end', teardown) executors.forEach(function (executor) { t.test(executor, function (t) { - const isQuery = executor === 'query' - const argumentSets = isQuery && type !== 'pool' + var isQuery = executor === 'query' + var argumentSets = isQuery && type !== 'pool' ? universalArgumentSets.concat(callbackArgumentSets) : universalArgumentSets t.test('callback', function (t) { argumentSets.forEach(function (argumentSet) { - const query = argumentSet.query - const names = argumentSet.names - const values = argumentSet.values + var query = argumentSet.query + var names = argumentSet.names + var values = argumentSet.values - const name = `${type}.${executor}(${names.join(', ')}, callback)` - const args = values(query, basicQueryCallback(t)) + var name = `${type}.${executor}(${names.join(', ')}, callback)` + var args = values(query, basicQueryCallback(t)) t.test(name, function (t) { resetAgent(function (data) { @@ -127,12 +127,12 @@ factories.forEach(function (f) { if (hasPromises) { t.test('promise', function (t) { universalArgumentSets.forEach(function (argumentSet) { - const query = argumentSet.query - const names = argumentSet.names - const values = argumentSet.values + var query = argumentSet.query + var names = argumentSet.names + var values = argumentSet.values - const name = `${type}.${executor}(${names.join(', ')})` - const args = values(query) + var name = `${type}.${executor}(${names.join(', ')})` + var args = values(query) t.test(name, function (t) { resetAgent(function (data) { @@ -141,7 +141,7 @@ factories.forEach(function (f) { }) factory(function () { agent.startTransaction('foo') - const promise = queryablePromise[executor].apply(queryablePromise, args) + var promise = queryablePromise[executor].apply(queryablePromise, args) t.ok(agent.currentSpan === null, 'mysql2 span should not spill into calling code') basicQueryPromise(t, promise) }) @@ -153,12 +153,12 @@ factories.forEach(function (f) { if (isQuery) { t.test('streaming', function (t) { argumentSets.forEach(function (argumentSet) { - const query = argumentSet.query - const names = argumentSet.names - const values = argumentSet.values + var query = argumentSet.query + var names = argumentSet.names + var values = argumentSet.values - const name = `${type}.${executor}(${names.join(', ')})` - const args = values(query) + var name = `${type}.${executor}(${names.join(', ')})` + var args = values(query) t.test(name, function (t) { resetAgent(function (data) { @@ -167,7 +167,7 @@ factories.forEach(function (f) { }) factory(function () { agent.startTransaction('foo') - const stream = queryable[executor].apply(queryable, args) + var stream = queryable[executor].apply(queryable, args) t.ok(agent.currentSpan === null, 'mysql2 span should not spill into calling code') basicQueryStream(stream, t) }) @@ -184,7 +184,7 @@ factories.forEach(function (f) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 3) - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, 'foo') @@ -199,8 +199,8 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + ? AS solution' factory(function () { - let n = 0 - const trans = agent.startTransaction('foo') + var n = 0 + var trans = agent.startTransaction('foo') queryable.query(sql, [1], function (err, rows, fields) { t.error(err) @@ -229,7 +229,7 @@ factories.forEach(function (f) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 3) - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, 'foo') @@ -244,8 +244,8 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + ? AS solution' createPool(function () { - let n = 0 - const trans = agent.startTransaction('foo') + var n = 0 + var trans = agent.startTransaction('foo') queryable.getConnection(function (err, conn) { t.error(err) @@ -283,7 +283,7 @@ factories.forEach(function (f) { resetAgent(6, function (data) { t.strictEqual(data.transactions.length, 3) t.strictEqual(data.spans.length, 3) - const names = data.transactions.map(function (trans) { + var names = data.transactions.map(function (trans) { return trans.name }).sort() t.deepEqual(names, ['bar', 'baz', 'foo']) @@ -301,7 +301,7 @@ factories.forEach(function (f) { factory(function () { setImmediate(function () { - const trans = agent.startTransaction('foo') + var trans = agent.startTransaction('foo') queryable.query(sql, [1], function (err, rows, fields) { t.error(err) t.strictEqual(rows[0].solution, 2) @@ -310,7 +310,7 @@ factories.forEach(function (f) { }) setImmediate(function () { - const trans = agent.startTransaction('bar') + var trans = agent.startTransaction('bar') queryable.query(sql, [2], function (err, rows, fields) { t.error(err) t.strictEqual(rows[0].solution, 3) @@ -319,7 +319,7 @@ factories.forEach(function (f) { }) setImmediate(function () { - const trans = agent.startTransaction('baz') + var trans = agent.startTransaction('baz') queryable.query(sql, [3], function (err, rows, fields) { t.error(err) t.strictEqual(rows[0].solution, 4) @@ -364,7 +364,7 @@ function basicQueryPromise (t, p) { } p.then(function (response) { - const rows = response[0] + var rows = response[0] t.strictEqual(rows[0].solution, 2) done() }, function (error) { @@ -383,7 +383,7 @@ function basicQueryCallback (t) { } function basicQueryStream (stream, t) { - let results = 0 + var results = 0 stream.on('error', function (err) { t.ok(agent.currentSpan === null, 'mysql2 span should not be active in user code') t.error(err) @@ -404,8 +404,8 @@ function assertBasicQuery (t, sql, data) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 1) - const trans = data.transactions[0] - const span = data.spans[0] + var trans = data.transactions[0] + var span = data.spans[0] t.strictEqual(trans.name, 'foo') assertSpan(t, span, sql) diff --git a/test/instrumentation/modules/mysql2/pool-release-1.test.js b/test/instrumentation/modules/mysql2/pool-release-1.test.js index e4c3b5dfaa..f95c2f8bd9 100644 --- a/test/instrumentation/modules/mysql2/pool-release-1.test.js +++ b/test/instrumentation/modules/mysql2/pool-release-1.test.js @@ -19,7 +19,7 @@ if (semver.gte(mysql2Ver, '3.0.0') && semver.lt(process.version, '14.6.0')) { process.exit() } -const agent = require('../../../..').start({ +var agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -27,10 +27,10 @@ const agent = require('../../../..').start({ centralConfig: false }) -const mysql = require('mysql2') -const test = require('tape') +var mysql = require('mysql2') +var test = require('tape') -const utils = require('./_utils') +var utils = require('./_utils') test('release connection prior to transaction', function (t) { createPool(function (pool) { diff --git a/test/instrumentation/modules/next/next.test.js b/test/instrumentation/modules/next/next.test.js index 0f5120aeb6..24ace91ace 100644 --- a/test/instrumentation/modules/next/next.test.js +++ b/test/instrumentation/modules/next/next.test.js @@ -387,7 +387,7 @@ let TEST_REQUESTS = [ ] // Dev Note: To limit a test run to a particular test request, provide a // string value to DEV_TEST_FILTER that matches `testName`. -const DEV_TEST_FILTER = null +var DEV_TEST_FILTER = null if (DEV_TEST_FILTER) { TEST_REQUESTS = TEST_REQUESTS.filter(testReq => ~testReq.testName.indexOf(DEV_TEST_FILTER)) assert(TEST_REQUESTS.length > 0, 'DEV_TEST_FILTER should not result in an *empty* TEST_REQUESTS') diff --git a/test/instrumentation/modules/pg/_utils.js b/test/instrumentation/modules/pg/_utils.js index 8f143e41ed..d1ee323e88 100644 --- a/test/instrumentation/modules/pg/_utils.js +++ b/test/instrumentation/modules/pg/_utils.js @@ -6,13 +6,13 @@ 'use strict' -const Client = require('pg').Client +var Client = require('pg').Client exports.reset = reset exports.loadData = loadData function reset (cb) { - const client = new Client({ + var client = new Client({ database: 'postgres', user: process.env.PGUSER || 'postgres' }) @@ -31,7 +31,7 @@ function reset (cb) { } function loadData (cb) { - const client = new Client({ + var client = new Client({ database: 'test_elastic_apm', user: process.env.PGUSER || 'postgres' }) @@ -41,7 +41,7 @@ function loadData (cb) { client.query('CREATE TABLE test (id serial NOT NULL, c1 varchar, c2 varchar)', function (err) { if (err) throw err - const sql = 'INSERT INTO test (c1, c2) ' + + var sql = 'INSERT INTO test (c1, c2) ' + 'VALUES (\'foo1\', \'bar1\'), ' + '(\'foo2\', \'bar2\'), ' + '(\'foo3\', \'bar3\'), ' + diff --git a/test/instrumentation/modules/pg/knex-no-span-stack-traces.test.js b/test/instrumentation/modules/pg/knex-no-span-stack-traces.test.js index dbf56eb718..0bd0756e05 100644 --- a/test/instrumentation/modules/pg/knex-no-span-stack-traces.test.js +++ b/test/instrumentation/modules/pg/knex-no-span-stack-traces.test.js @@ -11,7 +11,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -const agent = require('../../../..').start({ +var agent = require('../../../..').start({ serviceName: 'test-knex-no-span-stack-traces', secretToken: 'test', captureExceptions: false, @@ -22,8 +22,8 @@ const agent = require('../../../..').start({ spanStackTraceMinDuration: -1 }) -const knexVersion = require('knex/package').version -const semver = require('semver') +var knexVersion = require('knex/package').version +var semver = require('semver') // knex 0.18.0 min supported node is v8, knex 0.21.0 min supported node is v10 if ((semver.gte(knexVersion, '0.18.0') && semver.lt(process.version, '8.6.0')) || @@ -38,8 +38,8 @@ if (semver.gte(knexVersion, '0.95.0') && agent._conf.contextManager === 'patch') process.exit() } -const Knex = require('knex') -const test = require('tape') +var Knex = require('knex') +var test = require('tape') test('knex instrumentation is disabled if not collecting span stacktraces', t => { // To test that knex instrumentation did *not* happen, we are assuming that diff --git a/test/instrumentation/modules/pg/knex.test.js b/test/instrumentation/modules/pg/knex.test.js index 5a452294f5..1cac14eb39 100644 --- a/test/instrumentation/modules/pg/knex.test.js +++ b/test/instrumentation/modules/pg/knex.test.js @@ -13,7 +13,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.env.ELASTIC_APM_TEST = true -const agent = require('../../../..').start({ +var agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -23,8 +23,8 @@ const agent = require('../../../..').start({ spanCompressionEnabled: false }) -const knexVersion = require('knex/package').version -const semver = require('semver') +var knexVersion = require('knex/package').version +var semver = require('semver') // knex 0.18.0 min supported node is v8, knex 0.21.0 min supported node is v10, knex 1.0.0 min supported node is v12 if ((semver.gte(knexVersion, '0.18.0') && semver.lt(process.version, '8.6.0')) || @@ -40,16 +40,16 @@ if (semver.gte(knexVersion, '0.95.0') && agent._conf.contextManager === 'patch') process.exit() } -const Knex = require('knex') -const test = require('tape') +var Knex = require('knex') +var test = require('tape') -const utils = require('./_utils') -const mockClient = require('../../../_mock_http_client') +var utils = require('./_utils') +var mockClient = require('../../../_mock_http_client') -let transNo = 0 -let knex +var transNo = 0 +var knex -const selectTests = [ +var selectTests = [ 'knex.select().from(\'test\')', 'knex.select(\'c1\', \'c2\').from(\'test\')', 'knex.column(\'c1\', \'c2\').select().from(\'test\')', @@ -60,7 +60,7 @@ if (semver.gte(knexVersion, '0.11.0')) { selectTests.push('knex.select().from(\'test\').timeout(10000)') } -const insertTests = [ +var insertTests = [ 'knex(\'test\').insert({c1: \'test1\', c2: \'test2\'})' ] @@ -73,7 +73,7 @@ selectTests.forEach(function (source) { createClient(t, function userLandCode () { agent.startTransaction('foo' + ++transNo) - const query = eval(source) // eslint-disable-line no-eval + var query = eval(source) // eslint-disable-line no-eval query.then(function (rows) { t.strictEqual(rows.length, 5) @@ -98,7 +98,7 @@ insertTests.forEach(function (source) { createClient(t, function userLandCode () { agent.startTransaction('foo' + ++transNo) - const query = eval(source) // eslint-disable-line no-eval + var query = eval(source) // eslint-disable-line no-eval query.then(function (result) { t.strictEqual(result.command, 'INSERT') @@ -119,10 +119,10 @@ test('knex.raw', function (t) { createClient(t, function userLandCode () { agent.startTransaction('foo' + ++transNo) - const query = knex.raw('SELECT * FROM "test"') + var query = knex.raw('SELECT * FROM "test"') query.then(function (result) { - const rows = result.rows + var rows = result.rows t.strictEqual(rows.length, 5) rows.forEach(function (row, i) { t.strictEqual(row.c1, 'foo' + (i + 1)) @@ -138,7 +138,7 @@ test('knex.raw', function (t) { function assertBasicQuery (t, data) { t.strictEqual(data.transactions.length, 1) - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, 'foo' + transNo) diff --git a/test/instrumentation/modules/pg/pg.test.js b/test/instrumentation/modules/pg/pg.test.js index a107985db7..0985e21958 100644 --- a/test/instrumentation/modules/pg/pg.test.js +++ b/test/instrumentation/modules/pg/pg.test.js @@ -11,7 +11,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -const agent = require('../../../..').start({ +var agent = require('../../../..').start({ serviceName: 'test-pg', captureExceptions: false, metricsInterval: 0, @@ -20,25 +20,25 @@ const agent = require('../../../..').start({ spanCompressionEnabled: false }) -const semver = require('semver') -const once = require('once') -const pgVersion = require('pg/package.json').version +var semver = require('semver') +var once = require('once') +var pgVersion = require('pg/package.json').version -const test = require('tape') -const pg = require('pg') -const utils = require('./_utils') -const mockClient = require('../../../_mock_http_client') -const findObjInArray = require('../../../_utils').findObjInArray +var test = require('tape') +var pg = require('pg') +var utils = require('./_utils') +var mockClient = require('../../../_mock_http_client') +var findObjInArray = require('../../../_utils').findObjInArray -let queryable, connectionDone -const factories = [ +var queryable, connectionDone +var factories = [ [createClient, 'client'], [createPoolAndConnect, 'pool'] ] factories.forEach(function (f) { - const factory = f[0] - const type = f[1] + var factory = f[0] + var type = f[1] test('pg.' + factory.name, function (t) { t.on('end', teardown) @@ -115,7 +115,7 @@ factories.forEach(function (f) { }) var sql = 'SELECT 1 + 1 AS solution' factory(function () { - const trans = agent.startTransaction('foo') + var trans = agent.startTransaction('foo') queryable.query(sql) t.ok(agent.currentSpan === null, 'no currentSpan in sync code after pg .query') setTimeout(function () { @@ -136,7 +136,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + 1 AS solution' factory(function () { agent.startTransaction('foo') - const stream = queryable.query(new pg.Query(sql)) + var stream = queryable.query(new pg.Query(sql)) t.ok(agent.currentSpan === null, 'no currentSpan in sync code after pg .query') basicQueryStream(stream, t) }) @@ -152,7 +152,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + 1 AS solution' factory(function () { agent.startTransaction('foo') - const stream = queryable.query(sql) + var stream = queryable.query(sql) t.ok(agent.currentSpan === null, 'no currentSpan in sync code after pg .query') basicQueryStream(stream, t) }) @@ -166,7 +166,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + $1 AS solution' factory(function () { agent.startTransaction('foo') - const stream = queryable.query(sql, [1]) + var stream = queryable.query(sql, [1]) t.ok(agent.currentSpan === null, 'no currentSpan in sync code after pg .query') basicQueryStream(stream, t) }) @@ -180,7 +180,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + 1 AS solution' factory(function () { agent.startTransaction('foo') - const stream = queryable.query({ text: sql }) + var stream = queryable.query({ text: sql }) t.ok(agent.currentSpan === null, 'no currentSpan in sync code after pg .query') basicQueryStream(stream, t) }) @@ -194,7 +194,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + $1 AS solution' factory(function () { agent.startTransaction('foo') - const stream = queryable.query({ text: sql }, [1]) + var stream = queryable.query({ text: sql }, [1]) t.ok(agent.currentSpan === null, 'no currentSpan in sync code after pg .query') basicQueryStream(stream, t) }) @@ -208,7 +208,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + $1 AS solution' factory(function () { agent.startTransaction('foo') - const stream = queryable.query({ text: sql, values: [1] }) + var stream = queryable.query({ text: sql, values: [1] }) t.ok(agent.currentSpan === null, 'no currentSpan in sync code after pg .query') basicQueryStream(stream, t) }) @@ -227,7 +227,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + 1 AS solution' factory(function () { agent.startTransaction('foo') - const p = queryable.query(sql) + var p = queryable.query(sql) t.ok(agent.currentSpan === null, 'no currentSpan in sync code after pg .query') basicQueryPromise(p, t) }) @@ -241,7 +241,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + $1 AS solution' factory(function () { agent.startTransaction('foo') - const p = queryable.query(sql, [1]) + var p = queryable.query(sql, [1]) t.ok(agent.currentSpan === null, 'no currentSpan in sync code after pg .query') basicQueryPromise(p, t) }) @@ -255,7 +255,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + 1 AS solution' factory(function () { agent.startTransaction('foo') - const p = queryable.query({ text: sql }) + var p = queryable.query({ text: sql }) t.ok(agent.currentSpan === null, 'no currentSpan in sync code after pg .query') basicQueryPromise(p, t) }) @@ -269,7 +269,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + $1 AS solution' factory(function () { agent.startTransaction('foo') - const p = queryable.query({ text: sql }, [1]) + var p = queryable.query({ text: sql }, [1]) t.ok(agent.currentSpan === null, 'no currentSpan in sync code after pg .query') basicQueryPromise(p, t) }) @@ -283,7 +283,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + $1 AS solution' factory(function () { agent.startTransaction('foo') - const p = queryable.query({ text: sql, values: [1] }) + var p = queryable.query({ text: sql, values: [1] }) t.ok(agent.currentSpan === null, 'no currentSpan in sync code after pg .query') basicQueryPromise(p, t) }) @@ -297,7 +297,7 @@ factories.forEach(function (f) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 3) - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, 'foo') data.spans.forEach(function (span) { @@ -311,8 +311,8 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + $1 AS solution' factory(function () { - let n = 0 - const trans = agent.startTransaction('foo') + var n = 0 + var trans = agent.startTransaction('foo') queryable.query(sql, [1], function (err, result, fields) { t.error(err) @@ -341,7 +341,7 @@ factories.forEach(function (f) { resetAgent(6, function (data) { t.strictEqual(data.transactions.length, 3) t.strictEqual(data.spans.length, 3) - const names = data.transactions.map(function (trans) { + var names = data.transactions.map(function (trans) { return trans.name }).sort() t.deepEqual(names, ['bar', 'baz', 'foo']) @@ -360,7 +360,7 @@ factories.forEach(function (f) { factory(function () { setImmediate(function () { - const trans = agent.startTransaction('foo') + var trans = agent.startTransaction('foo') queryable.query(sql, [1], function (err, result, fields) { t.error(err) t.strictEqual(result.rows[0].solution, 2) @@ -369,7 +369,7 @@ factories.forEach(function (f) { }) setImmediate(function () { - const trans = agent.startTransaction('bar') + var trans = agent.startTransaction('bar') queryable.query(sql, [2], function (err, result, fields) { t.error(err) t.strictEqual(result.rows[0].solution, 3) @@ -378,7 +378,7 @@ factories.forEach(function (f) { }) setImmediate(function () { - const trans = agent.startTransaction('baz') + var trans = agent.startTransaction('baz') queryable.query(sql, [3], function (err, result, fields) { t.error(err) t.strictEqual(result.rows[0].solution, 4) @@ -396,7 +396,7 @@ test('simultaneous queries on different connections', function (t) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 3) - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, 'foo') data.spans.forEach(function (span) { @@ -410,8 +410,8 @@ test('simultaneous queries on different connections', function (t) { var sql = 'SELECT 1 + $1 AS solution' createPool(function (connector) { - let n = 0 - const trans = agent.startTransaction('foo') + var n = 0 + var trans = agent.startTransaction('foo') connector(function (err, client, release) { t.error(err) @@ -497,7 +497,7 @@ if (typeof pg.Client.prototype.query.on !== 'function' && teardown() }) - const sql = 'select \'not-a-uuid\' = \'00000000-0000-0000-0000-000000000000\'::uuid' + var sql = 'select \'not-a-uuid\' = \'00000000-0000-0000-0000-000000000000\'::uuid' createPool(function (connector) { agent.startTransaction('foo') @@ -533,7 +533,7 @@ function basicQueryCallback (t) { } function basicQueryStream (stream, t) { - let results = 0 + var results = 0 stream.on('error', function (err) { t.ok(agent.currentSpan === null, 'pg span should not be active in user code') t.error(err) @@ -565,10 +565,10 @@ function assertBasicQuery (t, sql, data) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 1) - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, 'foo') - const span = data.spans[0] + var span = data.spans[0] assertSpan(t, span, sql) } @@ -608,7 +608,7 @@ function createClient (cb) { function createPool (cb) { setup(function () { - let connector + var connector if (semver.satisfies(pgVersion, '<6.0.0')) { queryable = pg @@ -619,7 +619,7 @@ function createPool (cb) { }, cb) } } else { - const pool = new pg.Pool({ + var pool = new pg.Pool({ database: 'test_elastic_apm', user: process.env.PGUSER || 'postgres' }) diff --git a/test/instrumentation/modules/pug.test.js b/test/instrumentation/modules/pug.test.js index 0c455131cf..c905d25ad0 100644 --- a/test/instrumentation/modules/pug.test.js +++ b/test/instrumentation/modules/pug.test.js @@ -13,7 +13,7 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.env.ELASTIC_APM_TEST = true -const agent = require('../../..').start({ +var agent = require('../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -22,18 +22,18 @@ const agent = require('../../..').start({ spanStackTraceMinDuration: 0 // Always have span stacktraces. }) -const pug = require('pug') -const test = require('tape') +var pug = require('pug') +var test = require('tape') -const mockClient = require('../../_mock_http_client') -const findObjInArray = require('../../_utils').findObjInArray +var mockClient = require('../../_mock_http_client') +var findObjInArray = require('../../_utils').findObjInArray test('pug compile and render', function userLandCode (t) { resetAgent(function (data) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 2) - const trans = data.transactions[0] + var trans = data.transactions[0] t.ok(/^foo\d$/.test(trans.name)) t.strictEqual(trans.type, 'custom') @@ -55,8 +55,8 @@ test('pug compile and render', function userLandCode (t) { agent.startTransaction('foo1') - const template = pug.compile('p Hello, #{name}!') - const output = template({ name: 'world' }) + var template = pug.compile('p Hello, #{name}!') + var output = template({ name: 'world' }) t.strictEqual(output, '

Hello, world!

', 'compiled string should be Hello,world!') agent.endTransaction() agent.flush() diff --git a/test/instrumentation/modules/redis-2-3.test.js b/test/instrumentation/modules/redis-2-3.test.js index a5295c1229..dde9e141de 100644 --- a/test/instrumentation/modules/redis-2-3.test.js +++ b/test/instrumentation/modules/redis-2-3.test.js @@ -11,14 +11,14 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -const redisVersion = require('redis/package.json').version -const semver = require('semver') +var redisVersion = require('redis/package.json').version +var semver = require('semver') if (semver.gte(redisVersion, '4.0.0')) { console.log('# SKIP: skipping redis-2-3.test.js tests >=4.0.0') process.exit(0) } -const agent = require('../../..').start({ +var agent = require('../../..').start({ serviceName: 'test-redis-2-3', captureExceptions: false, metricsInterval: 0, @@ -26,12 +26,12 @@ const agent = require('../../..').start({ spanCompressionEnabled: false }) -const redis = require('redis') +var redis = require('redis') -const test = require('tape') +var test = require('tape') -const findObjInArray = require('../../_utils').findObjInArray -const mockClient = require('../../_mock_http_client') +var findObjInArray = require('../../_utils').findObjInArray +var mockClient = require('../../_mock_http_client') test('redis', function (t) { resetAgent(function (data) { @@ -41,9 +41,9 @@ test('redis', function (t) { // does *not* have spans for each of the client commands. It *possibly* // (with contextManager="patch" it doesn't) has an "INFO" span for the // internal INFO command the RedisClient setup does. - let trans = findObjInArray(data.transactions, 'name', 'transBeforeClient') + var trans = findObjInArray(data.transactions, 'name', 'transBeforeClient') t.ok(trans, 'have "transBeforeClient" transaction') - let spans = data.spans.filter(s => s.transaction_id === trans.id) + var spans = data.spans.filter(s => s.transaction_id === trans.id) .filter(s => s.name !== 'INFO') t.equal(spans.length, 0, 'there are no non-INFO spans in the "transBeforeClient" transaction') @@ -56,7 +56,7 @@ test('redis', function (t) { t.ok(trans, 'have "transAfterClient" transaction') t.strictEqual(trans.result, 'success', 'trans.result') - const expectedSpanNames = [ + var expectedSpanNames = [ 'FLUSHALL', 'SET', 'SET', @@ -65,7 +65,7 @@ test('redis', function (t) { 'HKEYS' ] t.equal(spans.length, expectedSpanNames.length, 'have the expected number of spans') - for (let i = 0; i < expectedSpanNames.length; i++) { + for (var i = 0; i < expectedSpanNames.length; i++) { const expectedName = expectedSpanNames[i] const span = spans[i] t.strictEqual(span.transaction_id, trans.id, 'span.transaction_id') @@ -82,7 +82,7 @@ test('redis', function (t) { t.deepEqual(span.context.db, { type: 'redis' }, 'span.context.db') t.strictEqual(span.parent_id, trans.id, 'span is a child of the transaction') - const offset = span.timestamp - trans.timestamp + var offset = span.timestamp - trans.timestamp t.ok(offset + span.duration * 1000 < trans.duration * 1000, 'span ended before transaction ended') } @@ -98,16 +98,16 @@ test('redis', function (t) { // currentTransaction for the async task in which the redis client is created. // That's what `transBeforeClient` is: to make sure we *don't* get // double-spans. - const transBeforeClient = agent.startTransaction('transBeforeClient') + var transBeforeClient = agent.startTransaction('transBeforeClient') - const client = redis.createClient('6379', process.env.REDIS_HOST) + var client = redis.createClient('6379', process.env.REDIS_HOST) - const transAfterClient = agent.startTransaction('transAfterClient') + var transAfterClient = agent.startTransaction('transAfterClient') client.flushall(function (err, reply) { t.error(err, 'no flushall error') t.strictEqual(reply, 'OK', 'reply is OK') - let done = 0 + var done = 0 client.set('string key', 'string val', function (err, reply) { t.error(err) @@ -166,12 +166,12 @@ if (semver.satisfies(redisVersion, '>=3.0.0')) { // Simulate a redis client error with `enable_offline_queue: false` and a // quick `.set()` before the client connection ready. - const client = redis.createClient({ + var client = redis.createClient({ host: process.env.REDIS_HOST, port: '6379', enable_offline_queue: false }) - const t0 = agent.startTransaction('t0') + var t0 = agent.startTransaction('t0') client.set('k', 'v', function (err, reply) { t.ok(err, 'got error from client.set') t.equal(err.name, 'AbortError', 'error.name') @@ -201,9 +201,9 @@ test('client.cmd(...) call signatures', function (t) { t.end() }) - const client = redis.createClient('6379', process.env.REDIS_HOST) + var client = redis.createClient('6379', process.env.REDIS_HOST) client.on('ready', function () { - const t0 = agent.startTransaction('t0') + var t0 = agent.startTransaction('t0') // Use different call signatures to trigger the different forms of arguments // to the internal RedisClient.send_command that we are wrapping. @@ -235,9 +235,9 @@ if (semver.satisfies(redisVersion, '<=2.4.2')) { t.end() }) - const client = redis.createClient('6379', process.env.REDIS_HOST) + var client = redis.createClient('6379', process.env.REDIS_HOST) client.on('ready', function () { - const t0 = agent.startTransaction('t0') + var t0 = agent.startTransaction('t0') client.get(['k', myCb]) diff --git a/test/instrumentation/modules/tedious.test.js b/test/instrumentation/modules/tedious.test.js index dd49859f00..80fac5222d 100644 --- a/test/instrumentation/modules/tedious.test.js +++ b/test/instrumentation/modules/tedious.test.js @@ -164,7 +164,7 @@ function assertTransaction (t, sql, data, spanCount) { t.strictEqual(data.transactions.length, 1, 'transaction count') t.strictEqual(data.spans.length, spanCount, 'span count') - const trans = data.transactions[0] + var trans = data.transactions[0] t.strictEqual(trans.name, 'foo', 'transaction name') } @@ -197,7 +197,7 @@ function assertBasicQuery (t, sql, data) { function assertPreparedQuery (t, sql, data) { assertTransaction(t, sql, data, 2) - const spans = sortSpansBy(data.spans, span => span.name) + var spans = sortSpansBy(data.spans, span => span.name) assertQuery(t, sql, spans[0], 'SELECT') assertQuery(t, sql, spans[1], 'SELECT (prepare)') } diff --git a/test/instrumentation/modules/ws.test.js b/test/instrumentation/modules/ws.test.js index ec36ea701f..c307526d19 100644 --- a/test/instrumentation/modules/ws.test.js +++ b/test/instrumentation/modules/ws.test.js @@ -11,24 +11,24 @@ if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { process.exit(0) } -const agent = require('../../..').start({ +var agent = require('../../..').start({ serviceName: 'test-ws', captureExceptions: false, metricsInterval: 0, centralConfig: false }) -const test = require('tape') -const WebSocket = require('ws') +var test = require('tape') +var WebSocket = require('ws') -const mockClient = require('../../_mock_http_client') +var mockClient = require('../../_mock_http_client') -const PORT = 12342 +var PORT = 12342 test('ws.send', function (t) { resetAgent(done(t)) - const wss = new WebSocket.Server({ port: PORT }) + var wss = new WebSocket.Server({ port: PORT }) wss.on('connection', function (ws) { ws.on('message', function (message) { @@ -37,7 +37,7 @@ test('ws.send', function (t) { }) }) - const ws = new WebSocket('ws://localhost:' + PORT) + var ws = new WebSocket('ws://localhost:' + PORT) ws.on('open', function () { agent.startTransaction('foo', 'websocket') @@ -61,8 +61,8 @@ function done (t) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 1) - const trans = data.transactions[0] - const span = data.spans[0] + var trans = data.transactions[0] + var span = data.spans[0] t.strictEqual(trans.name, 'foo') t.strictEqual(trans.type, 'websocket') @@ -70,7 +70,7 @@ function done (t) { t.strictEqual(span.type, 'websocket') t.strictEqual(span.subtype, 'send') - const offset = span.timestamp - trans.timestamp + var offset = span.timestamp - trans.timestamp t.ok(offset + span.duration * 1000 < trans.duration * 1000) t.end() diff --git a/test/instrumentation/native-promises.test.js b/test/instrumentation/native-promises.test.js index d52ceb0f26..0781c93f6e 100644 --- a/test/instrumentation/native-promises.test.js +++ b/test/instrumentation/native-promises.test.js @@ -6,14 +6,14 @@ 'use strict' -const agent = require('../..').start({ +var agent = require('../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false }) -const test = require('tape') +var test = require('tape') -const ins = agent._instrumentation +var ins = agent._instrumentation require('./_shared-promise-tests')(test, Promise, ins) diff --git a/test/instrumentation/run-context/fixtures/custom-instrumentation-sync.js b/test/instrumentation/run-context/fixtures/custom-instrumentation-sync.js index 412fa092b2..e197b5b037 100644 --- a/test/instrumentation/run-context/fixtures/custom-instrumentation-sync.js +++ b/test/instrumentation/run-context/fixtures/custom-instrumentation-sync.js @@ -28,15 +28,15 @@ if (Number(process.versions.node.split('.')[0]) > 8) { assert = assert.strict } -const t1 = apm.startTransaction('t1') +var t1 = apm.startTransaction('t1') assert(apm.currentTransaction === t1) -const t2 = apm.startTransaction('t2') +var t2 = apm.startTransaction('t2') assert(apm.currentTransaction === t2) -const t3 = apm.startTransaction('t3') +var t3 = apm.startTransaction('t3') assert(apm.currentTransaction === t3) -const s4 = apm.startSpan('s4') +var s4 = apm.startSpan('s4') assert(apm.currentSpan === s4) -const s5 = apm.startSpan('s5') +var s5 = apm.startSpan('s5') assert(apm.currentSpan === s5) s4.end() // (out of order) assert(apm.currentSpan === s5) diff --git a/test/instrumentation/run-context/fixtures/ls-await.js b/test/instrumentation/run-context/fixtures/ls-await.js index 39fd03144d..0c181070d8 100644 --- a/test/instrumentation/run-context/fixtures/ls-await.js +++ b/test/instrumentation/run-context/fixtures/ls-await.js @@ -12,7 +12,7 @@ // `- span "cwd" // `- span "readdir" -const apm = require('../../../../').start({ // elastic-apm-node +var apm = require('../../../../').start({ // elastic-apm-node captureExceptions: false, metricsInterval: 0, cloudProvider: 'none', @@ -30,7 +30,7 @@ const fsp = require('fs').promises let t1 async function getCwd () { - const s2 = apm.startSpan('cwd') + var s2 = apm.startSpan('cwd') try { return process.cwd() } finally { @@ -47,7 +47,7 @@ async function main () { const cwd = await getCwd() let entries - const s3 = apm.startSpan('readdir') + var s3 = apm.startSpan('readdir') try { assert(apm.currentSpan === s3) entries = await fsp.readdir(cwd) diff --git a/test/instrumentation/run-context/fixtures/ls-promises.js b/test/instrumentation/run-context/fixtures/ls-promises.js index c3a7ae85e5..14b4730cca 100644 --- a/test/instrumentation/run-context/fixtures/ls-promises.js +++ b/test/instrumentation/run-context/fixtures/ls-promises.js @@ -12,7 +12,7 @@ // `- span "cwd" // `- span "readdir" -const apm = require('../../../../').start({ // elastic-apm-node +var apm = require('../../../../').start({ // elastic-apm-node captureExceptions: false, metricsInterval: 0, cloudProvider: 'none', @@ -30,7 +30,7 @@ const fsp = require('fs').promises let t1 function getCwd () { - const s2 = apm.startSpan('cwd') + var s2 = apm.startSpan('cwd') try { return Promise.resolve(process.cwd()) } finally { @@ -47,7 +47,7 @@ function main () { .then(cwd => { assert(apm.currentTransaction === t1) assert(apm.currentSpan === null) - const s3 = apm.startSpan('readdir') + var s3 = apm.startSpan('readdir') assert(apm.currentSpan === s3) return fsp.readdir(cwd) .finally(() => { diff --git a/test/instrumentation/span-compression.test.js b/test/instrumentation/span-compression.test.js index 82ee8fcedc..386b71dd9e 100644 --- a/test/instrumentation/span-compression.test.js +++ b/test/instrumentation/span-compression.test.js @@ -122,12 +122,12 @@ tape.test('integration/end-to-end span compression tests', function (suite) { t.end() }) - const t0 = agent.startTransaction('t0') + var t0 = agent.startTransaction('t0') setImmediate(() => { - const s1 = t0.startSpan('s1', 'db', 'mysql', { exitSpan: true }) + var s1 = t0.startSpan('s1', 'db', 'mysql', { exitSpan: true }) setTimeout(() => { s1.end() - const s2 = t0.startSpan('s2', 'db', 'mysql', { exitSpan: true }) + var s2 = t0.startSpan('s2', 'db', 'mysql', { exitSpan: true }) setTimeout(() => { s2.end() t0.end() diff --git a/test/instrumentation/span.test.js b/test/instrumentation/span.test.js index 34a3a2acc8..544cbcf8c9 100644 --- a/test/instrumentation/span.test.js +++ b/test/instrumentation/span.test.js @@ -20,16 +20,16 @@ const agent = require('../..').start({ transport () { return new CapturingTransport() } }) -const test = require('tape') +var test = require('tape') -const assert = require('../_assert') -const Transaction = require('../../lib/instrumentation/transaction') -const Span = require('../../lib/instrumentation/span') +var assert = require('../_assert') +var Transaction = require('../../lib/instrumentation/transaction') +var Span = require('../../lib/instrumentation/span') test('init', function (t) { t.test('properties', function (t) { - const trans = new Transaction(agent) - const span = new Span(trans, 'sig', 'type') + var trans = new Transaction(agent) + var span = new Span(trans, 'sig', 'type') t.ok(/^[\da-f]{16}$/.test(span.id)) t.ok(/^[\da-f]{32}$/.test(span.traceId)) t.ok(/^[\da-f]{16}$/.test(span.parentId)) @@ -42,9 +42,9 @@ test('init', function (t) { }) t.test('options.childOf', function (t) { - const childOf = '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01' - const trans = new Transaction(agent) - const span = new Span(trans, 'sig', 'type', { childOf }) + var childOf = '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01' + var trans = new Transaction(agent) + var span = new Span(trans, 'sig', 'type', { childOf }) t.strictEqual(span._context.traceparent.version, '00') t.strictEqual(span._context.traceparent.traceId, '4bf92f3577b34da6a3ce929d0e0e4736') t.notEqual(span._context.traceparent.id, '00f067aa0ba902b7') @@ -127,8 +127,8 @@ test('init', function (t) { }) test('#end()', function (t) { - const trans = new Transaction(agent) - const span = new Span(trans, 'sig', 'type') + var trans = new Transaction(agent) + var span = new Span(trans, 'sig', 'type') t.strictEqual(span.ended, false) span.end() t.strictEqual(span.ended, true) @@ -136,8 +136,8 @@ test('#end()', function (t) { }) test('#duration()', function (t) { - const trans = new Transaction(agent) - const span = new Span(trans) + var trans = new Transaction(agent) + var span = new Span(trans) setTimeout(function () { span.end() t.ok(span.duration() > 49, span.duration() + ' should be larger than 49') @@ -146,28 +146,28 @@ test('#duration()', function (t) { }) test('#duration() - return null if not ended', function (t) { - const trans = new Transaction(agent) - const span = new Span(trans) + var trans = new Transaction(agent) + var span = new Span(trans) t.strictEqual(span.duration(), null) t.end() }) test('custom start time', function (t) { - const trans = new Transaction(agent) - const startTime = Date.now() - 1000 - const span = new Span(trans, 'sig', 'type', { childOf: trans, startTime }) + var trans = new Transaction(agent) + var startTime = Date.now() - 1000 + var span = new Span(trans, 'sig', 'type', { childOf: trans, startTime }) span.end() - const duration = span.duration() + var duration = span.duration() t.ok(duration > 990, `duration should be circa more than 1s (was: ${duration})`) // we've seen 998.752 in the wild t.ok(duration < 1100, `duration should be less than 1.1s (was: ${duration})`) t.end() }) test('#end(time)', function (t) { - const trans = new Transaction(agent) - const startTime = Date.now() - 1000 - const endTime = startTime + 2000.123 - const span = new Span(trans, 'sig', 'type', { childOf: trans, startTime }) + var trans = new Transaction(agent) + var startTime = Date.now() - 1000 + var endTime = startTime + 2000.123 + var span = new Span(trans, 'sig', 'type', { childOf: trans, startTime }) span.end(endTime) t.strictEqual(span.duration(), 2000.123) t.end() @@ -175,8 +175,8 @@ test('#end(time)', function (t) { test('#setLabel', function (t) { t.test('valid', function (t) { - const trans = new Transaction(agent) - const span = new Span(trans) + var trans = new Transaction(agent) + var span = new Span(trans) t.strictEqual(span._labels, null) t.strictEqual(span.setLabel(), false) t.strictEqual(span._labels, null) @@ -190,8 +190,8 @@ test('#setLabel', function (t) { }) t.test('invalid', function (t) { - const trans = new Transaction(agent) - const span = new Span(trans) + var trans = new Transaction(agent) + var span = new Span(trans) t.strictEqual(span._labels, null) t.strictEqual(span.setLabel(), false) t.strictEqual(span._labels, null) @@ -206,8 +206,8 @@ test('#setLabel', function (t) { }) test('#addLabels', function (t) { - const trans = new Transaction(agent) - const span = new Span(trans) + var trans = new Transaction(agent) + var span = new Span(trans) t.strictEqual(span._labels, null) t.strictEqual(span.setLabel(), false) @@ -240,13 +240,13 @@ test('#addLabels', function (t) { }) test('span.sync', function (t) { - const trans = agent.startTransaction() + var trans = agent.startTransaction() - const span1 = agent.startSpan('span1') + var span1 = agent.startSpan('span1') t.strictEqual(span1.sync, true) // This span will be *ended* synchronously. It should stay `span.sync=true`. - const span2 = agent.startSpan('span2') + var span2 = agent.startSpan('span2') t.strictEqual(span2.sync, true, 'span2.sync=true immediately after creation') span2.end() t.strictEqual(span2.sync, true, 'span2.sync=true immediately after end') @@ -262,8 +262,8 @@ test('span.sync', function (t) { }) test('#_encode() - un-ended', function (t) { - const trans = new Transaction(agent) - const span = new Span(trans) + var trans = new Transaction(agent) + var span = new Span(trans) span._encode(function (err, payload) { t.strictEqual(err.message, 'cannot encode un-ended span') t.end() @@ -271,9 +271,9 @@ test('#_encode() - un-ended', function (t) { }) test('#_encode() - ended unnamed', function myTest1 (t) { - const trans = new Transaction(agent) - const span = new Span(trans) - const timerStart = span._timer.start + var trans = new Transaction(agent) + var span = new Span(trans) + var timerStart = span._timer.start span.end() span._encode(function (err, payload) { t.error(err) @@ -296,9 +296,9 @@ test('#_encode() - ended unnamed', function myTest1 (t) { }) test('#_encode() - ended named', function myTest2 (t) { - const trans = new Transaction(agent) - const span = new Span(trans, 'foo', 'bar') - const timerStart = span._timer.start + var trans = new Transaction(agent) + var span = new Span(trans, 'foo', 'bar') + var timerStart = span._timer.start span.end() span._encode(function (err, payload) { t.error(err) @@ -321,9 +321,9 @@ test('#_encode() - ended named', function myTest2 (t) { }) test('#_encode() - with meta data', function myTest2 (t) { - const trans = new Transaction(agent) - const span = new Span(trans, 'foo', 'bar') - const timerStart = span._timer.start + var trans = new Transaction(agent) + var span = new Span(trans, 'foo', 'bar') + var timerStart = span._timer.start span.setDbContext({ statement: 'foo', type: 'bar' }) span.setLabel('baz', 1) span.end() @@ -354,9 +354,9 @@ test('#_encode() - disabled stack traces', function (t) { const oldValue = agent._conf.spanStackTraceMinDuration agent._conf.spanStackTraceMinDuration = -1 - const trans = new Transaction(agent) - const span = new Span(trans) - const timerStart = span._timer.start + var trans = new Transaction(agent) + var span = new Span(trans) + var timerStart = span._timer.start span.end() span._encode(function (err, payload) { t.error(err) @@ -381,8 +381,8 @@ test('#_encode() - disabled stack traces', function (t) { }) test('#ids', function (t) { - const trans = new Transaction(agent) - const span = new Span(trans) + var trans = new Transaction(agent) + var span = new Span(trans) t.deepLooseEqual(span.ids, { 'trace.id': span.traceId, 'span.id': span.id @@ -391,8 +391,8 @@ test('#ids', function (t) { }) test('#toString()', function (t) { - const trans = new Transaction(agent) - const span = new Span(trans) + var trans = new Transaction(agent) + var span = new Span(trans) t.strictEqual(span.toString(), `trace.id=${span.traceId} span.id=${span.id}`) t.end() }) diff --git a/test/instrumentation/timer.test.js b/test/instrumentation/timer.test.js index 9ce7a064f4..034751e610 100644 --- a/test/instrumentation/timer.test.js +++ b/test/instrumentation/timer.test.js @@ -6,19 +6,19 @@ 'use strict' -const test = require('tape') +var test = require('tape') -const Timer = require('../../lib/instrumentation/timer') +var Timer = require('../../lib/instrumentation/timer') test('started', function (t) { - const timer = new Timer() + var timer = new Timer() t.ok(timer.start > 0) t.strictEqual(timer.duration, null) t.end() }) test('ended', function (t) { - const timer = new Timer() + var timer = new Timer() timer.end() t.ok(timer.duration > 0) t.ok(timer.duration < 100) @@ -26,19 +26,19 @@ test('ended', function (t) { }) test('ended twice', function (t) { - const timer = new Timer() + var timer = new Timer() timer.end() - const duration = timer.duration + var duration = timer.duration timer.end() t.strictEqual(timer.duration, duration) t.end() }) test('elapsed', function (t) { - const timer = new Timer() - const e1 = timer.elapsed() + var timer = new Timer() + var e1 = timer.elapsed() process.nextTick(function () { - const e2 = timer.elapsed() + var e2 = timer.elapsed() t.ok(e2 > e1) timer.end() t.ok(timer.duration >= e2) @@ -48,8 +48,8 @@ test('elapsed', function (t) { }) test('custom start time', function (t) { - const startTime = Date.now() - 1000 - const timer = new Timer(null, startTime) + var startTime = Date.now() - 1000 + var timer = new Timer(null, startTime) t.strictEqual(timer.start, startTime * 1000) timer.end() t.ok(timer.duration > 990, `duration should be circa more than 1s (was: ${timer.duration})`) // we've seen 998.752 in the wild @@ -58,9 +58,9 @@ test('custom start time', function (t) { }) test('custom end time', function (t) { - const startTime = Date.now() - 1000 - const endTime = startTime + 2000.123 - const timer = new Timer(null, startTime) + var startTime = Date.now() - 1000 + var endTime = startTime + 2000.123 + var timer = new Timer(null, startTime) timer.end(endTime) t.strictEqual(timer.duration, 2000.123) t.end() diff --git a/test/instrumentation/transaction.test.js b/test/instrumentation/transaction.test.js index cbf75362f1..b5a0af09cc 100644 --- a/test/instrumentation/transaction.test.js +++ b/test/instrumentation/transaction.test.js @@ -20,14 +20,14 @@ const agent = require('../..').start({ transport () { return new CapturingTransport() } }) -const test = require('tape') +var test = require('tape') -const Transaction = require('../../lib/instrumentation/transaction') +var Transaction = require('../../lib/instrumentation/transaction') const Span = require('../../lib/instrumentation/span') test('init', function (t) { t.test('name and type', function (t) { - const trans = new Transaction(agent, 'name', 'type') + var trans = new Transaction(agent, 'name', 'type') t.ok(/^[\da-f]{16}$/.test(trans.id)) t.ok(/^[\da-f]{32}$/.test(trans.traceId)) t.ok(/^[\da-f]{2}-[\da-f]{32}-[\da-f]{16}-[\da-f]{2}$/.test(trans.traceparent)) @@ -39,8 +39,8 @@ test('init', function (t) { }) t.test('options.childOf', function (t) { - const childOf = '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01' - const trans = new Transaction(agent, 'name', 'type', { childOf }) + var childOf = '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01' + var trans = new Transaction(agent, 'name', 'type', { childOf }) t.strictEqual(trans._context.traceparent.version, '00') t.strictEqual(trans._context.traceparent.traceId, '4bf92f3577b34da6a3ce929d0e0e4736') t.notEqual(trans._context.traceparent.id, '00f067aa0ba902b7') @@ -102,7 +102,7 @@ test('init', function (t) { }) test('#setUserContext', function (t) { - const trans = new Transaction(agent) + var trans = new Transaction(agent) t.strictEqual(trans._user, null) trans.setUserContext() t.strictEqual(trans._user, null) @@ -118,7 +118,7 @@ test('#setUserContext', function (t) { }) test('#setCustomContext', function (t) { - const trans = new Transaction(agent) + var trans = new Transaction(agent) t.strictEqual(trans._custom, null) trans.setCustomContext() t.strictEqual(trans._custom, null) @@ -135,7 +135,7 @@ test('#setCustomContext', function (t) { test('#setLabel', function (t) { t.test('valid', function (t) { - const trans = new Transaction(agent) + var trans = new Transaction(agent) t.strictEqual(trans._labels, null) t.strictEqual(trans.setLabel(), false) t.strictEqual(trans._labels, null) @@ -149,7 +149,7 @@ test('#setLabel', function (t) { }) t.test('invalid', function (t) { - const trans = new Transaction(agent) + var trans = new Transaction(agent) t.strictEqual(trans._labels, null) t.strictEqual(trans.setLabel(), false) t.strictEqual(trans._labels, null) @@ -164,7 +164,7 @@ test('#setLabel', function (t) { }) test('#addLabels', function (t) { - const trans = new Transaction(agent) + var trans = new Transaction(agent) t.strictEqual(trans._labels, null) t.strictEqual(trans.setLabel(), false) @@ -198,8 +198,8 @@ test('#addLabels', function (t) { test('#startSpan()', function (t) { t.test('basic', function (t) { - const trans = new Transaction(agent) - const span = trans.startSpan('span-name', 'span-type') + var trans = new Transaction(agent) + var span = trans.startSpan('span-name', 'span-type') t.ok(span, 'should return a span') t.strictEqual(span.name, 'span-name') t.strictEqual(span.type, 'span-type') @@ -207,20 +207,20 @@ test('#startSpan()', function (t) { }) t.test('options.startTime', function (t) { - const trans = new Transaction(agent) - const startTime = Date.now() - 1000 - const span = trans.startSpan(null, null, { startTime }) + var trans = new Transaction(agent) + var startTime = Date.now() - 1000 + var span = trans.startSpan(null, null, { startTime }) span.end() - const duration = span.duration() + var duration = span.duration() t.ok(duration > 990, `duration should be circa more than 1s (was: ${duration})`) // we've seen 998.752 in the wild t.ok(duration < 1100, `duration should be less than 1.1s (was: ${duration})`) t.end() }) t.test('options.childOf', function (t) { - const trans = new Transaction(agent) - const childOf = '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01' - const span = trans.startSpan(null, null, { childOf }) + var trans = new Transaction(agent) + var childOf = '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01' + var span = trans.startSpan(null, null, { childOf }) t.strictEqual(span._context.traceparent.version, '00') t.strictEqual(span._context.traceparent.traceId, '4bf92f3577b34da6a3ce929d0e0e4736') t.notEqual(span._context.traceparent.id, '00f067aa0ba902b7') @@ -233,7 +233,7 @@ test('#startSpan()', function (t) { test('#end() - with result', function (t) { agent._apmClient.clear() - const trans = new Transaction(agent) + var trans = new Transaction(agent) trans.end('test-result') t.strictEqual(trans.ended, true) t.strictEqual(trans.result, 'test-result') @@ -248,7 +248,7 @@ test('#end() - with result', function (t) { test('#duration()', function (t) { agent._apmClient.clear() - const trans = new Transaction(agent) + var trans = new Transaction(agent) setTimeout(function () { trans.end() @@ -263,17 +263,17 @@ test('#duration()', function (t) { }) test('#duration() - un-ended transaction', function (t) { - const trans = new Transaction(agent) + var trans = new Transaction(agent) t.strictEqual(trans.duration(), null) t.end() }) test('custom start time', function (t) { - const startTime = Date.now() - 1000 - const trans = new Transaction(agent, null, null, { startTime }) + var startTime = Date.now() - 1000 + var trans = new Transaction(agent, null, null, { startTime }) trans.end() - const duration = trans.duration() + var duration = trans.duration() t.ok(duration > 990, `duration should be circa more than 1s (was: ${duration})`) // we've seen 998.752 in the wild t.ok(duration < 1100, `duration should be less than 1.1s (was: ${duration})`) @@ -281,9 +281,9 @@ test('custom start time', function (t) { }) test('#end(time)', function (t) { - const startTime = Date.now() - 1000 - const endTime = startTime + 2000.123 - const trans = new Transaction(agent, null, null, { startTime }) + var startTime = Date.now() - 1000 + var endTime = startTime + 2000.123 + var trans = new Transaction(agent, null, null, { startTime }) trans.end(null, endTime) t.strictEqual(trans.duration(), 2000.123) @@ -292,7 +292,7 @@ test('#end(time)', function (t) { }) test('#setDefaultName() - with initial value', function (t) { - const trans = new Transaction(agent, 'default-1') + var trans = new Transaction(agent, 'default-1') t.strictEqual(trans.name, 'default-1') trans.setDefaultName('default-2') t.strictEqual(trans.name, 'default-2') @@ -300,7 +300,7 @@ test('#setDefaultName() - with initial value', function (t) { }) test('#setDefaultName() - no initial value', function (t) { - const trans = new Transaction(agent) + var trans = new Transaction(agent) t.strictEqual(trans.name, 'unnamed') trans.setDefaultName('default') t.strictEqual(trans.name, 'default') @@ -308,7 +308,7 @@ test('#setDefaultName() - no initial value', function (t) { }) test('name - custom first, then default', function (t) { - const trans = new Transaction(agent) + var trans = new Transaction(agent) trans.name = 'custom' trans.setDefaultName('default') t.strictEqual(trans.name, 'custom') @@ -316,7 +316,7 @@ test('name - custom first, then default', function (t) { }) test('name - default first, then custom', function (t) { - const trans = new Transaction(agent) + var trans = new Transaction(agent) trans.setDefaultName('default') trans.name = 'custom' t.strictEqual(trans.name, 'custom') @@ -334,7 +334,7 @@ test('parallel transactions', function (t) { } setImmediate(function () { - const t1 = new Transaction(agent, 'first') + var t1 = new Transaction(agent, 'first') setTimeout(function () { t1.end() finish() @@ -342,7 +342,7 @@ test('parallel transactions', function (t) { }) setTimeout(function () { - const t2 = new Transaction(agent, 'second') + var t2 = new Transaction(agent, 'second') setTimeout(function () { t2.end() }, 25) @@ -350,7 +350,7 @@ test('parallel transactions', function (t) { }) test('#_encode() - un-ended', function (t) { - const trans = new Transaction(agent) + var trans = new Transaction(agent) t.strictEqual(trans._encode(), null, 'cannot encode un-ended transaction') t.end() }) @@ -358,8 +358,8 @@ test('#_encode() - un-ended', function (t) { test('#_encode() - ended', function (t) { agent._apmClient.clear() - const trans = new Transaction(agent) - const timerStart = trans._timer.start + var trans = new Transaction(agent) + var timerStart = trans._timer.start trans.end() const payload = agent._apmClient.transactions[0] @@ -382,8 +382,8 @@ test('#_encode() - ended', function (t) { test('#_encode() - with meta data', function (t) { agent._apmClient.clear() - const trans = new Transaction(agent, 'foo', 'bar') - const timerStart = trans._timer.start + var trans = new Transaction(agent, 'foo', 'bar') + var timerStart = trans._timer.start trans.result = 'baz' trans.setUserContext({ foo: 1 }) trans.setLabel('bar', 1) @@ -410,8 +410,8 @@ test('#_encode() - with meta data', function (t) { test('#_encode() - http request meta data', function (t) { agent._apmClient.clear() - const trans = new Transaction(agent) - const timerStart = trans._timer.start + var trans = new Transaction(agent) + var timerStart = trans._timer.start trans.req = mockRequest() trans.end() @@ -469,10 +469,10 @@ test('#_encode() - http request meta data', function (t) { }) test('#_encode() - with spans', function (t) { - const trans = new Transaction(agent, 'single-name', 'type') - const timerStart = trans._timer.start + var trans = new Transaction(agent, 'single-name', 'type') + var timerStart = trans._timer.start trans.result = 'result' - const span = trans.startSpan('span') + var span = trans.startSpan('span') span.end() trans.end() @@ -505,12 +505,12 @@ test('#_encode() - dropped spans', function (t) { const oldTransactionMaxSpans = agent._conf.transactionMaxSpans agent._conf.transactionMaxSpans = 2 - const trans = new Transaction(agent, 'single-name', 'type') - const timerStart = trans._timer.start + var trans = new Transaction(agent, 'single-name', 'type') + var timerStart = trans._timer.start trans.result = 'result' - const span0 = trans.startSpan('s0', 'type0') + var span0 = trans.startSpan('s0', 'type0') trans.startSpan('s1', 'type1') - const span2 = trans.startSpan('s2', { exitSpan: true }) + var span2 = trans.startSpan('s2', { exitSpan: true }) if (span2.isRecorded()) { t.fail('should have dropped the span') } @@ -549,12 +549,12 @@ test('#_encode() - not sampled', function (t) { const oldTransactionSampleRate = agent._conf.transactionSampleRate agent._conf.transactionSampleRate = 0 - const trans = new Transaction(agent, 'single-name', 'type') - const timerStart = trans._timer.start + var trans = new Transaction(agent, 'single-name', 'type') + var timerStart = trans._timer.start trans.result = 'result' trans.req = mockRequest() trans.res = mockResponse() - const span = trans.startSpan() + var span = trans.startSpan() t.notOk(span) trans.end() @@ -572,7 +572,7 @@ test('#_encode() - not sampled', function (t) { }) test('#ids', function (t) { - const trans = new Transaction(agent) + var trans = new Transaction(agent) t.deepLooseEqual(trans.ids, { 'trace.id': trans.traceId, 'transaction.id': trans.id @@ -581,7 +581,7 @@ test('#ids', function (t) { }) test('#toString()', function (t) { - const trans = new Transaction(agent) + var trans = new Transaction(agent) t.strictEqual(trans.toString(), `trace.id=${trans.traceId} transaction.id=${trans.id}`) t.end() }) @@ -667,8 +667,8 @@ function mockRequest () { } function mockResponse () { - const statusLine = 'HTTP/1.1 200 OK\r\n' - const msgHeaders = 'Date: Tue, 10 Jun 2014 07:29:20 GMT\r\n' + + var statusLine = 'HTTP/1.1 200 OK\r\n' + var msgHeaders = 'Date: Tue, 10 Jun 2014 07:29:20 GMT\r\n' + 'Connection: keep-alive\r\n' + 'Transfer-Encoding: chunked\r\n' + 'Age: foo\r\n' + diff --git a/test/integration/503.test.js b/test/integration/503.test.js index f31fff2609..5784371ce9 100644 --- a/test/integration/503.test.js +++ b/test/integration/503.test.js @@ -6,10 +6,10 @@ 'use strict' -const getPort = require('get-port') +var getPort = require('get-port') getPort().then(function (port) { - const agent = require('../../').start({ + var agent = require('../../').start({ serviceName: 'test', serverUrl: 'http://localhost:' + port, captureExceptions: false, @@ -18,11 +18,11 @@ getPort().then(function (port) { disableInstrumentations: ['http'] // avoid the agent instrumenting the mock APM Server }) - const http = require('http') - const test = require('tape') + var http = require('http') + var test = require('tape') test('should not throw on 503', function (t) { - const server = http.createServer(function (req, res) { + var server = http.createServer(function (req, res) { res.statusCode = 503 res.setHeader('Content-Type', 'application/json') res.end('{"error":"something"}') diff --git a/test/integration/abort-on-invalid-cert.test.js b/test/integration/abort-on-invalid-cert.test.js index 96b7b12f8f..28e2cf7a98 100644 --- a/test/integration/abort-on-invalid-cert.test.js +++ b/test/integration/abort-on-invalid-cert.test.js @@ -6,24 +6,24 @@ 'use strict' -const getPort = require('get-port') +var getPort = require('get-port') getPort().then(function (port) { - const agent = require('../../').start({ + var agent = require('../../').start({ serviceName: 'test', serverUrl: 'https://localhost:' + port, metricsInterval: 0, centralConfig: false }) - const https = require('https') - const pem = require('https-pem') - const test = require('tape') + var https = require('https') + var pem = require('https-pem') + var test = require('tape') test('should not allow self signed certificate', function (t) { t.plan(1) - const server = https.createServer(pem, function (req, res) { + var server = https.createServer(pem, function (req, res) { // Gotcha: there's no way to know if the agent failed except setting // `logLevel < error` and looking at stderr, which is a bit cumbersome. // This is easier. diff --git a/test/integration/allow-invalid-cert.test.js b/test/integration/allow-invalid-cert.test.js index 1674005b28..0b2422b8fd 100644 --- a/test/integration/allow-invalid-cert.test.js +++ b/test/integration/allow-invalid-cert.test.js @@ -6,10 +6,10 @@ 'use strict' -const getPort = require('get-port') +var getPort = require('get-port') getPort().then(function (port) { - const agent = require('../../').start({ + var agent = require('../../').start({ serviceName: 'test-allow-invalid-cert', serverUrl: 'https://localhost:' + port, captureExceptions: false, @@ -20,14 +20,14 @@ getPort().then(function (port) { verifyServerCert: false }) - const https = require('https') - const pem = require('https-pem') - const test = require('tape') + var https = require('https') + var pem = require('https-pem') + var test = require('tape') test('should allow self signed certificate', function (t) { t.plan(3) - const server = https.createServer(pem, function (req, res) { + var server = https.createServer(pem, function (req, res) { t.pass('server received client request') res.end() }) diff --git a/test/integration/no-sampling.test.js b/test/integration/no-sampling.test.js index 1bab665720..ded17988c4 100644 --- a/test/integration/no-sampling.test.js +++ b/test/integration/no-sampling.test.js @@ -6,11 +6,11 @@ 'use strict' -const getPort = require('get-port') -const ndjson = require('ndjson') +var getPort = require('get-port') +var ndjson = require('ndjson') getPort().then(function (port) { - const agent = require('../../').start({ + var agent = require('../../').start({ serviceName: 'test-no-sampling', serverUrl: 'http://localhost:' + port, captureExceptions: false, @@ -21,9 +21,9 @@ getPort().then(function (port) { apiRequestTime: '1s' }) - const http = require('http') - const zlib = require('zlib') - const test = require('tape') + var http = require('http') + var zlib = require('zlib') + var test = require('tape') test('should not sample', function (t) { var server = http.createServer(function (req, res) { @@ -57,7 +57,7 @@ getPort().then(function (port) { } function makeTransaction (cb) { - const trans = agent.startTransaction('foo', 'bar') + var trans = agent.startTransaction('foo', 'bar') setTimeout(function () { trans.end() process.nextTick(cb) diff --git a/test/integration/server-url-path.test.js b/test/integration/server-url-path.test.js index 74876d4117..23c7266d5e 100644 --- a/test/integration/server-url-path.test.js +++ b/test/integration/server-url-path.test.js @@ -6,10 +6,10 @@ 'use strict' -const getPort = require('get-port') +var getPort = require('get-port') getPort().then(function (port) { - const agent = require('../../').start({ + var agent = require('../../').start({ serviceName: 'test', serverUrl: 'http://localhost:' + port + '/sub', captureExceptions: false, @@ -19,8 +19,8 @@ getPort().then(function (port) { disableInstrumentations: ['http'] // avoid the agent instrumenting the mock APM Server }) - const http = require('http') - const test = require('tape') + var http = require('http') + var test = require('tape') test('should allow path in serverUrl', function (t) { var server = http.createServer(function (req, res) { diff --git a/test/integration/socket-close.test.js b/test/integration/socket-close.test.js index 3809d60229..a85ef8bb53 100644 --- a/test/integration/socket-close.test.js +++ b/test/integration/socket-close.test.js @@ -6,10 +6,10 @@ 'use strict' -const getPort = require('get-port') +var getPort = require('get-port') getPort().then(function (port) { - const agent = require('../../').start({ + var agent = require('../../').start({ serviceName: 'test', serverUrl: 'http://localhost:' + port, captureExceptions: false, @@ -19,11 +19,11 @@ getPort().then(function (port) { disableInstrumentations: ['http'] // avoid the agent instrumenting the mock APM Server }) - const net = require('net') - const test = require('tape') + var net = require('net') + var test = require('tape') test('should not throw on socket close', function (t) { - const server = net.createServer(function (socket) { + var server = net.createServer(function (socket) { socket.destroy() }) diff --git a/test/integration/verify-server-ca-cert.test.js b/test/integration/verify-server-ca-cert.test.js index 18cd27ce7f..09dbab94a5 100644 --- a/test/integration/verify-server-ca-cert.test.js +++ b/test/integration/verify-server-ca-cert.test.js @@ -6,13 +6,13 @@ 'use strict' -const getPort = require('get-port') +var getPort = require('get-port') getPort().then(function (port) { - const fs = require('fs') - const path = require('path') + var fs = require('fs') + var path = require('path') - const agent = require('../../').start({ + var agent = require('../../').start({ serviceName: 'test', serverUrl: 'https://localhost:' + port, captureExceptions: false, @@ -23,16 +23,16 @@ getPort().then(function (port) { serverCaCertFile: path.join(__dirname, 'cert.pem') // self-signed certificate }) - const https = require('https') - const test = require('tape') + var https = require('https') + var test = require('tape') test('should allow self signed certificate', function (t) { t.plan(3) - const cert = fs.readFileSync(path.join(__dirname, 'cert.pem')) - const key = fs.readFileSync(path.join(__dirname, 'key.pem')) + var cert = fs.readFileSync(path.join(__dirname, 'cert.pem')) + var key = fs.readFileSync(path.join(__dirname, 'key.pem')) - const server = https.createServer({ cert, key }, function (req, res) { + var server = https.createServer({ cert, key }, function (req, res) { t.pass('server received client request') res.end() }) diff --git a/test/lambda/lambda.test.js b/test/lambda/lambda.test.js index 3417ce2717..3edede27b0 100644 --- a/test/lambda/lambda.test.js +++ b/test/lambda/lambda.test.js @@ -927,7 +927,7 @@ tape.test('lambda transactions', function (suite) { const wrappedHandler = apm.lambda(handler) // Save current and apply new config values. - const confToRestore = {} + var confToRestore = {} if (c.conf) { Object.keys(c.conf).forEach(k => { confToRestore[k] = apm._conf[k] diff --git a/test/lambda/metadata.test.js b/test/lambda/metadata.test.js index b30fefebe3..274664ac18 100644 --- a/test/lambda/metadata.test.js +++ b/test/lambda/metadata.test.js @@ -90,7 +90,7 @@ tape.test('lambda config & metadata tests', function (suite) { t.error(err, `no error from executing the lambda handler: err=${JSON.stringify(err)}`) t.strictEqual(result, output) - const metadata = server.events[0].metadata + var metadata = server.events[0].metadata t.ok(metadata, 'got metadata') t.same(metadata.service.name, process.env.AWS_LAMBDA_FUNCTION_NAME, 'service.name') t.same(metadata.service.version, '42', 'service.version') diff --git a/test/lambda/metadata2.test.js b/test/lambda/metadata2.test.js index 60b57c787b..acf5880128 100644 --- a/test/lambda/metadata2.test.js +++ b/test/lambda/metadata2.test.js @@ -69,7 +69,7 @@ tape.test('lambda metadata respects config settings', function (suite) { callback: function (err, result) { t.error(err, `no error from executing the lambda handler: err=${JSON.stringify(err)}`) - const metadata = server.events[0].metadata + var metadata = server.events[0].metadata t.ok(metadata, 'got metadata') t.same(metadata.service.name, 'my-service', 'service.name from serviceName config') t.same(metadata.service.version, '1.2.3', 'service.version from serviceVersion config') diff --git a/test/logging-preamble.test.js b/test/logging-preamble.test.js index 80920fecb5..ed7ed37431 100644 --- a/test/logging-preamble.test.js +++ b/test/logging-preamble.test.js @@ -6,12 +6,12 @@ 'use strict' -const fs = require('fs') -const os = require('os') -const path = require('path') +var fs = require('fs') +var os = require('os') +var path = require('path') -const mkdirp = require('mkdirp') -const rimraf = require('rimraf') +var mkdirp = require('mkdirp') +var rimraf = require('rimraf') const test = require('tape') const AGENT_VERSION = require('../package.json').version diff --git a/test/metrics/breakdown.test.js b/test/metrics/breakdown.test.js index 4412382961..04772892d9 100644 --- a/test/metrics/breakdown.test.js +++ b/test/metrics/breakdown.test.js @@ -150,8 +150,8 @@ function waitForAgentToSendBreakdownMetrics (agent, waitCb) { test('includes breakdown when sampling', t => { const agent = new Agent().start(testAgentOpts) - const transaction = agent.startTransaction('foo', 'bar') - const span = agent.startSpan('s0 name', 's0 type') + var transaction = agent.startTransaction('foo', 'bar') + var span = agent.startSpan('s0 name', 's0 type') if (span) span.end() transaction.end() @@ -182,7 +182,7 @@ test('includes breakdown when sampling', t => { test('only transaction', t => { const agent = new Agent().start(testAgentOpts) - const transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) + var transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) transaction.end(null, 30) waitForAgentToSendBreakdownMetrics(agent, function (err) { @@ -206,8 +206,8 @@ test('only transaction', t => { test('with single sub-span', t => { const agent = new Agent().start(testAgentOpts) - const transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) - const span = agent.startSpan('SELECT *', 'db.mysql', { startTime: 10 }) + var transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) + var span = agent.startSpan('SELECT *', 'db.mysql', { startTime: 10 }) if (span) span.end(20) transaction.end(null, 30) @@ -239,8 +239,8 @@ test('with single sub-span', t => { test('with single app sub-span', t => { const agent = new Agent().start(testAgentOpts) - const transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) - const span = agent.startSpan('foo', 'app', { startTime: 10 }) + var transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) + var span = agent.startSpan('foo', 'app', { startTime: 10 }) if (span) span.end(20) transaction.end(null, 30) @@ -266,8 +266,8 @@ test('with single app sub-span', t => { test('with parallel sub-spans', t => { const agent = new Agent().start(testAgentOpts) - const transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) - let span0 + var transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) + var span0 setImmediate(function () { span0 = agent.startSpan('SELECT * FROM a', 'db.mysql', { startTime: 10 }) setImmediate(function () { @@ -279,7 +279,7 @@ test('with parallel sub-spans', t => { // transaction for the special case of (a) contextManager="patch" such that // we are using "patch-async.js" and (b) use of `agent.destroy(); new // Agent()`. The latter breaks patch-async's patching of setImmediate. - const span1 = agent.startSpan('SELECT * FROM b', 'db.mysql', + var span1 = agent.startSpan('SELECT * FROM b', 'db.mysql', { startTime: 10, childOf: transaction }) setImmediate(function () { if (span1) span1.end(20) @@ -315,8 +315,8 @@ test('with parallel sub-spans', t => { test('with overlapping sub-spans', t => { const agent = new Agent().start(testAgentOpts) - const transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) - let span0 + var transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) + var span0 setImmediate(function () { span0 = agent.startSpan('SELECT * FROM a', 'db.mysql', { startTime: 10 }) setImmediate(function () { @@ -325,7 +325,7 @@ test('with overlapping sub-spans', t => { }) setImmediate(function () { // See "childOf" comment above for why `childOf` is used here. - const span1 = agent.startSpan('SELECT * FROM b', 'db.mysql', + var span1 = agent.startSpan('SELECT * FROM b', 'db.mysql', { startTime: 15, childOf: transaction }) setImmediate(function () { if (span1) span1.end(25) @@ -363,10 +363,10 @@ test('with overlapping sub-spans', t => { test('with sequential sub-spans', t => { const agent = new Agent().start(testAgentOpts) - const transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) - const span0 = agent.startSpan('SELECT * FROM a', 'db.mysql', { startTime: 5 }) + var transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) + var span0 = agent.startSpan('SELECT * FROM a', 'db.mysql', { startTime: 5 }) if (span0) span0.end(15) - const span1 = agent.startSpan('SELECT * FROM b', 'db.mysql', { startTime: 15 }) + var span1 = agent.startSpan('SELECT * FROM b', 'db.mysql', { startTime: 15 }) if (span1) span1.end(25) transaction.end(null, 30) @@ -398,10 +398,10 @@ test('with sequential sub-spans', t => { test('with sub-spans returning to app time', t => { const agent = new Agent().start(testAgentOpts) - const transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) - const span0 = agent.startSpan('SELECT * FROM a', 'db.mysql', { startTime: 10 }) + var transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) + var span0 = agent.startSpan('SELECT * FROM a', 'db.mysql', { startTime: 10 }) if (span0) span0.end(15) - const span1 = agent.startSpan('SELECT * FROM b', 'db.mysql', { startTime: 20 }) + var span1 = agent.startSpan('SELECT * FROM b', 'db.mysql', { startTime: 20 }) if (span1) span1.end(25) transaction.end(null, 30) @@ -433,9 +433,9 @@ test('with sub-spans returning to app time', t => { test('with overlapping nested async sub-spans', t => { const agent = new Agent().start(testAgentOpts) - const transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) - const span0 = agent.startSpan('foo', 'app', { startTime: 10 }) - const span1 = agent.startSpan('SELECT *', 'db.mysql', { startTime: 15, childOf: span0 }) + var transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) + var span0 = agent.startSpan('foo', 'app', { startTime: 10 }) + var span1 = agent.startSpan('SELECT *', 'db.mysql', { startTime: 15, childOf: span0 }) if (span0) span0.end(20) if (span1) span1.end(25) transaction.end(null, 30) @@ -468,11 +468,11 @@ test('with overlapping nested async sub-spans', t => { test('with app sub-span extending beyond end', t => { const agent = new Agent().start(testAgentOpts) - const transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) - const span0 = agent.startSpan('foo', 'app', { startTime: 10 }) + var transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) + var span0 = agent.startSpan('foo', 'app', { startTime: 10 }) transaction.end(null, 20) // span1 is *not* created, because cannot create a span on an ended transaction. - const span1 = agent.startSpan('SELECT *', 'db.mysql', { startTime: 20, childOf: span0 }) + var span1 = agent.startSpan('SELECT *', 'db.mysql', { startTime: 20, childOf: span0 }) if (span0) span0.end(30) if (span1) span1.end(30) @@ -499,8 +499,8 @@ test('with app sub-span extending beyond end', t => { test('with other sub-span extending beyond end', t => { const agent = new Agent().start(testAgentOpts) - const transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) - const span = agent.startSpan('SELECT *', 'db.mysql', { startTime: 10 }) + var transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) + var span = agent.startSpan('SELECT *', 'db.mysql', { startTime: 10 }) transaction.end(null, 20) if (span) span.end(30) @@ -527,9 +527,9 @@ test('with other sub-span extending beyond end', t => { test('with other sub-span starting after end', t => { const agent = new Agent().start(testAgentOpts) - const transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) + var transaction = agent.startTransaction('foo', 'bar', { startTime: 0 }) transaction.end(null, 10) - const span = agent.startSpan('SELECT *', 'db.mysql', { startTime: 20, childOf: transaction }) + var span = agent.startSpan('SELECT *', 'db.mysql', { startTime: 20, childOf: transaction }) if (span) span.end(30) waitForAgentToSendBreakdownMetrics(agent, function (err) { diff --git a/test/outcome.test.js b/test/outcome.test.js index 9ca7e04832..dda3fcf2e8 100644 --- a/test/outcome.test.js +++ b/test/outcome.test.js @@ -5,7 +5,7 @@ */ 'use strict' -const agent = require('..').start({ +var agent = require('..').start({ serviceName: 'test-outcome', captureExceptions: true, metricsInterval: 0, diff --git a/test/parsers.test.js b/test/parsers.test.js index 36ef6bd370..4abe20b86f 100644 --- a/test/parsers.test.js +++ b/test/parsers.test.js @@ -6,11 +6,11 @@ 'use strict' -const http = require('http') +var http = require('http') -const test = require('tape') +var test = require('tape') -const parsers = require('../lib/parsers') +var parsers = require('../lib/parsers') test('#getContextFromResponse()', function (t) { t.test('for error (before headers)', function (t) { @@ -21,7 +21,7 @@ test('#getContextFromResponse()', function (t) { res.sendDate = false - const context = parsers.getContextFromResponse(res, { captureHeaders: true }, true) + var context = parsers.getContextFromResponse(res, { captureHeaders: true }, true) t.deepEqual(context, { status_code: 200, headers: {}, @@ -42,7 +42,7 @@ test('#getContextFromResponse()', function (t) { res.sendDate = false res.write('foo') - const context = parsers.getContextFromResponse(res, { captureHeaders: true }, true) + var context = parsers.getContextFromResponse(res, { captureHeaders: true }, true) t.deepEqual(context, { status_code: 200, headers: { connection: 'close', 'transfer-encoding': 'chunked' }, @@ -57,7 +57,7 @@ test('#getContextFromResponse()', function (t) { t.test('for error (request finished)', function (t) { onRequest(function (req, res) { req.on('end', function () { - const context = parsers.getContextFromResponse(res, { captureHeaders: true }, true) + var context = parsers.getContextFromResponse(res, { captureHeaders: true }, true) t.deepEqual(context, { status_code: 200, headers: { connection: 'close', 'content-length': '0' }, @@ -76,7 +76,7 @@ test('#getContextFromResponse()', function (t) { t.test('for transaction', function (t) { onRequest(function (req, res) { req.on('end', function () { - const context = parsers.getContextFromResponse(res, { captureHeaders: true }, false) + var context = parsers.getContextFromResponse(res, { captureHeaders: true }, false) t.deepEqual(context, { status_code: 200, headers: { connection: 'close', 'content-length': '0' } @@ -91,8 +91,8 @@ test('#getContextFromResponse()', function (t) { test('#getContextFromRequest()', function (t) { t.test('should parse a request object', function (t) { - const conf = { captureHeaders: true, captureBody: 'off' } - const parsed = parsers.getContextFromRequest(getMockReq(), conf) + var conf = { captureHeaders: true, captureBody: 'off' } + var parsed = parsers.getContextFromRequest(getMockReq(), conf) t.deepEqual(parsed, { http_version: '1.1', method: 'GET', @@ -116,9 +116,9 @@ test('#getContextFromRequest()', function (t) { }) t.test('full URI', function (t) { - const req = getMockReq() + var req = getMockReq() req.url = 'https://www.example.com:8080/some/path?key=value' - const parsed = parsers.getContextFromRequest(req, {}) + var parsed = parsers.getContextFromRequest(req, {}) t.deepEqual(parsed.url, { pathname: '/some/path', search: '?key=value', @@ -132,9 +132,9 @@ test('#getContextFromRequest()', function (t) { }) t.test('port in host header', function (t) { - const req = getMockReq() + var req = getMockReq() req.headers.host = 'example.com:8080' - const parsed = parsers.getContextFromRequest(req, {}) + var parsed = parsers.getContextFromRequest(req, {}) t.deepEqual(parsed.url, { hostname: 'example.com', port: '8080', @@ -148,9 +148,9 @@ test('#getContextFromRequest()', function (t) { }) t.test('empty query string', function (t) { - const req = getMockReq() + var req = getMockReq() req.url = '/some/path?' - const parsed = parsers.getContextFromRequest(req, {}) + var parsed = parsers.getContextFromRequest(req, {}) t.deepEqual(parsed.url, { hostname: 'example.com', pathname: '/some/path', @@ -163,42 +163,42 @@ test('#getContextFromRequest()', function (t) { }) t.test('should not log body if opts.body is false', function (t) { - const conf = { captureBody: 'off' } - const req = getMockReq() + var conf = { captureBody: 'off' } + var req = getMockReq() req.body = 'secret stuff' req.headers['content-length'] = String(req.body.length) - const parsed = parsers.getContextFromRequest(req, conf) + var parsed = parsers.getContextFromRequest(req, conf) t.strictEqual(parsed.body, '[REDACTED]') t.end() }) t.test('body is object', function (t) { - const conf = { captureBody: 'all' } - const req = getMockReq() + var conf = { captureBody: 'all' } + var req = getMockReq() req.body = { foo: 42 } req.headers['content-length'] = JSON.stringify(req.body).length - const parsed = parsers.getContextFromRequest(req, conf) + var parsed = parsers.getContextFromRequest(req, conf) t.deepEqual(parsed.body, JSON.stringify({ foo: 42 })) t.end() }) t.test('body is object, but not safe to stringify', function (t) { - const conf = { captureBody: 'all' } - const req = getMockReq() + var conf = { captureBody: 'all' } + var req = getMockReq() req.body = { foo: 42 } req.body.bar = req.body req.headers['transfer-encoding'] = 'chunked' - const parsed = parsers.getContextFromRequest(req, conf) + var parsed = parsers.getContextFromRequest(req, conf) t.deepEqual(parsed.body, JSON.stringify({ foo: 42, bar: '[Circular]' })) t.end() }) t.test('body is an array', function (t) { - const conf = { captureBody: 'all' } - const req = getMockReq() + var conf = { captureBody: 'all' } + var req = getMockReq() req.body = [{ foo: 42 }] req.headers['content-length'] = JSON.stringify(req.body).length - const parsed = parsers.getContextFromRequest(req, conf) + var parsed = parsers.getContextFromRequest(req, conf) t.deepEqual(parsed.body, JSON.stringify([{ foo: 42 }])) t.end() }) @@ -235,14 +235,14 @@ test('#getContextFromRequest()', function (t) { }) function onRequest (cb) { - const server = http.createServer(cb) + var server = http.createServer(cb) server.listen(function () { - const opts = { + var opts = { agent: new http.Agent(), port: server.address().port } - const req = http.request(opts, function (res) { + var req = http.request(opts, function (res) { res.on('end', function () { server.close() }) diff --git a/test/redact-secrets/is-secret.test.js b/test/redact-secrets/is-secret.test.js index d32dee6f32..4a15a7ecb2 100644 --- a/test/redact-secrets/is-secret.test.js +++ b/test/redact-secrets/is-secret.test.js @@ -34,8 +34,8 @@ require('../..').start({ disableSend: true }) -const test = require('tape') -const isSecret = require('../../lib/redact-secrets/is-secret') +var test = require('tape') +var isSecret = require('../../lib/redact-secrets/is-secret') test('isSecret.key true', function (t) { t.equal(isSecret.key('pass'), true) diff --git a/test/redact-secrets/redact-secrets.test.js b/test/redact-secrets/redact-secrets.test.js index da8748ac4b..d599a1d454 100644 --- a/test/redact-secrets/redact-secrets.test.js +++ b/test/redact-secrets/redact-secrets.test.js @@ -34,12 +34,12 @@ require('../..').start({ disableSend: true }) -const test = require('tape') -const clone = require('clone') -const redact = require('../../lib/redact-secrets') +var test = require('tape') +var clone = require('clone') +var redact = require('../../lib/redact-secrets') test('redact.map', function (t) { - const input = { + var input = { foo: 'non-secret', secret: 'secret', sub1: { @@ -52,7 +52,7 @@ test('redact.map', function (t) { }] } - const expected = { + var expected = { foo: 'non-secret', secret: 'redacted', sub1: { @@ -65,8 +65,8 @@ test('redact.map', function (t) { }] } - const orig = clone(input) - const result = redact('redacted').map(input) + var orig = clone(input) + var result = redact('redacted').map(input) t.deepEqual(result, expected) t.deepEqual(input, orig) @@ -74,7 +74,7 @@ test('redact.map', function (t) { }) test('redact.forEach', function (t) { - const input = { + var input = { foo: 'non-secret', secret: 'secret', sub1: { @@ -87,7 +87,7 @@ test('redact.forEach', function (t) { }] } - const expected = { + var expected = { foo: 'non-secret', secret: 'redacted', sub1: { @@ -100,7 +100,7 @@ test('redact.forEach', function (t) { }] } - const result = redact('redacted').forEach(input) + var result = redact('redacted').forEach(input) t.equal(result, undefined) t.deepEqual(input, expected) diff --git a/test/sanitize-field-names/hapi.test.js b/test/sanitize-field-names/hapi.test.js index 71f9842a97..9abf8f9b2c 100644 --- a/test/sanitize-field-names/hapi.test.js +++ b/test/sanitize-field-names/hapi.test.js @@ -15,7 +15,7 @@ const { } = require('./_shared') const agent = require('../..').start(createAgentConfig()) -const isHapiIncompat = require('../_is_hapi_incompat') +var isHapiIncompat = require('../_is_hapi_incompat') if (isHapiIncompat('@hapi/hapi')) { // Skip out of this test. process.exit() diff --git a/test/service-resource-inference.test.js b/test/service-resource-inference.test.js index e4d71d3d8e..19061f93d2 100644 --- a/test/service-resource-inference.test.js +++ b/test/service-resource-inference.test.js @@ -28,7 +28,7 @@ test('setup: current trans', t => { t.end() }) -const testData = require('./fixtures/json-specs/service_resource_inference.json') +var testData = require('./fixtures/json-specs/service_resource_inference.json') testData.forEach(testDatum => { test(testDatum.failure_message, t => { // 1. Create a span according to `testDatum.span`. diff --git a/test/sourcemaps/index.test.js b/test/sourcemaps/index.test.js index bbc20e9cf0..5ffef0b348 100644 --- a/test/sourcemaps/index.test.js +++ b/test/sourcemaps/index.test.js @@ -6,11 +6,11 @@ 'use strict' -const path = require('path') +var path = require('path') -const test = require('tape') +var test = require('tape') -const agent = require('../../').start({ +var agent = require('../../').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -46,7 +46,7 @@ test('fails', function (t) { t.strictEqual(error.exception.type, 'Error') t.strictEqual(error.culprit, `generateError (${path.join('test', 'sourcemaps', 'fixtures', 'lib', 'error-inline-broken.js')})`) - const frame = error.exception.stacktrace[0] + var frame = error.exception.stacktrace[0] t.strictEqual(frame.filename, path.join('test', 'sourcemaps', 'fixtures', 'lib', 'error-inline-broken.js')) t.strictEqual(frame.lineno, 6) t.strictEqual(frame.function, 'generateError') @@ -63,7 +63,7 @@ test('fails', function (t) { t.strictEqual(error.exception.type, 'Error') t.strictEqual(error.culprit, `generateError (${path.join('test', 'sourcemaps', 'fixtures', 'lib', 'error-map-missing.js')})`) - const frame = error.exception.stacktrace[0] + var frame = error.exception.stacktrace[0] t.strictEqual(frame.filename, path.join('test', 'sourcemaps', 'fixtures', 'lib', 'error-map-missing.js')) t.strictEqual(frame.lineno, 6) t.strictEqual(frame.function, 'generateError') @@ -80,7 +80,7 @@ test('fails', function (t) { t.strictEqual(error.exception.type, 'Error') t.strictEqual(error.culprit, `generateError (${path.join('test', 'sourcemaps', 'fixtures', 'lib', 'error-broken.js')})`) - const frame = error.exception.stacktrace[0] + var frame = error.exception.stacktrace[0] t.strictEqual(frame.filename, path.join('test', 'sourcemaps', 'fixtures', 'lib', 'error-broken.js')) t.strictEqual(frame.lineno, 6) t.strictEqual(frame.function, 'generateError') @@ -110,7 +110,7 @@ function assertSourceFound (t, error) { t.strictEqual(error.exception.type, 'Error') t.strictEqual(error.culprit, `generateError (${path.join('test', 'sourcemaps', 'fixtures', 'src', 'error.js')})`) - const frame = error.exception.stacktrace[0] + var frame = error.exception.stacktrace[0] t.strictEqual(frame.filename, path.join('test', 'sourcemaps', 'fixtures', 'src', 'error.js')) t.strictEqual(frame.lineno, 2) t.strictEqual(frame.function, 'generateError') @@ -126,7 +126,7 @@ function assertSourceNotFound (t, error) { t.strictEqual(error.exception.type, 'Error') t.strictEqual(error.culprit, `generateError (${path.join('test', 'sourcemaps', 'fixtures', 'src', 'not', 'found.js')})`) - const frame = error.exception.stacktrace[0] + var frame = error.exception.stacktrace[0] t.strictEqual(frame.filename, path.join('test', 'sourcemaps', 'fixtures', 'src', 'not', 'found.js')) t.strictEqual(frame.lineno, 2) t.strictEqual(frame.function, 'generateError') diff --git a/test/stacktraces/stacktraces.test.js b/test/stacktraces/stacktraces.test.js index 0d2a3715ce..041eb5e956 100644 --- a/test/stacktraces/stacktraces.test.js +++ b/test/stacktraces/stacktraces.test.js @@ -325,7 +325,7 @@ tape.test('gatherStackTrace()', function (suite) { } } - const cases = [ + var cases = [ { lines: 0, expectedContext: {} diff --git a/test/start/env/test.test.js b/test/start/env/test.test.js index 4072c36b44..55263bec9e 100644 --- a/test/start/env/test.test.js +++ b/test/start/env/test.test.js @@ -10,7 +10,7 @@ process.env.ELASTIC_APM_SERVICE_NAME = 'from-env' -const agent = require('../../..').start({ +var agent = require('../../..').start({ disableSend: true }) const tape = require('tape') diff --git a/test/start/file/test.test.js b/test/start/file/test.test.js index 6ac5b99248..66b06d2d24 100644 --- a/test/start/file/test.test.js +++ b/test/start/file/test.test.js @@ -11,7 +11,7 @@ process.chdir(__dirname) -const agent = require('../../..').start({ +var agent = require('../../..').start({ disableSend: true }) diff --git a/test/test.js b/test/test.js index 4f7b4fe48f..99c65c4e52 100644 --- a/test/test.js +++ b/test/test.js @@ -14,13 +14,13 @@ // // Run `node test/test.js -h` for usage. -const fs = require('fs') -const path = require('path') -const spawn = require('child_process').spawn +var fs = require('fs') +var path = require('path') +var spawn = require('child_process').spawn -const dashdash = require('dashdash') -const glob = require('glob') -const semver = require('semver') +var dashdash = require('dashdash') +var glob = require('glob') +var semver = require('semver') // ---- support functions @@ -31,7 +31,7 @@ function slugifyPath (f) { // Run a single test file. function runTestFile (test, cb) { - const args = [test.file] + var args = [test.file] if (semver.gte(process.version, '12.0.0')) { args.unshift('--unhandled-rejections=strict') } else { @@ -47,7 +47,7 @@ function runTestFile (test, cb) { } const outFile = fs.createWriteStream(outFileName) outFile.on('open', function () { - const ps = spawn('node', args, { + var ps = spawn('node', args, { stdio: ['inherit', outFile, outFile] }) ps.on('error', cb) @@ -78,7 +78,7 @@ function runTestFile (test, cb) { cb() return } - const ps = spawn('node', args, { + var ps = spawn('node', args, { stdio: 'inherit', env: test.env }) @@ -96,8 +96,8 @@ function runTestFile (test, cb) { } function series (tasks, cb) { - const results = [] - let pos = 0 + var results = [] + var pos = 0 function done (err, result) { if (err) return cb(err) @@ -125,7 +125,7 @@ function mapSeries (tasks, handler, cb) { // ---- mainline -const options = [ +var options = [ { names: ['help', 'h'], type: 'bool', @@ -146,7 +146,7 @@ const options = [ ] function main () { - const parser = dashdash.createParser({ options }) + var parser = dashdash.createParser({ options }) try { var opts = parser.parse(process.argv) } catch (e) { @@ -156,14 +156,14 @@ function main () { // Use `parser.help()` for formatted options help. if (opts.help) { - const help = parser.help().trimRight() + var help = parser.help().trimRight() console.log('usage: node test/test.js [OPTIONS]\n' + 'options:\n' + help) process.exit(0) } - const tests = glob + var tests = glob .sync( // Find all ".test.js" files, except those in "fixtures" dirs and in // "node_modules" dirs created for test packages. diff --git a/test/tracecontext/tracestate.test.js b/test/tracecontext/tracestate.test.js index 2bc8d824dd..c7f8946e38 100644 --- a/test/tracecontext/tracestate.test.js +++ b/test/tracecontext/tracestate.test.js @@ -4,7 +4,7 @@ * compliance with the BSD 2-Clause License. */ -const test = require('tape') +var test = require('tape') const TraceState = require('../../lib/tracecontext/tracestate') test('TraceState binary format functionality', function (t) { diff --git a/test/transaction-sampling.test.js b/test/transaction-sampling.test.js index 170cce0cf1..03aa6476e1 100644 --- a/test/transaction-sampling.test.js +++ b/test/transaction-sampling.test.js @@ -35,13 +35,13 @@ tape.test('various transactionSampleRate values', function (t) { } )) - const results = { + var results = { count: count, numSampled: 0, numUnsampled: 0 } - for (let i = 0; i < count; i++) { - const trans = agent.startTransaction('myTrans') + for (var i = 0; i < count; i++) { + var trans = agent.startTransaction('myTrans') if (trans && trans.sampled) { results.numSampled++ } else { @@ -95,11 +95,11 @@ tape.test('APM Server =v8.0 (which does not want unsampled transactions)', func suite.test('unsampled transactions are not sent', function (t) { // Start and end a transaction with some spans. - const t0 = agent.startTransaction('t0') - const s0 = agent.startSpan('s0', 'type') + var t0 = agent.startTransaction('t0') + var s0 = agent.startSpan('s0', 'type') process.nextTick(function () { if (s0) s0.end() - const s1 = agent.startSpan('s1', 'type') + var s1 = agent.startSpan('s1', 'type') t.ok(s1 === null, 'no span should be started for an unsampled transaction') process.nextTick(function () { if (s1) s1.end() diff --git a/test/wildcard-matcher.test.js b/test/wildcard-matcher.test.js index 33383e8c2d..b6ca3cacc2 100644 --- a/test/wildcard-matcher.test.js +++ b/test/wildcard-matcher.test.js @@ -5,7 +5,7 @@ */ 'use strict' -const test = require('tape') +var test = require('tape') const { WildcardMatcher } = require('../lib/wildcard-matcher') From 1bd39fac02ea9804b5388567556ab8b93af702ca Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Fri, 9 Jun 2023 14:22:01 -0700 Subject: [PATCH 07/10] min node for eslint@8 is 12.22.0 etc --- package.json | 4 ++-- test/script/run_tests.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 2eb9e368bc..c03e14d4f4 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,8 @@ "docs:open": "PREVIEW=1 npm run docs:build", "docs:build": "./docs/scripts/build_docs.sh apm-agent-nodejs ./docs ./build", "lint": "npm run lint:eslint && npm run lint:license-files && npm run lint:yaml-files && npm run lint:tav", - "lint:eslint": "eslint . --max-warnings=144 # requires node >10", - "lint:fix": "eslint --fix . # requires node >10", + "lint:eslint": "eslint . # requires node >12.20.0", + "lint:fix": "eslint --fix . # requires node >12.20.0", "lint:license-files": "./dev-utils/gen-notice.sh --lint . # requires node >=16", "lint:yaml-files": "./dev-utils/lint-yaml-files.sh # requires node >=10", "lint:tav": "./dev-utils/lint-tav-json.js", diff --git a/test/script/run_tests.sh b/test/script/run_tests.sh index 72ebea5f71..de99e29fc6 100755 --- a/test/script/run_tests.sh +++ b/test/script/run_tests.sh @@ -43,8 +43,8 @@ setup_env () { } run_test_suite () { - # Our current eslint requires at least node 8.10.0 - if $(./node_modules/.bin/semver -r '>=8.10.0' $(node --version) >/dev/null); then + # eslint@8 requires a more recent Node.js than our min supported node. + if $(./node_modules/.bin/semver -r '^12.22.0 || ^14.17.0 || >=16.0.0' $(node --version) >/dev/null); then npm run lint else echo "# skip lint with old node (node $(node --version))" From 7165a88dd6f965681a6b8db732cd58371adaec0d Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Fri, 9 Jun 2023 14:22:15 -0700 Subject: [PATCH 08/10] a couple manual style tweaks --- lib/tracecontext/tracestate.js | 5 +---- test/metrics/index.test.js | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/tracecontext/tracestate.js b/lib/tracecontext/tracestate.js index 1b1886808b..00314e894a 100644 --- a/lib/tracecontext/tracestate.js +++ b/lib/tracecontext/tracestate.js @@ -247,10 +247,7 @@ class TraceState { if (key.length > 256 || key.length < 1) { return false } - // eslint-disable-next-line prefer-regex-literals - const re = new RegExp( - '^[abcdefghijklmnopqrstuvwxyz0123456789_\\-\\*/]*$' - ) + const re = /^[abcdefghijklmnopqrstuvwxyz0123456789_\-*/]*$/ if (!key.match(re)) { return false } diff --git a/test/metrics/index.test.js b/test/metrics/index.test.js index 535685a553..de21d7084d 100644 --- a/test/metrics/index.test.js +++ b/test/metrics/index.test.js @@ -245,6 +245,6 @@ test('Metrics objects do not throw/crash when not started', function (t) { function spinCPUFor (durationMs) { const start = Date.now() while (Date.now() - start < durationMs) { - // spin + // spin } } From 2e6f061f5ba54064e947fbc67a7a160a2f17cc5c Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Fri, 9 Jun 2023 14:23:23 -0700 Subject: [PATCH 09/10] apply eslint 'no-var' autofixes to examples/... --- examples/trace-graphql.js | 6 +++--- examples/trace-handlebars.js | 2 +- examples/trace-pg.js | 2 +- examples/trace-pug.js | 2 +- examples/trace-tedious.js | 2 +- examples/trace-ws.js | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/trace-graphql.js b/examples/trace-graphql.js index 2dfa074455..f1dc2023a6 100644 --- a/examples/trace-graphql.js +++ b/examples/trace-graphql.js @@ -10,10 +10,10 @@ const apm = require('../').start({ // elastic-apm-node serviceName: 'example-trace-graphql' }) -var { graphql, buildSchema } = require('graphql') +const { graphql, buildSchema } = require('graphql') // Construct a schema, using GraphQL schema language -var schema = buildSchema(` +const schema = buildSchema(` type Query { hello: String bye: String @@ -21,7 +21,7 @@ var schema = buildSchema(` `) // The root provides a resolver function for each API endpoint -var root = { +const root = { hello: () => { return 'Hello world!' }, diff --git a/examples/trace-handlebars.js b/examples/trace-handlebars.js index fdd457fb14..c1e1543b5b 100755 --- a/examples/trace-handlebars.js +++ b/examples/trace-handlebars.js @@ -21,7 +21,7 @@ const handlebars = require('handlebars') // https://www.elastic.co/guide/en/apm/agent/nodejs/current/custom-transactions.html const t1 = apm.startTransaction('t1') -var template = handlebars.compile('Hello, {{name}}!') +const template = handlebars.compile('Hello, {{name}}!') console.log(template({ name: 'world' })) console.log(template({ name: 'Bob' })) diff --git a/examples/trace-pg.js b/examples/trace-pg.js index 269c57801b..af5ada1285 100755 --- a/examples/trace-pg.js +++ b/examples/trace-pg.js @@ -43,7 +43,7 @@ client.query('SELECT $1::text as message', ['bye'], (err, res) => { // 2. Using streaming style, i.e. using a `Submittable` as node-postgres calls it. const t2 = apm.startTransaction('t2') -var q = client.query(new Query('select 1 + 1 as solution')) +const q = client.query(new Query('select 1 + 1 as solution')) q.on('error', (err) => { console.log('[t2] Failure: err is', err) t2.end() diff --git a/examples/trace-pug.js b/examples/trace-pug.js index 34b7deb8d8..cd43e1d1c9 100755 --- a/examples/trace-pug.js +++ b/examples/trace-pug.js @@ -21,7 +21,7 @@ const pug = require('pug') // https://www.elastic.co/guide/en/apm/agent/nodejs/current/custom-transactions.html const t1 = apm.startTransaction('t1') -var template = pug.compile('p Hello, #{name}!') +const template = pug.compile('p Hello, #{name}!') console.log(template({ name: 'world' })) console.log(template({ name: 'Bob' })) diff --git a/examples/trace-tedious.js b/examples/trace-tedious.js index 5d31eb3344..afac19bc1f 100755 --- a/examples/trace-tedious.js +++ b/examples/trace-tedious.js @@ -65,7 +65,7 @@ const conn2 = new tedious.Connection(connOpts) conn2.on('connect', onConnect2) conn2.connect() function onConnect2 () { - var req = new tedious.Request("select @mynum=42, @mystr='qaz'", function (err, rowCount) { + const req = new tedious.Request("select @mynum=42, @mystr='qaz'", function (err, rowCount) { console.log('select @mynum ...: err=%s rowCount=%s', err && err.message, rowCount) conn2.close() }) diff --git a/examples/trace-ws.js b/examples/trace-ws.js index 440b83fd9f..027acb0109 100755 --- a/examples/trace-ws.js +++ b/examples/trace-ws.js @@ -20,8 +20,8 @@ const apm = require('../').start({ // elastic-apm-node serviceName: 'example-trace-ws' }) -var WebSocket = require('ws') -var PORT = 4567 +const WebSocket = require('ws') +const PORT = 4567 // Server const wss = new WebSocket.Server({ port: PORT }) From e9435026fa11b1a66553c644613c9b014f045b2c Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Fri, 9 Jun 2023 14:54:27 -0700 Subject: [PATCH 10/10] fix eslint 'array-callback-return' issues --- lib/instrumentation/modules/graphql.js | 5 +++-- lib/redact-secrets/index.js | 2 ++ test/_utils.js | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/instrumentation/modules/graphql.js b/lib/instrumentation/modules/graphql.js index 214cb80d11..990c74c71f 100644 --- a/lib/instrumentation/modules/graphql.js +++ b/lib/instrumentation/modules/graphql.js @@ -173,12 +173,13 @@ module.exports = function (graphql, agent, { version, enabled }) { if (document && Array.isArray(document.definitions)) { document.definitions.some(function (definition) { - if (!definition || definition.kind !== graphql.Kind.OPERATION_DEFINITION) return - if (!operationName && operation) return + if (!definition || definition.kind !== graphql.Kind.OPERATION_DEFINITION) return false + if (!operationName && operation) return false if (!operationName || (definition.name && definition.name.value === operationName)) { operation = definition return true } + return false }) var selections = operation && operation.selectionSet && operation.selectionSet.selections diff --git a/lib/redact-secrets/index.js b/lib/redact-secrets/index.js index 5dfdfbefbe..2c9da89fe4 100644 --- a/lib/redact-secrets/index.js +++ b/lib/redact-secrets/index.js @@ -38,6 +38,8 @@ module.exports = function (redacted) { } function map (obj) { + // Eslint mistakes the `.map` as being on an Array, rather than a Traverse. + // eslint-disable-next-line array-callback-return return traverse(obj).map(function (val) { if (isSecret.key(this.key) || isSecret.value(val)) this.update(redacted) }) diff --git a/test/_utils.js b/test/_utils.js index 99aaa5184b..fb89563fa4 100644 --- a/test/_utils.js +++ b/test/_utils.js @@ -48,6 +48,7 @@ function findObjInArray (arr, key, val) { return true } } + return false }) return result }