From 52c304e19a805f2ffa5a52f76b508ea32bc99453 Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Fri, 21 Dec 2018 09:52:25 +0700 Subject: [PATCH] Add configuration support to tracing instrumentation (#160) * Add support for supplying instrumentation configuration via tracing option. Option argument added to instrumentation interface. * Add ignoreIncomingPaths and ignoreOutgoingUrls support to the http and https tracing instrumentations. --- CHANGELOG.md | 2 + package-lock.json | 158 +++++++++--------- packages/opencensus-core/package-lock.json | 2 +- .../opencensus-core/src/trace/config/types.ts | 2 - .../src/trace/instrumentation/base-plugin.ts | 13 +- .../src/trace/instrumentation/types.ts | 18 +- .../opencensus-core/src/trace/model/tracer.ts | 8 +- .../package-lock.json | 2 +- .../package-lock.json | 2 +- .../package-lock.json | 20 +-- .../package-lock.json | 2 +- .../package-lock.json | 2 +- .../package-lock.json | 2 +- .../test/test-grpc.ts | 2 +- .../package-lock.json | 2 +- .../src/http.ts | 80 ++++++++- .../src/types.ts | 9 + .../test/test-http.ts | 50 +++++- .../package-lock.json | 2 +- .../test/test-http2.ts | 2 +- .../package-lock.json | 2 +- .../test/test-https.ts | 51 +++++- .../package-lock.json | 2 +- .../test/test-mongodb.ts | 2 +- packages/opencensus-nodejs/README.md | 1 - packages/opencensus-nodejs/package-lock.json | 2 +- .../trace/instrumentation/plugin-loader.ts | 25 ++- .../package-lock.json | 2 +- .../package-lock.json | 2 +- .../package-lock.json | 2 +- 30 files changed, 336 insertions(+), 135 deletions(-) create mode 100644 packages/opencensus-instrumentation-http/src/types.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 08688653f..7f5d6c756 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ All notable changes to this project will be documented in this file. - Add Metrics API. - Add Resource API. - Add Gauges (`DoubleGauge`, `LongGauge`, `DerivedDoubleGauge`, `DerivedLongGauge`) APIs. +- Add support for supplying instrumentation configuration via tracing option. Option argument added to instrumentation interface. +- Add ignoreIncomingPaths and ignoreOutgoingUrls support to the http and https tracing instrumentations. ## 0.0.8 - 2018-12-14 **Contains API breaking changes for stats/metrics implementations** diff --git a/package-lock.json b/package-lock.json index 6be65b72d..826a27cee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,7 +28,7 @@ }, "ansi-escapes": { "version": "3.1.0", - "resolved": "http://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", "integrity": "sha512-UgAb8H9D41AQnu/PbWlCofQVcnV4Gs2bBJi9eZPxfU/hgglFh3SMDMENRIqdr7H6XFnXdoknctFByVsCOotTVw==", "dev": true }, @@ -41,7 +41,7 @@ "ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha1-QfuyAkPlCxK+DwS43tvwdSDOhB0=", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { "color-convert": "^1.9.0" @@ -50,7 +50,7 @@ "aproba": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", - "integrity": "sha1-aALmJk79GMeQobDVF/DyYnvyyUo=", + "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", "dev": true }, "are-we-there-yet": { @@ -98,7 +98,7 @@ }, "async": { "version": "1.5.2", - "resolved": "http://registry.npmjs.org/async/-/async-1.5.2.tgz", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", "dev": true }, @@ -111,7 +111,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "^1.0.0", @@ -309,7 +309,7 @@ "concat-stream": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", - "integrity": "sha1-kEvfGUzTEi/Gdcd/xKw9T/D9GjQ=", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", "dev": true, "requires": { "buffer-from": "^1.0.0", @@ -345,7 +345,7 @@ }, "conventional-changelog-angular": { "version": "1.6.6", - "resolved": "http://registry.npmjs.org/conventional-changelog-angular/-/conventional-changelog-angular-1.6.6.tgz", + "resolved": "https://registry.npmjs.org/conventional-changelog-angular/-/conventional-changelog-angular-1.6.6.tgz", "integrity": "sha512-suQnFSqCxRwyBxY68pYTsFkG0taIdinHLNEAX5ivtw8bCRnIgnpvcHmlR/yjUyZIrNPYAoXlY1WiEKWgSE4BNg==", "dev": true, "requires": { @@ -355,7 +355,7 @@ }, "conventional-changelog-atom": { "version": "0.2.8", - "resolved": "http://registry.npmjs.org/conventional-changelog-atom/-/conventional-changelog-atom-0.2.8.tgz", + "resolved": "https://registry.npmjs.org/conventional-changelog-atom/-/conventional-changelog-atom-0.2.8.tgz", "integrity": "sha512-8pPZqhMbrnltNBizjoDCb/Sz85KyUXNDQxuAEYAU5V/eHn0okMBVjqc8aHWYpHrytyZWvMGbayOlDv7i8kEf6g==", "dev": true, "requires": { @@ -377,7 +377,7 @@ }, "conventional-changelog-codemirror": { "version": "0.3.8", - "resolved": "http://registry.npmjs.org/conventional-changelog-codemirror/-/conventional-changelog-codemirror-0.3.8.tgz", + "resolved": "https://registry.npmjs.org/conventional-changelog-codemirror/-/conventional-changelog-codemirror-0.3.8.tgz", "integrity": "sha512-3HFZKtBXTaUCHvz7ai6nk2+psRIkldDoNzCsom0egDtVmPsvvHZkzjynhdQyULfacRSsBTaiQ0ol6nBOL4dDiQ==", "dev": true, "requires": { @@ -407,7 +407,7 @@ "dependencies": { "load-json-file": { "version": "1.1.0", - "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", "dev": true, "requires": { @@ -440,7 +440,7 @@ }, "pify": { "version": "2.3.0", - "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true }, @@ -477,7 +477,7 @@ }, "conventional-changelog-eslint": { "version": "1.0.9", - "resolved": "http://registry.npmjs.org/conventional-changelog-eslint/-/conventional-changelog-eslint-1.0.9.tgz", + "resolved": "https://registry.npmjs.org/conventional-changelog-eslint/-/conventional-changelog-eslint-1.0.9.tgz", "integrity": "sha512-h87nfVh2fdk9fJIvz26wCBsbDC/KxqCc5wSlNMZbXcARtbgNbNDIF7Y7ctokFdnxkzVdaHsbINkh548T9eBA7Q==", "dev": true, "requires": { @@ -486,7 +486,7 @@ }, "conventional-changelog-express": { "version": "0.3.6", - "resolved": "http://registry.npmjs.org/conventional-changelog-express/-/conventional-changelog-express-0.3.6.tgz", + "resolved": "https://registry.npmjs.org/conventional-changelog-express/-/conventional-changelog-express-0.3.6.tgz", "integrity": "sha512-3iWVtBJZ9RnRnZveNDzOD8QRn6g6vUif0qVTWWyi5nUIAbuN1FfPVyKdAlJJfp5Im+dE8Kiy/d2SpaX/0X678Q==", "dev": true, "requires": { @@ -495,7 +495,7 @@ }, "conventional-changelog-jquery": { "version": "0.1.0", - "resolved": "http://registry.npmjs.org/conventional-changelog-jquery/-/conventional-changelog-jquery-0.1.0.tgz", + "resolved": "https://registry.npmjs.org/conventional-changelog-jquery/-/conventional-changelog-jquery-0.1.0.tgz", "integrity": "sha1-Agg5cWLjhGmG5xJztsecW1+A9RA=", "dev": true, "requires": { @@ -513,7 +513,7 @@ }, "conventional-changelog-jshint": { "version": "0.3.8", - "resolved": "http://registry.npmjs.org/conventional-changelog-jshint/-/conventional-changelog-jshint-0.3.8.tgz", + "resolved": "https://registry.npmjs.org/conventional-changelog-jshint/-/conventional-changelog-jshint-0.3.8.tgz", "integrity": "sha512-hn9QU4ZI/5V50wKPJNPGT4gEWgiBFpV6adieILW4MaUFynuDYOvQ71EMSj3EznJyKi/KzuXpc9dGmX8njZMjig==", "dev": true, "requires": { @@ -523,13 +523,13 @@ }, "conventional-changelog-preset-loader": { "version": "1.1.8", - "resolved": "http://registry.npmjs.org/conventional-changelog-preset-loader/-/conventional-changelog-preset-loader-1.1.8.tgz", + "resolved": "https://registry.npmjs.org/conventional-changelog-preset-loader/-/conventional-changelog-preset-loader-1.1.8.tgz", "integrity": "sha512-MkksM4G4YdrMlT2MbTsV2F6LXu/hZR0Tc/yenRrDIKRwBl/SP7ER4ZDlglqJsCzLJi4UonBc52Bkm5hzrOVCcw==", "dev": true }, "conventional-changelog-writer": { "version": "3.0.9", - "resolved": "http://registry.npmjs.org/conventional-changelog-writer/-/conventional-changelog-writer-3.0.9.tgz", + "resolved": "https://registry.npmjs.org/conventional-changelog-writer/-/conventional-changelog-writer-3.0.9.tgz", "integrity": "sha512-n9KbsxlJxRQsUnK6wIBRnARacvNnN4C/nxnxCkH+B/R1JS2Fa+DiP1dU4I59mEDEjgnFaN2+9wr1P1s7GYB5/Q==", "dev": true, "requires": { @@ -547,7 +547,7 @@ }, "conventional-commits-filter": { "version": "1.1.6", - "resolved": "http://registry.npmjs.org/conventional-commits-filter/-/conventional-commits-filter-1.1.6.tgz", + "resolved": "https://registry.npmjs.org/conventional-commits-filter/-/conventional-commits-filter-1.1.6.tgz", "integrity": "sha512-KcDgtCRKJCQhyk6VLT7zR+ZOyCnerfemE/CsR3iQpzRRFbLEs0Y6rwk3mpDvtOh04X223z+1xyJ582Stfct/0Q==", "dev": true, "requires": { @@ -557,7 +557,7 @@ }, "conventional-commits-parser": { "version": "2.1.7", - "resolved": "http://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-2.1.7.tgz", + "resolved": "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-2.1.7.tgz", "integrity": "sha512-BoMaddIEJ6B4QVMSDu9IkVImlGOSGA1I2BQyOZHeLQ6qVOJLcLKn97+fL6dGbzWEiqDzfH4OkcveULmeq2MHFQ==", "dev": true, "requires": { @@ -573,7 +573,7 @@ "conventional-recommended-bump": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/conventional-recommended-bump/-/conventional-recommended-bump-1.2.1.tgz", - "integrity": "sha1-G3E377UJH5n+AJ4v6d23zEkOk3U=", + "integrity": "sha512-oJjG6DkRgtnr/t/VrPdzmf4XZv8c4xKVJrVT4zrSHd92KEL+EYxSbYoKq8lQ7U5yLMw7130wrcQTLRjM/T+d4w==", "dev": true, "requires": { "concat-stream": "^1.4.10", @@ -593,7 +593,7 @@ }, "camelcase-keys": { "version": "2.1.0", - "resolved": "http://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", + "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", "dev": true, "requires": { @@ -618,7 +618,7 @@ }, "meow": { "version": "3.7.0", - "resolved": "http://registry.npmjs.org/meow/-/meow-3.7.0.tgz", + "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz", "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", "dev": true, "requires": { @@ -636,7 +636,7 @@ }, "minimist": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true }, @@ -714,7 +714,7 @@ "dateformat": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz", - "integrity": "sha1-puN0maTZqc+F71hyBE1ikByYia4=", + "integrity": "sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==", "dev": true }, "decamelize": { @@ -785,7 +785,7 @@ }, "duplexer": { "version": "0.1.1", - "resolved": "http://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", + "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", "dev": true }, @@ -827,7 +827,7 @@ }, "external-editor": { "version": "2.2.0", - "resolved": "http://registry.npmjs.org/external-editor/-/external-editor-2.2.0.tgz", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.2.0.tgz", "integrity": "sha512-bSn6gvGxKt+b7+6TKEv1ZycHleA7aHhRHyAqJyp5pbUFuYYNIzpZnQDk7AsYckyWdEnTeAnay0aCy2aV6iTk9A==", "dev": true, "requires": { @@ -857,7 +857,7 @@ "fs-extra": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz", - "integrity": "sha1-DYUhIuW8W+tFP7Ao6cDJvzY0DJQ=", + "integrity": "sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg==", "dev": true, "requires": { "graceful-fs": "^4.1.2", @@ -936,7 +936,7 @@ }, "camelcase-keys": { "version": "2.1.0", - "resolved": "http://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", + "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", "dev": true, "requires": { @@ -961,7 +961,7 @@ }, "meow": { "version": "3.7.0", - "resolved": "http://registry.npmjs.org/meow/-/meow-3.7.0.tgz", + "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz", "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", "dev": true, "requires": { @@ -979,7 +979,7 @@ }, "minimist": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true }, @@ -1024,13 +1024,13 @@ }, "get-stream": { "version": "3.0.0", - "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", "dev": true }, "git-raw-commits": { "version": "1.3.6", - "resolved": "http://registry.npmjs.org/git-raw-commits/-/git-raw-commits-1.3.6.tgz", + "resolved": "https://registry.npmjs.org/git-raw-commits/-/git-raw-commits-1.3.6.tgz", "integrity": "sha512-svsK26tQ8vEKnMshTDatSIQSMDdz8CxIIqKsvPqbtV23Etmw6VNaFAitu8zwZ0VrOne7FztwPyRLxK7/DIUTQg==", "dev": true, "requires": { @@ -1053,7 +1053,7 @@ "dependencies": { "pify": { "version": "2.3.0", - "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true } @@ -1061,7 +1061,7 @@ }, "git-semver-tags": { "version": "1.3.6", - "resolved": "http://registry.npmjs.org/git-semver-tags/-/git-semver-tags-1.3.6.tgz", + "resolved": "https://registry.npmjs.org/git-semver-tags/-/git-semver-tags-1.3.6.tgz", "integrity": "sha512-2jHlJnln4D/ECk9FxGEBh3k44wgYdWjWDtMmJPaecjoRmxKo3Y1Lh8GMYuOPu04CHw86NTAODchYjC5pnpMQig==", "dev": true, "requires": { @@ -1117,7 +1117,7 @@ "dependencies": { "pify": { "version": "2.3.0", - "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true } @@ -1125,7 +1125,7 @@ }, "got": { "version": "6.7.1", - "resolved": "http://registry.npmjs.org/got/-/got-6.7.1.tgz", + "resolved": "https://registry.npmjs.org/got/-/got-6.7.1.tgz", "integrity": "sha1-JAzQV4WpoY5WHcG0S0HHY+8ejbA=", "dev": true, "requires": { @@ -1229,13 +1229,13 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.3.0.tgz", - "integrity": "sha1-ndLyrXZdyrH/BEO0kUQqILoifck=", + "integrity": "sha512-h+xtnyk4EwKvFWHrUYsWErEVR+igKtLdchu+o0Z1RL7VU/jVMFbYir2bp6bAj8efFNxWqHX0dIss6fJQ+/+qeQ==", "dev": true, "requires": { "ansi-escapes": "^3.0.0", @@ -1285,7 +1285,7 @@ }, "is-builtin-module": { "version": "1.0.0", - "resolved": "http://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", "dev": true, "requires": { @@ -1333,7 +1333,7 @@ }, "is-obj": { "version": "1.0.1", - "resolved": "http://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", + "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", "dev": true }, @@ -1403,7 +1403,7 @@ "json-parse-better-errors": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", - "integrity": "sha1-u4Z8+zRQ5pEHwTHRxRS6s9yLyqk=", + "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==", "dev": true }, "json-stringify-safe": { @@ -1549,7 +1549,7 @@ "lowercase-keys": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz", - "integrity": "sha1-b54wtHCE2XGnyCD/FabFFnt0wm8=", + "integrity": "sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==", "dev": true }, "lru-cache": { @@ -1605,7 +1605,7 @@ "dependencies": { "minimist": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true }, @@ -1624,13 +1624,13 @@ "mimic-fn": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", - "integrity": "sha1-ggyGo5M0ZA6ZUWkovQP8qIBX0CI=", + "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", "dev": true }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "^1.1.7" @@ -1638,14 +1638,14 @@ }, "minimist": { "version": "0.0.8", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "dev": true }, "minimist-options": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/minimist-options/-/minimist-options-3.0.2.tgz", - "integrity": "sha1-+6TIGRM54T7PTWG+sD8HAQPz2VQ=", + "integrity": "sha512-FyBrT/d0d4+uiZRbqznPXqw3IpZZG3gl3wKWiX784FycUKVwBt0uLBFkQrtE4tZOrgo78nZp2jnKz3L65T5LdQ==", "dev": true, "requires": { "arrify": "^1.0.1", @@ -1654,7 +1654,7 @@ }, "mkdirp": { "version": "0.5.1", - "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, "requires": { @@ -1664,7 +1664,7 @@ "modify-values": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/modify-values/-/modify-values-1.0.1.tgz", - "integrity": "sha1-s5OfpgVUZHTj4+PGPWS9Q7TuYCI=", + "integrity": "sha512-xV2bxeN6F7oYjZWTe/YPAy6MN2M+sL4u/Rlm2AHCIVGfo2p1yGmBHQ6vHehl4bRTZBdHu3TSkWdYgkwpYzAGSw==", "dev": true }, "moment": { @@ -1682,7 +1682,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "^2.1.4", @@ -1703,7 +1703,7 @@ "npmlog": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", - "integrity": "sha1-CKfyqL9zRgR3mp76StXMcXq7lUs=", + "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", "dev": true, "requires": { "are-we-there-yet": "~1.1.2", @@ -1755,7 +1755,7 @@ "os-locale": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz", - "integrity": "sha1-QrwpAKa1uL0XN2yOiCtlr8zyS/I=", + "integrity": "sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==", "dev": true, "requires": { "execa": "^0.7.0", @@ -1782,7 +1782,7 @@ }, "os-tmpdir": { "version": "1.0.2", - "resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", "dev": true }, @@ -1858,7 +1858,7 @@ }, "path-is-absolute": { "version": "1.0.1", - "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, @@ -1871,7 +1871,7 @@ "path-type": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", - "integrity": "sha1-zvMdyOCho7sNEFwM2Xzzv0f0428=", + "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", "dev": true, "requires": { "pify": "^3.0.0" @@ -1907,7 +1907,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "pseudomap": { @@ -1942,7 +1942,7 @@ "dependencies": { "minimist": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true } @@ -1990,7 +1990,7 @@ }, "load-json-file": { "version": "1.1.0", - "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", "dev": true, "requires": { @@ -2032,7 +2032,7 @@ }, "pify": { "version": "2.3.0", - "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true }, @@ -2060,7 +2060,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "requires": { @@ -2086,7 +2086,7 @@ "registry-auth-token": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-3.3.2.tgz", - "integrity": "sha1-hR/UkDjuy1hpERFa+EUmDuyYPyA=", + "integrity": "sha512-JL39c60XlzCVgNrO+qq68FoNb56w/m7JYvGR2jT5iR1xBrUA3Mfx5Twk5rqTThPmQKMWydGmq8oFtDlxfrmxnQ==", "dev": true, "requires": { "rc": "^1.1.6", @@ -2136,7 +2136,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "^7.0.5" @@ -2175,7 +2175,7 @@ "safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha1-RPoWGwGHuVSd2Eu5GAL5vYOFzWo=", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true }, "semver": { @@ -2251,7 +2251,7 @@ "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "^2.1.0", @@ -2267,7 +2267,7 @@ "split": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", - "integrity": "sha1-YFvZvjA6pZ+zX5Ip++oN3snqB9k=", + "integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==", "dev": true, "requires": { "through": "2" @@ -2276,7 +2276,7 @@ "split2": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/split2/-/split2-2.2.0.tgz", - "integrity": "sha1-GGsldbz4PoW30YRldWI47k7kJJM=", + "integrity": "sha512-RAb22TG39LhI31MbreBgIuKiIKhVsawfTgEGqKHTK87aG+ul/PB8Sqoi3I7kVdRWiCfrKxK3uo4/YUkpNvhPbw==", "dev": true, "requires": { "through2": "^2.0.2" @@ -2285,7 +2285,7 @@ "string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha1-q5Pyeo3BPSjKyBXEYhQ6bZASrp4=", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", "dev": true, "requires": { "is-fullwidth-code-point": "^2.0.0", @@ -2312,7 +2312,7 @@ "string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha1-nPFhG6YmhdcDCunkujQUnDrwP8g=", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { "safe-buffer": "~5.1.0" @@ -2320,7 +2320,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { @@ -2335,7 +2335,7 @@ }, "strip-eof": { "version": "1.0.0", - "resolved": "http://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", "dev": true }, @@ -2353,7 +2353,7 @@ }, "strong-log-transformer": { "version": "1.0.6", - "resolved": "http://registry.npmjs.org/strong-log-transformer/-/strong-log-transformer-1.0.6.tgz", + "resolved": "https://registry.npmjs.org/strong-log-transformer/-/strong-log-transformer-1.0.6.tgz", "integrity": "sha1-9/uTdYpppXEUAYEnfuoMLrEwH6M=", "dev": true, "requires": { @@ -2366,7 +2366,7 @@ "dependencies": { "minimist": { "version": "0.1.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.1.0.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.1.0.tgz", "integrity": "sha1-md9lelJXTCHJBXSX33QnkLK0wN4=", "dev": true } @@ -2427,7 +2427,7 @@ }, "through": { "version": "2.3.8", - "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", "dev": true }, @@ -2450,7 +2450,7 @@ "tmp": { "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", - "integrity": "sha1-bTQzWIl2jSGyvNoKonfO07G/rfk=", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", "dev": true, "requires": { "os-tmpdir": "~1.0.2" @@ -2520,7 +2520,7 @@ }, "uuid": { "version": "2.0.3", - "resolved": "http://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz", "integrity": "sha1-Z+LoY3lyFVMN/zGOW/nc6/1Hsho=", "dev": true }, @@ -2575,7 +2575,7 @@ }, "wrap-ansi": { "version": "2.1.0", - "resolved": "http://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", "dev": true, "requires": { @@ -2614,7 +2614,7 @@ "write-file-atomic": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.3.0.tgz", - "integrity": "sha1-H/YVdcLipOjlENb6TiQ8zhg5mas=", + "integrity": "sha512-xuPeK4OdjWqtfi59ylvVL0Yn35SF3zgcAcv7rBPFHVaEapaDr4GdGgm3j7ckTwH9wHL7fGmgfAnb0+THrHb8tA==", "dev": true, "requires": { "graceful-fs": "^4.1.11", @@ -2687,7 +2687,7 @@ "dependencies": { "load-json-file": { "version": "2.0.0", - "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", "dev": true, "requires": { @@ -2717,7 +2717,7 @@ }, "pify": { "version": "2.3.0", - "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true }, diff --git a/packages/opencensus-core/package-lock.json b/packages/opencensus-core/package-lock.json index dd404c0a3..e39829c48 100644 --- a/packages/opencensus-core/package-lock.json +++ b/packages/opencensus-core/package-lock.json @@ -2937,7 +2937,7 @@ "dependencies": { "minimist": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" } } diff --git a/packages/opencensus-core/src/trace/config/types.ts b/packages/opencensus-core/src/trace/config/types.ts index 2108dfbb4..0b565f58b 100644 --- a/packages/opencensus-core/src/trace/config/types.ts +++ b/packages/opencensus-core/src/trace/config/types.ts @@ -33,8 +33,6 @@ export interface BufferConfig { export interface TracerConfig { /** Determines the sampling rate. Ranges from 0.0 to 1.0 */ samplingRate?: number; - /** Determines the ignored (or blacklisted) URLs */ - ignoreUrls?: Array; /** A logger object */ logger?: Logger; /** A propagation instance */ diff --git a/packages/opencensus-core/src/trace/instrumentation/base-plugin.ts b/packages/opencensus-core/src/trace/instrumentation/base-plugin.ts index f511081fe..53cdf8f5e 100644 --- a/packages/opencensus-core/src/trace/instrumentation/base-plugin.ts +++ b/packages/opencensus-core/src/trace/instrumentation/base-plugin.ts @@ -47,6 +47,8 @@ export abstract class BasePlugin implements types.Plugin { protected internalFilesExports: ModuleExportsMapping; /** module directory - used to load internal files */ protected basedir: string; + /** plugin options */ + protected options: types.PluginConfig; /** * Constructs a new BasePlugin instance. @@ -61,17 +63,19 @@ export abstract class BasePlugin implements types.Plugin { * @param moduleExports nodejs module exports to set as context * @param tracer tracer relating to context * @param version module version description + * @param options plugin options * @param basedir module absolute path */ private setPluginContext( // tslint:disable-next-line:no-any moduleExports: any, tracer: modelTypes.Tracer, version: string, - basedir?: string) { + options: types.PluginConfig, basedir?: string) { this.moduleExports = moduleExports; this.tracer = tracer; this.version = version; this.basedir = basedir; this.logger = tracer.logger; + this.options = options; this.internalFilesExports = this.loadInternalFiles(); } @@ -85,13 +89,14 @@ export abstract class BasePlugin implements types.Plugin { * @param moduleExports nodejs module exports from the module to patch * @param tracer a tracer instance * @param version version of the current instaled module to patch + * @param options plugin options * @param basedir module absolute path */ enable( // tslint:disable-next-line:no-any moduleExports: T, tracer: modelTypes.Tracer, version: string, - basedir: string) { - this.setPluginContext(moduleExports, tracer, version, basedir); + options: types.PluginConfig, basedir: string) { + this.setPluginContext(moduleExports, tracer, version, options, basedir); return this.applyPatch(); } @@ -146,7 +151,7 @@ export abstract class BasePlugin implements types.Plugin { * Load internal files from a module and set internalFilesExports */ private loadInternalModuleFiles( - extraModulesList: types.PluginNames, + extraModulesList: types.PluginInternalFilesVersion, basedir: string): ModuleExportsMapping { const extraModules: ModuleExportsMapping = {}; if (extraModulesList) { diff --git a/packages/opencensus-core/src/trace/instrumentation/types.ts b/packages/opencensus-core/src/trace/instrumentation/types.ts index 33c964d86..4c16c50cf 100644 --- a/packages/opencensus-core/src/trace/instrumentation/types.ts +++ b/packages/opencensus-core/src/trace/instrumentation/types.ts @@ -24,17 +24,27 @@ export interface Plugin { * @param moduleExports nodejs module exports from the module to patch * @param tracer a tracer instance * @param version version of the current instaled module to patch + * @param options plugin options * @param basedir module absolute path */ enable( // tslint:disable-next-line:no-any moduleExports: any, tracer: Tracer, version: string, + options: PluginConfig, // tslint:disable-next-line:no-any basedir?: string): any; /** Method to disable the instrumentation */ disable(): void; } +export type PluginConfig = { + // tslint:disable-next-line:no-any + [key: string]: any; +}; + +export type NamedPluginConfig = { + module: string; config: PluginConfig; +}; /** * Type PluginNames: each key should be the name of the module to trace, @@ -42,7 +52,11 @@ export interface Plugin { * plugin implementation. */ export type PluginNames = { - [pluginName: string]: string; + [pluginName: string]: string|NamedPluginConfig; +}; + +export type PluginInternalFilesVersion = { + [pluginName: string]: string }; /** @@ -50,5 +64,5 @@ export type PluginNames = { * a mapping of a property name to a internal plugin file name. */ export type PluginInternalFiles = { - [versions: string]: PluginNames; + [versions: string]: PluginInternalFilesVersion; }; diff --git a/packages/opencensus-core/src/trace/model/tracer.ts b/packages/opencensus-core/src/trace/model/tracer.ts index c4e0dce4d..3e28da131 100644 --- a/packages/opencensus-core/src/trace/model/tracer.ts +++ b/packages/opencensus-core/src/trace/model/tracer.ts @@ -123,9 +123,11 @@ export class CoreTracer implements types.Tracer { } } const aRoot = new RootSpan(this, options); - const sampleDecision: boolean = propagatedSample ? - propagatedSample : - this.sampler.shouldSample(aRoot.traceId); + + let sampleDecision: boolean = propagatedSample; + if (!sampleDecision) { + sampleDecision = this.sampler.shouldSample(aRoot.traceId); + } if (sampleDecision) { this.currentRootSpan = aRoot; diff --git a/packages/opencensus-exporter-instana/package-lock.json b/packages/opencensus-exporter-instana/package-lock.json index bbe7d3666..e58ffb994 100644 --- a/packages/opencensus-exporter-instana/package-lock.json +++ b/packages/opencensus-exporter-instana/package-lock.json @@ -2925,7 +2925,7 @@ "dependencies": { "minimist": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" } } diff --git a/packages/opencensus-exporter-prometheus/package-lock.json b/packages/opencensus-exporter-prometheus/package-lock.json index 2afeea5b7..d41653c0f 100644 --- a/packages/opencensus-exporter-prometheus/package-lock.json +++ b/packages/opencensus-exporter-prometheus/package-lock.json @@ -3395,7 +3395,7 @@ "dependencies": { "minimist": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" } } diff --git a/packages/opencensus-exporter-stackdriver/package-lock.json b/packages/opencensus-exporter-stackdriver/package-lock.json index 767750ce0..9b5c03140 100644 --- a/packages/opencensus-exporter-stackdriver/package-lock.json +++ b/packages/opencensus-exporter-stackdriver/package-lock.json @@ -153,7 +153,7 @@ "@types/nock": { "version": "9.3.0", "resolved": "https://registry.npmjs.org/@types/nock/-/nock-9.3.0.tgz", - "integrity": "sha1-nTQ1j9zAiv0HFE4HhKyelR1BLdQ=", + "integrity": "sha512-ZHf/X8rTQ5Tb1rHjxIJYqm55uO265agE3G7NoSXVa2ep+EcJXgB2fsme+zBvK7MhrxTwkC/xkB6THyv50u0MGw==", "requires": { "@types/node": "*" } @@ -195,7 +195,7 @@ "ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha1-QfuyAkPlCxK+DwS43tvwdSDOhB0=", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "requires": { "color-convert": "^1.9.0" } @@ -347,7 +347,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -356,7 +356,7 @@ "browser-stdout": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", - "integrity": "sha1-uqVZ7hTO1zRSIputcyZGfGH6vWA=" + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==" }, "buffer-equal-constant-time": { "version": "1.0.1", @@ -582,7 +582,7 @@ "debug": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha1-W7WgZyYotkFJVmuhaBnmFRjGcmE=", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", "requires": { "ms": "2.0.0" } @@ -634,7 +634,7 @@ "diff": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha1-gAwN0eCov7yVg1wgKtIg/jF+WhI=" + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==" }, "dot-prop": { "version": "4.2.0", @@ -909,7 +909,7 @@ "googleapis": { "version": "27.0.0", "resolved": "https://registry.npmjs.org/googleapis/-/googleapis-27.0.0.tgz", - "integrity": "sha1-whBjO0PnBHtl0z2kDEibbY+cArg=", + "integrity": "sha512-Cz0BRsZmewc21N50x5nAUW5cqaGhJ9ETQKZMGqGL4BxmCV7ETELazSqmNi4oCDeRwM4Iub/fIJWAWZk2i6XLCg==", "requires": { "google-auth-library": "^1.3.1", "pify": "^3.0.0", @@ -1490,7 +1490,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "requires": { "brace-expansion": "^1.1.7" } @@ -3154,7 +3154,7 @@ "dependencies": { "minimist": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" } } @@ -3219,7 +3219,7 @@ "typescript": { "version": "2.7.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.7.2.tgz", - "integrity": "sha1-LWFaHvSu5PV0Qlzf9wJu34GRmDY=" + "integrity": "sha512-p5TCYZDAO0m4G344hD+wx/LATebLWZNkkh2asWUFqSsD2OrDNhbAHuSjobrmsUmdzjJjEeZVU9g1h3O6vpstnw==" }, "unique-string": { "version": "1.0.0", diff --git a/packages/opencensus-exporter-zipkin/package-lock.json b/packages/opencensus-exporter-zipkin/package-lock.json index bad7cd1fa..801acc093 100644 --- a/packages/opencensus-exporter-zipkin/package-lock.json +++ b/packages/opencensus-exporter-zipkin/package-lock.json @@ -2937,7 +2937,7 @@ "dependencies": { "minimist": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" } } diff --git a/packages/opencensus-exporter-zpages/package-lock.json b/packages/opencensus-exporter-zpages/package-lock.json index 080a4c0f9..14f08d7ce 100644 --- a/packages/opencensus-exporter-zpages/package-lock.json +++ b/packages/opencensus-exporter-zpages/package-lock.json @@ -3317,7 +3317,7 @@ "dependencies": { "minimist": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" } } diff --git a/packages/opencensus-instrumentation-grpc/package-lock.json b/packages/opencensus-instrumentation-grpc/package-lock.json index 4728b3c36..2a76c8974 100644 --- a/packages/opencensus-instrumentation-grpc/package-lock.json +++ b/packages/opencensus-instrumentation-grpc/package-lock.json @@ -3625,7 +3625,7 @@ "dependencies": { "minimist": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" } } diff --git a/packages/opencensus-instrumentation-grpc/test/test-grpc.ts b/packages/opencensus-instrumentation-grpc/test/test-grpc.ts index 097cb97ca..1136c2b67 100644 --- a/packages/opencensus-instrumentation-grpc/test/test-grpc.ts +++ b/packages/opencensus-instrumentation-grpc/test/test-grpc.ts @@ -253,7 +253,7 @@ describe('GrpcPlugin() ', function() { before(() => { const basedir = path.dirname(require.resolve('grpc')); const version = require(path.join(basedir, 'package.json')).version; - plugin.enable(grpcModule, tracer, version, basedir); + plugin.enable(grpcModule, tracer, version, {}, basedir); tracer.registerSpanEventListener(rootSpanVerifier); const proto = grpcModule.load(PROTO_PATH).pkg_test; server = startServer(grpcModule, proto); diff --git a/packages/opencensus-instrumentation-http/package-lock.json b/packages/opencensus-instrumentation-http/package-lock.json index 4cb026878..9ac814a3d 100644 --- a/packages/opencensus-instrumentation-http/package-lock.json +++ b/packages/opencensus-instrumentation-http/package-lock.json @@ -2970,7 +2970,7 @@ "dependencies": { "minimist": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" } } diff --git a/packages/opencensus-instrumentation-http/src/http.ts b/packages/opencensus-instrumentation-http/src/http.ts index 2ad1925a8..7fa8ec1b0 100644 --- a/packages/opencensus-instrumentation-http/src/http.ts +++ b/packages/opencensus-instrumentation-http/src/http.ts @@ -21,6 +21,7 @@ import * as semver from 'semver'; import * as shimmer from 'shimmer'; import * as url from 'url'; import * as uuid from 'uuid'; +import {HttpPluginConfig, IgnoreMatcher} from './types'; @@ -43,6 +44,7 @@ export class HttpPlugin extends BasePlugin { static ATTRIBUTE_HTTP_ERROR_NAME = 'http.error_name'; static ATTRIBUTE_HTTP_ERROR_MESSAGE = 'http.error_message'; + protected options: HttpPluginConfig; /** Constructs a new HttpPlugin instance. */ constructor(moduleName: string) { @@ -93,6 +95,47 @@ export class HttpPlugin extends BasePlugin { } } + /** + * Check whether the given request is ignored by configuration + * @param url URL of request + * @param request Request to inspect + * @param list List of ignore patterns + */ + protected isIgnored( + url: string, request: T, list: Array>): boolean { + if (!list) { + // No ignored urls - trace everything + return false; + } + + for (const pattern of list) { + if (this.isSatisfyPattern(url, request, pattern)) { + return true; + } + } + + return false; + } + + /** + * Check whether the given request match pattern + * @param url URL of request + * @param request Request to inspect + * @param pattern Match pattern + */ + protected isSatisfyPattern( + url: string, request: T, pattern: IgnoreMatcher): boolean { + if (typeof pattern === 'string') { + return pattern === url; + } else if (pattern instanceof RegExp) { + return pattern.test(url); + } else if (typeof pattern === 'function') { + return pattern(url, request); + } else { + throw new TypeError('Pattern is in unsupported datatype'); + } + } + /** * Creates spans for incoming requests, restoring spans' context if applied. @@ -111,8 +154,15 @@ export class HttpPlugin extends BasePlugin { const request: httpModule.IncomingMessage = args[0]; const response: httpModule.ServerResponse = args[1]; + const path = url.parse(request.url).pathname; plugin.logger.debug('%s plugin incomingRequest', plugin.moduleName); + + if (plugin.isIgnored( + path, request, plugin.options.ignoreIncomingPaths)) { + return original.apply(this, arguments); + } + const propagation = plugin.tracer.propagation; const headers = request.headers; const getter: HeaderGetter = { @@ -122,7 +172,7 @@ export class HttpPlugin extends BasePlugin { }; const traceOptions = { - name: url.parse(request.url).pathname, + name: path, kind: 'SERVER', spanContext: propagation ? propagation.extract(getter) : null }; @@ -192,17 +242,21 @@ export class HttpPlugin extends BasePlugin { httpModule.ClientRequest> => { const plugin = this; return function outgoingRequest( - options, callback): httpModule.ClientRequest { + options: httpModule.RequestOptions|string, + callback): httpModule.ClientRequest { if (!options) { return original.apply(this, arguments); } // Makes sure the url is an url object let pathname = ''; + let method = 'GET'; + let origin = ''; if (typeof (options) === 'string') { - options = url.parse(options); - arguments[0] = options; - pathname = options.pathname; + const parsedUrl = url.parse(options); + options = parsedUrl; + pathname = parsedUrl.pathname; + origin = `${parsedUrl.protocol || 'http:'}//${parsedUrl.host}`; } else { // Do not trace ourselves if (options.headers && @@ -213,18 +267,28 @@ export class HttpPlugin extends BasePlugin { } try { - pathname = options.pathname || url.parse(options.path).pathname; + pathname = (options as url.URL).pathname || + url.parse(options.path).pathname; + method = options.method; + origin = `${options.protocol || 'http:'}//${options.host}`; } catch (e) { } } - const request = original.apply(this, arguments); + const request: httpModule.ClientRequest = + original.apply(this, arguments); + + if (plugin.isIgnored( + origin + pathname, request, + plugin.options.ignoreOutgoingUrls)) { + return request; + } plugin.tracer.wrapEmitter(request); plugin.logger.debug('%s plugin outgoingRequest', plugin.moduleName); const traceOptions = { - name: `${request.method ? request.method : 'GET'} ${pathname}`, + name: `${method || 'GET'} ${pathname}`, kind: 'CLIENT', }; diff --git a/packages/opencensus-instrumentation-http/src/types.ts b/packages/opencensus-instrumentation-http/src/types.ts new file mode 100644 index 000000000..ed9b0cb5c --- /dev/null +++ b/packages/opencensus-instrumentation-http/src/types.ts @@ -0,0 +1,9 @@ +import {ClientRequest, IncomingMessage} from 'http'; + +export type IgnoreMatcher = + string|RegExp|((url: string, request: T) => boolean); + +export type HttpPluginConfig = { + ignoreIncomingPaths?: Array>; + ignoreOutgoingUrls?: Array>; +}; diff --git a/packages/opencensus-instrumentation-http/test/test-http.ts b/packages/opencensus-instrumentation-http/test/test-http.ts index db280e1fe..178d5edf2 100644 --- a/packages/opencensus-instrumentation-http/test/test-http.ts +++ b/packages/opencensus-instrumentation-http/test/test-http.ts @@ -99,7 +99,19 @@ describe('HttpPlugin', () => { }); before(() => { - plugin.enable(http, tracer, VERSION, null); + plugin.enable( + http, tracer, VERSION, { + ignoreIncomingPaths: [ + '/ignored/string', /^\/ignored\/regexp/, + (url: string) => url === '/ignored/function' + ], + ignoreOutgoingUrls: [ + `${urlHost}/ignored/string`, + /^http:\/\/fake\.service\.io\/ignored\/regexp$/, + (url: string) => url === `${urlHost}/ignored/function` + ] + }, + null); tracer.registerSpanEventListener(rootSpanVerifier); server = http.createServer((request, response) => { response.end('Test Server Response'); @@ -245,6 +257,22 @@ describe('HttpPlugin', () => { assert.strictEqual(rootSpanVerifier.endedRootSpans.length, 0); }); }); + + for (const ignored of ['string', 'function', 'regexp']) { + it(`should not trace ignored requests with type ${ignored}`, async () => { + const testPath = `/ignored/${ignored}`; + doNock(urlHost, testPath, 200, 'Ok'); + + const options = { + host: hostName, + path: testPath, + }; + + assert.strictEqual(rootSpanVerifier.endedRootSpans.length, 0); + await httpRequest.get(options); + assert.strictEqual(rootSpanVerifier.endedRootSpans.length, 0); + }); + } }); @@ -274,6 +302,26 @@ describe('HttpPlugin', () => { span, 200, 'GET', 'localhost', testPath, 'Android'); }); }); + + for (const ignored of ['string', 'function', 'regexp']) { + it(`should not trace ignored requests with type ${ignored}`, async () => { + const testPath = `/ignored/${ignored}`; + + const options = { + host: 'localhost', + path: testPath, + port: serverPort, + headers: {'User-Agent': 'Android'} + }; + shimmer.unwrap(http, 'get'); + shimmer.unwrap(http, 'request'); + nock.enableNetConnect(); + + assert.strictEqual(rootSpanVerifier.endedRootSpans.length, 0); + await httpRequest.get(options); + assert.strictEqual(rootSpanVerifier.endedRootSpans.length, 0); + }); + } }); // TODO: This tests relies on a specific order in which tests are executed. diff --git a/packages/opencensus-instrumentation-http2/package-lock.json b/packages/opencensus-instrumentation-http2/package-lock.json index 94f8156bc..af053cfc8 100644 --- a/packages/opencensus-instrumentation-http2/package-lock.json +++ b/packages/opencensus-instrumentation-http2/package-lock.json @@ -2955,7 +2955,7 @@ "dependencies": { "minimist": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" } } diff --git a/packages/opencensus-instrumentation-http2/test/test-http2.ts b/packages/opencensus-instrumentation-http2/test/test-http2.ts index ea740f1e3..6669597f7 100644 --- a/packages/opencensus-instrumentation-http2/test/test-http2.ts +++ b/packages/opencensus-instrumentation-http2/test/test-http2.ts @@ -100,7 +100,7 @@ describe('Http2Plugin', () => { before(() => { tracer.registerSpanEventListener(rootSpanVerifier); - plugin.enable(http2, tracer, VERSION, null); + plugin.enable(http2, tracer, VERSION, {}, null); server = http2.createServer(); server.on('stream', (stream, requestHeaders) => { const statusCode = requestHeaders[':path'].length > 1 ? diff --git a/packages/opencensus-instrumentation-https/package-lock.json b/packages/opencensus-instrumentation-https/package-lock.json index 50ea9fb08..9f9f891e6 100644 --- a/packages/opencensus-instrumentation-https/package-lock.json +++ b/packages/opencensus-instrumentation-https/package-lock.json @@ -2955,7 +2955,7 @@ "dependencies": { "minimist": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" } } diff --git a/packages/opencensus-instrumentation-https/test/test-https.ts b/packages/opencensus-instrumentation-https/test/test-https.ts index e44b90723..0571ef2d0 100644 --- a/packages/opencensus-instrumentation-https/test/test-https.ts +++ b/packages/opencensus-instrumentation-https/test/test-https.ts @@ -115,7 +115,19 @@ describe('HttpsPlugin', () => { }); before(() => { - plugin.enable(https, tracer, VERSION, null); + plugin.enable( + https, tracer, VERSION, { + ignoreIncomingPaths: [ + '/ignored/string', /^\/ignored\/regexp/, + (url: string) => url === '/ignored/function' + ], + ignoreOutgoingUrls: [ + `${urlHost}/ignored/string`, + /^https:\/\/fake\.service\.io\/ignored\/regexp$/, + (url: string) => url === `${urlHost}/ignored/function` + ] + }, + null); tracer.registerSpanEventListener(rootSpanVerifier); server = https.createServer(httpsOptions, (request, response) => { response.end('Test Server Response'); @@ -268,6 +280,23 @@ describe('HttpsPlugin', () => { assert.strictEqual(rootSpanVerifier.endedRootSpans.length, 0); }); }); + + for (const ignored of ['string', 'function', 'regexp']) { + it(`should not trace ignored requests with type ${ignored}`, + async () => { + const testPath = `/ignored/${ignored}`; + doNock(urlHost, testPath, 200, 'Ok'); + + const options = { + host: hostName, + path: testPath, + }; + + assert.strictEqual(rootSpanVerifier.endedRootSpans.length, 0); + await httpRequest.get(options); + assert.strictEqual(rootSpanVerifier.endedRootSpans.length, 0); + }); + } }); }); }); @@ -297,6 +326,26 @@ describe('HttpsPlugin', () => { span, 200, 'GET', 'localhost', testPath, 'Android'); }); }); + + for (const ignored of ['string', 'function', 'regexp']) { + it(`should not trace ignored requests with type ${ignored}`, async () => { + const testPath = `/ignored/${ignored}`; + + const options = { + host: 'localhost', + path: testPath, + port: serverPort, + headers: {'User-Agent': 'Android'} + }; + shimmer.unwrap(https, 'get'); + shimmer.unwrap(https, 'request'); + nock.enableNetConnect(); + + assert.strictEqual(rootSpanVerifier.endedRootSpans.length, 0); + await httpRequest.get(options); + assert.strictEqual(rootSpanVerifier.endedRootSpans.length, 0); + }); + } }); /** Should not intercept incoming and outgoing requests */ diff --git a/packages/opencensus-instrumentation-mongodb/package-lock.json b/packages/opencensus-instrumentation-mongodb/package-lock.json index 6f0030870..5dff337b5 100644 --- a/packages/opencensus-instrumentation-mongodb/package-lock.json +++ b/packages/opencensus-instrumentation-mongodb/package-lock.json @@ -3029,7 +3029,7 @@ "dependencies": { "minimist": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" } } diff --git a/packages/opencensus-instrumentation-mongodb/test/test-mongodb.ts b/packages/opencensus-instrumentation-mongodb/test/test-mongodb.ts index 9c9f05781..5421a12ba 100644 --- a/packages/opencensus-instrumentation-mongodb/test/test-mongodb.ts +++ b/packages/opencensus-instrumentation-mongodb/test/test-mongodb.ts @@ -104,7 +104,7 @@ describe('MongoDBPlugin', () => { before((done) => { tracer.start({samplingRate: 1}); tracer.registerSpanEventListener(rootSpanVerifier); - plugin.enable(mongodb, tracer, VERSION, null); + plugin.enable(mongodb, tracer, VERSION, {}, null); accessCollection(URL, DB_NAME, COLLECTION_NAME) .then(result => { client = result.client; diff --git a/packages/opencensus-nodejs/README.md b/packages/opencensus-nodejs/README.md index de6d6b47d..d8b4619dc 100644 --- a/packages/opencensus-nodejs/README.md +++ b/packages/opencensus-nodejs/README.md @@ -63,7 +63,6 @@ Tracing has many options available to choose from. At `tracing.start()`, you can | [`logger`](https://github.com/census-instrumentation/opencensus-node/blob/master/packages/opencensus-core/src/trace/config/types.ts#L29) | `Logger` | A logger object | | [`logLevel`](https://github.com/census-instrumentation/opencensus-node/blob/master/packages/opencensus-core/src/trace/config/types.ts#L47) | `number` | Level of logger - 0: disable, 1: error, 2: warn, 3: info, 4: debug | | [`samplingRate`](https://github.com/census-instrumentation/opencensus-node/blob/master/packages/opencensus-core/src/trace/config/types.ts#L35) | `number` | Determines the span's sampling rate. Ranges from 0.0 to 1.0 | -| [`ignoreUrls`](https://github.com/census-instrumentation/opencensus-node/blob/master/packages/opencensus-core/src/trace/config/types.ts#L37) | `Array` | A list of ignored (or blacklisted) URLs to not trace | | [`propagation`](https://github.com/census-instrumentation/opencensus-node/blob/master/packages/opencensus-core/src/trace/config/types.ts#L41) | `Propagation` | A propagation instance to use | | [`maximumLabelValueSize`](https://github.com/census-instrumentation/opencensus-node/blob/master/packages/opencensus-core/src/trace/config/types.ts#L52) | `number` | The maximum number of characters reported on a label value | | [`plugin`](https://github.com/census-instrumentation/opencensus-node/blob/master/packages/opencensus-core/src/trace/config/types.ts#L68) | `PluginNames` | A list of trace instrumentations plugins to load | diff --git a/packages/opencensus-nodejs/package-lock.json b/packages/opencensus-nodejs/package-lock.json index 3192f906e..87e51c18a 100644 --- a/packages/opencensus-nodejs/package-lock.json +++ b/packages/opencensus-nodejs/package-lock.json @@ -2899,7 +2899,7 @@ "dependencies": { "minimist": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" } } diff --git a/packages/opencensus-nodejs/src/trace/instrumentation/plugin-loader.ts b/packages/opencensus-nodejs/src/trace/instrumentation/plugin-loader.ts index 0ff0bf08a..10da1d15d 100644 --- a/packages/opencensus-nodejs/src/trace/instrumentation/plugin-loader.ts +++ b/packages/opencensus-nodejs/src/trace/instrumentation/plugin-loader.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import {Logger, Plugin, PluginNames, Tracer} from '@opencensus/core'; +import {Logger, NamedPluginConfig, Plugin, PluginConfig, PluginNames, Tracer} from '@opencensus/core'; import * as fs from 'fs'; import * as path from 'path'; import * as hook from 'require-in-the-middle'; @@ -118,23 +118,34 @@ export class PluginLoader { if (this.hookState !== HookState.ENABLED) { return exports; } + const plugin = pluginList[name]; const version = this.getPackageVersion(name, basedir as string); this.logger.info('trying loading %s.%s', name, version); if (!version) { return exports; } this.logger.debug('applying patch to %s@%s module', name, version); - this.logger.debug( - 'using package %s to patch %s', pluginList[name], name); + + let moduleName; + let moduleConfig: PluginConfig = {}; + if (typeof plugin === 'string') { + moduleName = plugin; + } else { + moduleConfig = plugin.config; + moduleName = plugin.module; + } + this.logger.debug('using package %s to patch %s', moduleName, name); + // Expecting a plugin from module; try { - const plugin: Plugin = require(pluginList[name]).plugin; + const plugin: Plugin = require(moduleName as string).plugin; this.plugins.push(plugin); - return plugin.enable(exports, this.tracer, version, basedir); + return plugin.enable( + exports, this.tracer, version, moduleConfig, basedir); } catch (e) { this.logger.error( - 'could not load plugin %s of module %s. Error: %s', - pluginList[name], name, e.message); + 'could not load plugin %s of module %s. Error: %s', moduleName, + name, e.message); return exports; } }); diff --git a/packages/opencensus-propagation-b3/package-lock.json b/packages/opencensus-propagation-b3/package-lock.json index 023efe9f6..3a8fac503 100644 --- a/packages/opencensus-propagation-b3/package-lock.json +++ b/packages/opencensus-propagation-b3/package-lock.json @@ -2825,7 +2825,7 @@ "dependencies": { "minimist": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" } } diff --git a/packages/opencensus-propagation-jaeger/package-lock.json b/packages/opencensus-propagation-jaeger/package-lock.json index 023efe9f6..3a8fac503 100644 --- a/packages/opencensus-propagation-jaeger/package-lock.json +++ b/packages/opencensus-propagation-jaeger/package-lock.json @@ -2825,7 +2825,7 @@ "dependencies": { "minimist": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" } } diff --git a/packages/opencensus-propagation-tracecontext/package-lock.json b/packages/opencensus-propagation-tracecontext/package-lock.json index 023efe9f6..3a8fac503 100644 --- a/packages/opencensus-propagation-tracecontext/package-lock.json +++ b/packages/opencensus-propagation-tracecontext/package-lock.json @@ -2825,7 +2825,7 @@ "dependencies": { "minimist": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" } }