From e62499a95b729ea23a6caf02b2d2a8b8fbd1d2be Mon Sep 17 00:00:00 2001 From: Ross Hendry Date: Tue, 5 May 2020 10:01:30 +0100 Subject: [PATCH] chore(gatsby): jaeger-local to TypeScript (#23656) * chore(gatsby): jaeger-local to TypeScript * Add interface extension and reason * Remove apparently unused ts-ignore, inlined interface extension * Upgrade types package, and remove interface extension --- package.json | 1 + .../{jaeger-local.js => jaeger-local.ts} | 17 ++++----- yarn.lock | 36 +++++++++++++++++-- 3 files changed, 42 insertions(+), 12 deletions(-) rename packages/gatsby/src/utils/tracer/{jaeger-local.js => jaeger-local.ts} (69%) diff --git a/package.json b/package.json index d0e288740961f..53d6859338132 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "@types/fast-levenshtein": "^0.0.1", "@types/fs-extra": "^8.1.0", "@types/got": "^9.6.9", + "@types/jaeger-client": "^3.15.4", "@types/jest": "^24.9.1", "@types/joi": "^14.3.4", "@types/lodash": "^4.14.149", diff --git a/packages/gatsby/src/utils/tracer/jaeger-local.js b/packages/gatsby/src/utils/tracer/jaeger-local.ts similarity index 69% rename from packages/gatsby/src/utils/tracer/jaeger-local.js rename to packages/gatsby/src/utils/tracer/jaeger-local.ts index 6f9301d7174c2..56a475d34e076 100644 --- a/packages/gatsby/src/utils/tracer/jaeger-local.js +++ b/packages/gatsby/src/utils/tracer/jaeger-local.ts @@ -1,11 +1,11 @@ -const initTracer = require(`jaeger-client`).initTracer +import { initTracer, JaegerTracer, TracingConfig } from "jaeger-client" -let tracer +let tracer: JaegerTracer -function create() { +function create(): JaegerTracer { // See schema // https://github.com/jaegertracing/jaeger-client-node/blob/master/src/configuration.js#L37 - var config = { + const config: TracingConfig = { serviceName: `gatsby`, reporter: { // Provide the traces endpoint; this forces the client to @@ -17,18 +17,15 @@ function create() { param: 1, }, } - var options = {} + const options = {} tracer = initTracer(config, options) return tracer } -function stop() { +function stop(): Promise { return new Promise(resolve => { tracer.close(resolve) }) } -module.exports = { - create, - stop, -} +export { create, stop } diff --git a/yarn.lock b/yarn.lock index a8a4d96c16e67..da584628bdbb3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3609,7 +3609,7 @@ unist-builder "2.0.3" unist-util-visit "2.0.2" -"@mdx-js/react@^1.6.1": +"@mdx-js/react@^1.5.7", "@mdx-js/react@^1.6.1": version "1.6.1" resolved "https://registry.yarnpkg.com/@mdx-js/react/-/react-1.6.1.tgz#46e56602c1f513452db2f1f4185f56dc60a4fcb7" integrity sha512-jXBSWdWFPK2fs3johKb0hQFsf/x/C24XQYQwMhj8FxwlBgf7+NGATwXFs6pGkKd5/JfK9HXmbOcQ78MYoIZyxA== @@ -4055,6 +4055,14 @@ "@types/istanbul-lib-coverage" "*" "@types/istanbul-lib-report" "*" +"@types/jaeger-client@^3.15.4": + version "3.15.4" + resolved "https://registry.yarnpkg.com/@types/jaeger-client/-/jaeger-client-3.15.4.tgz#7c7548c1bbdfbdb819df63afb230998ed2e298dc" + integrity sha512-DdA3jLT6VoAnn9/AI7DBOSXSFFM839f1dXvf/wTWcofs8ajcclEexGPEbELYfC3XuoEIWLPd7OmrqF/6mp4n/A== + dependencies: + opentracing "~0.14.3" + prom-client "~11.3.0" + "@types/jest@^24.9.1": version "24.9.1" resolved "https://registry.yarnpkg.com/@types/jest/-/jest-24.9.1.tgz#02baf9573c78f1b9974a5f36778b366aa77bd534" @@ -6258,6 +6266,11 @@ binary-extensions@^2.0.0: resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.0.0.tgz#23c0df14f6a88077f5f986c0d167ec03c3d5537c" integrity sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow== +bintrees@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/bintrees/-/bintrees-1.0.1.tgz#0e655c9b9c2435eaab68bf4027226d2b55a34524" + integrity sha1-DmVcm5wkNeqraL9AJyJtK1WjRSQ= + bl@^1.0.0: version "1.2.2" resolved "https://registry.yarnpkg.com/bl/-/bl-1.2.2.tgz#a160911717103c07410cef63ef51b397c025af9c" @@ -17901,7 +17914,7 @@ opencollective-postinstall@^2.0.0, opencollective-postinstall@^2.0.2: resolved "https://registry.yarnpkg.com/opencollective-postinstall/-/opencollective-postinstall-2.0.2.tgz#5657f1bede69b6e33a45939b061eb53d3c6c3a89" integrity sha512-pVOEP16TrAO2/fjej1IdOyupJY8KDUM1CvsaScRbw6oddvpQoOfGk4ywha0HKKVAD6RkW4x6Q+tNBwhf3Bgpuw== -opentracing@^0.14.4: +opentracing@^0.14.4, opentracing@~0.14.3: version "0.14.4" resolved "https://registry.yarnpkg.com/opentracing/-/opentracing-0.14.4.tgz#a113408ea740da3a90fde5b3b0011a375c2e4268" integrity sha512-nNnZDkUNExBwEpb7LZaeMeQgvrlO8l4bgY/LvGNZCR0xG/dGWqHqjKrAmR5GUoYo0FIz38kxasvA1aevxWs2CA== @@ -19287,6 +19300,11 @@ prettier-linter-helpers@^1.0.0: dependencies: fast-diff "^1.1.2" +prettier@2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.4.tgz#2d1bae173e355996ee355ec9830a7a1ee05457ef" + integrity sha512-SVJIQ51spzFDvh4fIbCLvciiDMCrRhlN3mbZvv/+ycjvmF5E73bKdGfU8QDLNmjYJf+lsGnDBC4UUnvTe5OO0w== + prettier@2.0.5, prettier@^2.0.5: version "2.0.5" resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.5.tgz#d6d56282455243f2f92cc1716692c08aa31522d4" @@ -19419,6 +19437,13 @@ progress@^2.0.0, progress@^2.0.1, progress@^2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" +prom-client@~11.3.0: + version "11.3.0" + resolved "https://registry.yarnpkg.com/prom-client/-/prom-client-11.3.0.tgz#fe93f360182f1ec1921722efc211a6c0e68e0253" + integrity sha512-OqSf5WOvpGZXkfqPXUHNHpjrbEE/q8jxjktO0i7zg1cnULAtf0ET67/J5R4e4iA4MZx2260tzTzSFSWgMdTZmQ== + dependencies: + tdigest "^0.1.1" + promise-inflight@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/promise-inflight/-/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3" @@ -23670,6 +23695,13 @@ tar@^6.0.1: mkdirp "^1.0.3" yallist "^4.0.0" +tdigest@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/tdigest/-/tdigest-0.1.1.tgz#2e3cb2c39ea449e55d1e6cd91117accca4588021" + integrity sha1-Ljyyw56kSeVdHmzZEReszKRYgCE= + dependencies: + bintrees "1.0.1" + teepee@^2.31.1: version "2.31.2" resolved "https://registry.yarnpkg.com/teepee/-/teepee-2.31.2.tgz#2283fd176176c93977769bade1247fae7d41e58a"