@gitpod/gitpod-protocol 0.1.5-update-ovsx.0 → 0.1.5-update-yarnlock.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/gitpod-schema.json +159 -25
- package/lib/accounting-protocol.d.ts +165 -0
- package/lib/accounting-protocol.d.ts.map +1 -0
- package/lib/accounting-protocol.js +120 -0
- package/lib/accounting-protocol.js.map +1 -0
- package/lib/admin-protocol.d.ts +51 -6
- package/lib/admin-protocol.d.ts.map +1 -1
- package/lib/admin-protocol.js +17 -2
- package/lib/admin-protocol.js.map +1 -1
- package/lib/analytics.d.ts +44 -0
- package/lib/analytics.d.ts.map +1 -0
- package/lib/analytics.js +10 -0
- package/lib/analytics.js.map +1 -0
- package/lib/attribution.d.ts +25 -0
- package/lib/attribution.d.ts.map +1 -0
- package/lib/attribution.js +58 -0
- package/lib/attribution.js.map +1 -0
- package/lib/auth.d.ts +25 -0
- package/lib/auth.d.ts.map +1 -0
- package/lib/auth.js +16 -0
- package/lib/auth.js.map +1 -0
- package/lib/billing-mode.d.ts +45 -0
- package/lib/billing-mode.d.ts.map +1 -0
- package/lib/billing-mode.js +44 -0
- package/lib/billing-mode.js.map +1 -0
- package/lib/blocked-repositories-protocol.d.ts +13 -0
- package/lib/blocked-repositories-protocol.d.ts.map +1 -0
- package/lib/blocked-repositories-protocol.js +8 -0
- package/lib/blocked-repositories-protocol.js.map +1 -0
- package/lib/context-url.d.ts +30 -0
- package/lib/context-url.d.ts.map +1 -0
- package/lib/context-url.js +100 -0
- package/lib/context-url.js.map +1 -0
- package/lib/context-url.spec.d.ts +12 -0
- package/lib/context-url.spec.d.ts.map +1 -0
- package/lib/context-url.spec.js +81 -0
- package/lib/context-url.spec.js.map +1 -0
- package/lib/encryption/container-module.d.ts +2 -2
- package/lib/encryption/container-module.d.ts.map +1 -1
- package/lib/encryption/container-module.js +8 -6
- package/lib/encryption/container-module.js.map +1 -1
- package/lib/encryption/encryption-engine.d.ts +2 -2
- package/lib/encryption/encryption-engine.d.ts.map +1 -1
- package/lib/encryption/encryption-engine.js +28 -28
- package/lib/encryption/encryption-engine.js.map +1 -1
- package/lib/encryption/encryption-engine.spec.d.ts +3 -3
- package/lib/encryption/encryption-engine.spec.d.ts.map +1 -1
- package/lib/encryption/encryption-engine.spec.js +32 -39
- package/lib/encryption/encryption-engine.spec.js.map +1 -1
- package/lib/encryption/encryption-service.d.ts +2 -2
- package/lib/encryption/encryption-service.d.ts.map +1 -1
- package/lib/encryption/encryption-service.js +33 -46
- package/lib/encryption/encryption-service.js.map +1 -1
- package/lib/encryption/key-provider.d.ts +3 -3
- package/lib/encryption/key-provider.d.ts.map +1 -1
- package/lib/encryption/key-provider.js +34 -40
- package/lib/encryption/key-provider.js.map +1 -1
- package/lib/env.d.ts +2 -8
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +10 -29
- package/lib/env.js.map +1 -1
- package/lib/experiments/always-default.d.ts +8 -0
- package/lib/experiments/always-default.d.ts.map +1 -0
- package/lib/experiments/always-default.js +20 -0
- package/lib/experiments/always-default.js.map +1 -0
- package/lib/experiments/configcat-server.d.ts +10 -0
- package/lib/experiments/configcat-server.d.ts.map +1 -0
- package/lib/experiments/configcat-server.js +37 -0
- package/lib/experiments/configcat-server.js.map +1 -0
- package/lib/experiments/configcat.d.ts +21 -0
- package/lib/experiments/configcat.d.ts.map +1 -0
- package/lib/experiments/configcat.js +51 -0
- package/lib/experiments/configcat.js.map +1 -0
- package/lib/experiments/types.d.ts +22 -0
- package/lib/experiments/types.d.ts.map +1 -0
- package/lib/experiments/types.js +10 -0
- package/lib/experiments/types.js.map +1 -0
- package/lib/frontend-dashboard-service.d.ts +99 -0
- package/lib/frontend-dashboard-service.d.ts.map +1 -0
- package/lib/frontend-dashboard-service.js +55 -0
- package/lib/frontend-dashboard-service.js.map +1 -0
- package/lib/gitpod-file-parser.d.ts +2 -2
- package/lib/gitpod-file-parser.d.ts.map +1 -1
- package/lib/gitpod-file-parser.js +29 -44
- package/lib/gitpod-file-parser.js.map +1 -1
- package/lib/gitpod-file-parser.spec.d.ts +2 -2
- package/lib/gitpod-file-parser.spec.js +147 -144
- package/lib/gitpod-file-parser.spec.js.map +1 -1
- package/lib/gitpod-service.d.ts +290 -50
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +288 -123
- package/lib/gitpod-service.js.map +1 -1
- package/lib/headless-workspace-log.d.ts +11 -13
- package/lib/headless-workspace-log.d.ts.map +1 -1
- package/lib/headless-workspace-log.js +8 -9
- package/lib/headless-workspace-log.js.map +1 -1
- package/lib/ide-frontend-service.d.ts +26 -0
- package/lib/ide-frontend-service.d.ts.map +1 -0
- package/lib/ide-frontend-service.js +8 -0
- package/lib/ide-frontend-service.js.map +1 -0
- package/lib/ide-protocol.d.ts +126 -0
- package/lib/ide-protocol.d.ts.map +1 -0
- package/lib/ide-protocol.js +18 -0
- package/lib/ide-protocol.js.map +1 -0
- package/lib/index.d.ts +18 -12
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +28 -13
- package/lib/index.js.map +1 -1
- package/lib/installation-admin-protocol.d.ts +30 -0
- package/lib/installation-admin-protocol.d.ts.map +1 -0
- package/lib/installation-admin-protocol.js +31 -0
- package/lib/installation-admin-protocol.js.map +1 -0
- package/lib/license-protocol.d.ts +9 -2
- package/lib/license-protocol.d.ts.map +1 -1
- package/lib/license-protocol.js +3 -2
- package/lib/license-protocol.js.map +1 -1
- package/lib/messaging/browser/connection.d.ts +6 -4
- package/lib/messaging/browser/connection.d.ts.map +1 -1
- package/lib/messaging/browser/connection.js +188 -48
- package/lib/messaging/browser/connection.js.map +1 -1
- package/lib/messaging/browser/window-connection.d.ts +9 -4
- package/lib/messaging/browser/window-connection.d.ts.map +1 -1
- package/lib/messaging/browser/window-connection.js +48 -59
- package/lib/messaging/browser/window-connection.js.map +1 -1
- package/lib/messaging/client-call-metrics.d.ts +21 -0
- package/lib/messaging/client-call-metrics.d.ts.map +1 -0
- package/lib/messaging/client-call-metrics.js +95 -0
- package/lib/messaging/client-call-metrics.js.map +1 -0
- package/lib/messaging/error.d.ts +18 -4
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js +38 -7
- package/lib/messaging/error.js.map +1 -1
- package/lib/messaging/handler.d.ts +10 -0
- package/lib/messaging/handler.d.ts.map +1 -1
- package/lib/messaging/handler.js +2 -1
- package/lib/messaging/handler.js.map +1 -1
- package/lib/messaging/node/connection.d.ts +1 -17
- package/lib/messaging/node/connection.d.ts.map +1 -1
- package/lib/messaging/node/connection.js +24 -59
- package/lib/messaging/node/connection.js.map +1 -1
- package/lib/messaging/proxy-factory.d.ts +3 -1
- package/lib/messaging/proxy-factory.d.ts.map +1 -1
- package/lib/messaging/proxy-factory.js +76 -162
- package/lib/messaging/proxy-factory.js.map +1 -1
- package/lib/oss-allowlist.d.ts +14 -0
- package/lib/oss-allowlist.d.ts.map +1 -0
- package/lib/oss-allowlist.js +8 -0
- package/lib/oss-allowlist.js.map +1 -0
- package/lib/payment-protocol.d.ts +18 -0
- package/lib/payment-protocol.d.ts.map +1 -0
- package/lib/payment-protocol.js +13 -0
- package/lib/payment-protocol.js.map +1 -0
- package/lib/permission.d.ts +26 -15
- package/lib/permission.d.ts.map +1 -1
- package/lib/permission.js +50 -36
- package/lib/permission.js.map +1 -1
- package/lib/plans.d.ts +213 -0
- package/lib/plans.d.ts.map +1 -0
- package/lib/plans.js +625 -0
- package/lib/plans.js.map +1 -0
- package/lib/protocol.d.ts +338 -111
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +422 -201
- package/lib/protocol.js.map +1 -1
- package/lib/protocol.spec.d.ts +7 -0
- package/lib/protocol.spec.d.ts.map +1 -0
- package/lib/protocol.spec.js +127 -0
- package/lib/protocol.spec.js.map +1 -0
- package/lib/snapshot-url.d.ts +14 -0
- package/lib/snapshot-url.d.ts.map +1 -0
- package/lib/snapshot-url.js +26 -0
- package/lib/snapshot-url.js.map +1 -0
- package/lib/snapshot-url.spec.d.ts +7 -0
- package/lib/snapshot-url.spec.d.ts.map +1 -0
- package/lib/snapshot-url.spec.js +41 -0
- package/lib/snapshot-url.spec.js.map +1 -0
- package/lib/team-subscription-protocol.d.ts +93 -0
- package/lib/team-subscription-protocol.d.ts.map +1 -0
- package/lib/team-subscription-protocol.js +82 -0
- package/lib/team-subscription-protocol.js.map +1 -0
- package/lib/teams-projects-protocol.d.ts +136 -0
- package/lib/teams-projects-protocol.d.ts.map +1 -0
- package/lib/teams-projects-protocol.js +41 -0
- package/lib/teams-projects-protocol.js.map +1 -0
- package/lib/typings/globals.d.ts +8 -3
- package/lib/typings/globals.d.ts.map +1 -1
- package/lib/typings/globals.js +2 -2
- package/lib/usage.d.ts +73 -0
- package/lib/usage.d.ts.map +1 -0
- package/lib/usage.js +20 -0
- package/lib/usage.js.map +1 -0
- package/lib/util/analytics.d.ts +8 -0
- package/lib/util/analytics.d.ts.map +1 -0
- package/lib/util/analytics.js +88 -0
- package/lib/util/analytics.js.map +1 -0
- package/lib/util/async-iterator.d.ts +2 -2
- package/lib/util/async-iterator.d.ts.map +1 -1
- package/lib/util/async-iterator.js +60 -137
- package/lib/util/async-iterator.js.map +1 -1
- package/lib/util/cancelable.d.ts +2 -2
- package/lib/util/cancelable.js +20 -61
- package/lib/util/cancelable.js.map +1 -1
- package/lib/util/date-time.d.ts +2 -2
- package/lib/util/date-time.js +14 -13
- package/lib/util/date-time.js.map +1 -1
- package/lib/util/debug-app.d.ts +25 -0
- package/lib/util/debug-app.d.ts.map +1 -0
- package/lib/util/debug-app.js +100 -0
- package/lib/util/debug-app.js.map +1 -0
- package/lib/util/deep-partial.d.ts +2 -2
- package/lib/util/deep-partial.js +2 -2
- package/lib/util/deferred.d.ts +2 -2
- package/lib/util/deferred.js +13 -14
- package/lib/util/deferred.js.map +1 -1
- package/lib/util/disposable.d.ts +2 -2
- package/lib/util/disposable.d.ts.map +1 -1
- package/lib/util/disposable.js +28 -40
- package/lib/util/disposable.js.map +1 -1
- package/lib/util/event.d.ts +1 -1
- package/lib/util/event.d.ts.map +1 -1
- package/lib/util/event.js +64 -77
- package/lib/util/event.js.map +1 -1
- package/lib/util/garbage-collected-cache.d.ts +3 -2
- package/lib/util/garbage-collected-cache.d.ts.map +1 -1
- package/lib/util/garbage-collected-cache.js +35 -49
- package/lib/util/garbage-collected-cache.js.map +1 -1
- package/lib/util/generate-workspace-id.d.ts +9 -0
- package/lib/util/generate-workspace-id.d.ts.map +1 -0
- package/lib/util/generate-workspace-id.js +491 -0
- package/lib/util/generate-workspace-id.js.map +1 -0
- package/lib/util/generate-workspace-id.spec.d.ts +7 -0
- package/lib/util/generate-workspace-id.spec.d.ts.map +1 -0
- package/lib/util/generate-workspace-id.spec.js +98 -0
- package/lib/util/generate-workspace-id.spec.js.map +1 -0
- package/lib/util/gitpod-cookie.d.ts +20 -0
- package/lib/util/gitpod-cookie.d.ts.map +1 -0
- package/lib/util/gitpod-cookie.js +41 -0
- package/lib/util/gitpod-cookie.js.map +1 -0
- package/lib/util/gitpod-host-url.d.ts +20 -8
- package/lib/util/gitpod-host-url.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.js +143 -85
- package/lib/util/gitpod-host-url.js.map +1 -1
- package/lib/util/gitpod-host-url.spec.d.ts +16 -0
- package/lib/util/gitpod-host-url.spec.d.ts.map +1 -0
- package/lib/util/gitpod-host-url.spec.js +134 -0
- package/lib/util/gitpod-host-url.spec.js.map +1 -0
- package/lib/util/grpc.d.ts +35 -0
- package/lib/util/grpc.d.ts.map +1 -0
- package/lib/util/grpc.js +90 -0
- package/lib/util/grpc.js.map +1 -0
- package/lib/util/jaeger-client-types.d.ts +68 -0
- package/lib/util/jaeger-client-types.d.ts.map +1 -0
- package/lib/util/jaeger-client-types.js +8 -0
- package/lib/util/jaeger-client-types.js.map +1 -0
- package/lib/util/logging.d.ts +58 -35
- package/lib/util/logging.d.ts.map +1 -1
- package/lib/util/logging.js +144 -129
- package/lib/util/logging.js.map +1 -1
- package/lib/util/logging.spec.d.ts +7 -0
- package/lib/util/logging.spec.d.ts.map +1 -0
- package/lib/util/logging.spec.js +52 -0
- package/lib/util/logging.spec.js.map +1 -0
- package/lib/util/make-link.d.ts +2 -2
- package/lib/util/make-link.js +8 -7
- package/lib/util/make-link.js.map +1 -1
- package/lib/util/nice-grpc.d.ts +9 -0
- package/lib/util/nice-grpc.d.ts.map +1 -0
- package/lib/util/nice-grpc.js +121 -0
- package/lib/util/nice-grpc.js.map +1 -0
- package/lib/util/parse-workspace-id.d.ts +15 -5
- package/lib/util/parse-workspace-id.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.js +39 -9
- package/lib/util/parse-workspace-id.js.map +1 -1
- package/lib/util/parse-workspace-id.spec.d.ts +10 -2
- package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.spec.js +130 -49
- package/lib/util/parse-workspace-id.spec.js.map +1 -1
- package/lib/util/queue.d.ts +2 -2
- package/lib/util/queue.js +19 -57
- package/lib/util/queue.js.map +1 -1
- package/lib/util/queue.spec.d.ts +2 -2
- package/lib/util/queue.spec.js +149 -288
- package/lib/util/queue.spec.js.map +1 -1
- package/lib/util/repeat.d.ts +15 -0
- package/lib/util/repeat.d.ts.map +1 -0
- package/lib/util/repeat.js +55 -0
- package/lib/util/repeat.js.map +1 -0
- package/lib/util/semaphore.d.ts +2 -2
- package/lib/util/semaphore.d.ts.map +1 -1
- package/lib/util/semaphore.js +18 -48
- package/lib/util/semaphore.js.map +1 -1
- package/lib/util/skip-if.d.ts +2 -2
- package/lib/util/skip-if.d.ts.map +1 -1
- package/lib/util/skip-if.js +9 -8
- package/lib/util/skip-if.js.map +1 -1
- package/lib/util/timeutil.d.ts +4 -2
- package/lib/util/timeutil.d.ts.map +1 -1
- package/lib/util/timeutil.js +43 -18
- package/lib/util/timeutil.js.map +1 -1
- package/lib/util/timeutil.spec.d.ts +4 -2
- package/lib/util/timeutil.spec.d.ts.map +1 -1
- package/lib/util/timeutil.spec.js +57 -25
- package/lib/util/timeutil.spec.js.map +1 -1
- package/lib/util/tracing.d.ts +55 -8
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +210 -66
- package/lib/util/tracing.js.map +1 -1
- package/lib/util/tracing.spec.d.ts +7 -0
- package/lib/util/tracing.spec.d.ts.map +1 -0
- package/lib/util/tracing.spec.js +121 -0
- package/lib/util/tracing.spec.js.map +1 -0
- package/lib/util/workspace-port-authentication.d.ts +9 -9
- package/lib/util/workspace-port-authentication.d.ts.map +1 -1
- package/lib/util/workspace-port-authentication.js +13 -14
- package/lib/util/workspace-port-authentication.js.map +1 -1
- package/lib/webhook-event.d.ts +44 -0
- package/lib/webhook-event.d.ts.map +1 -0
- package/lib/webhook-event.js +8 -0
- package/lib/webhook-event.js.map +1 -0
- package/lib/workspace-class.d.ts +14 -0
- package/lib/workspace-class.d.ts.map +1 -0
- package/lib/workspace-class.js +8 -0
- package/lib/workspace-class.js.map +1 -0
- package/lib/workspace-cluster.d.ts +80 -0
- package/lib/workspace-cluster.d.ts.map +1 -0
- package/lib/workspace-cluster.js +36 -0
- package/lib/workspace-cluster.js.map +1 -0
- package/lib/workspace-instance.d.ts +51 -8
- package/lib/workspace-instance.d.ts.map +1 -1
- package/lib/workspace-instance.js +2 -2
- package/lib/wsready.d.ts +8 -2
- package/lib/wsready.d.ts.map +1 -1
- package/lib/wsready.js +4 -3
- package/lib/wsready.js.map +1 -1
- package/package.json +42 -18
- package/pkg-yarn.lock +24 -10
- package/provenance-bundle.jsonl +2 -0
- package/src/accounting-protocol.ts +253 -0
- package/src/admin-protocol.ts +96 -21
- package/src/analytics.ts +52 -0
- package/src/attribution.ts +67 -0
- package/src/auth.ts +27 -0
- package/src/billing-mode.ts +84 -0
- package/src/blocked-repositories-protocol.ts +13 -0
- package/src/context-url.spec.ts +49 -0
- package/src/context-url.ts +107 -0
- package/src/encryption/container-module.ts +4 -5
- package/src/encryption/encryption-engine.spec.ts +11 -10
- package/src/encryption/encryption-engine.ts +22 -18
- package/src/encryption/encryption-service.ts +6 -7
- package/src/encryption/key-provider.ts +18 -21
- package/src/env.ts +3 -26
- package/src/experiments/always-default.ts +24 -0
- package/src/experiments/configcat-server.ts +42 -0
- package/src/experiments/configcat.ts +56 -0
- package/src/experiments/types.ts +34 -0
- package/src/frontend-dashboard-service.ts +148 -0
- package/src/gitpod-file-parser.spec.ts +57 -63
- package/src/gitpod-file-parser.ts +18 -19
- package/src/gitpod-service.ts +602 -99
- package/src/headless-workspace-log.ts +14 -16
- package/src/ide-frontend-service.ts +28 -0
- package/src/ide-protocol.ts +147 -0
- package/src/index.ts +18 -12
- package/src/installation-admin-protocol.ts +45 -0
- package/src/license-protocol.ts +14 -8
- package/src/messaging/browser/connection.ts +202 -26
- package/src/messaging/browser/window-connection.ts +45 -29
- package/src/messaging/client-call-metrics.ts +94 -0
- package/src/messaging/error.ts +51 -10
- package/src/messaging/handler.ts +13 -1
- package/src/messaging/node/connection.ts +23 -70
- package/src/messaging/proxy-factory.ts +35 -34
- package/src/oss-allowlist.ts +15 -0
- package/src/payment-protocol.ts +20 -0
- package/src/permission.ts +53 -40
- package/src/plans.ts +699 -0
- package/src/protocol.spec.ts +97 -0
- package/src/protocol.ts +790 -302
- package/src/snapshot-url.spec.ts +27 -0
- package/src/snapshot-url.ts +27 -0
- package/src/team-subscription-protocol.ts +153 -0
- package/src/teams-projects-protocol.ts +180 -0
- package/src/typings/globals.ts +13 -5
- package/src/usage.ts +85 -0
- package/src/util/analytics.ts +109 -0
- package/src/util/async-iterator.ts +6 -7
- package/src/util/cancelable.ts +5 -5
- package/src/util/date-time.ts +10 -10
- package/src/util/debug-app.ts +81 -0
- package/src/util/deep-partial.ts +2 -2
- package/src/util/deferred.ts +8 -8
- package/src/util/disposable.ts +3 -6
- package/src/util/event.ts +9 -11
- package/src/util/garbage-collected-cache.ts +18 -10
- package/src/util/generate-workspace-id.spec.ts +58 -0
- package/src/util/generate-workspace-id.ts +481 -0
- package/src/util/gitpod-cookie.ts +38 -0
- package/src/util/gitpod-host-url.spec.ts +76 -0
- package/src/util/gitpod-host-url.ts +119 -40
- package/src/util/grpc.ts +107 -0
- package/src/util/jaeger-client-types.ts +102 -0
- package/src/util/logging.spec.ts +23 -0
- package/src/util/logging.ts +163 -73
- package/src/util/make-link.ts +8 -9
- package/src/util/nice-grpc.ts +96 -0
- package/src/util/parse-workspace-id.spec.ts +62 -12
- package/src/util/parse-workspace-id.ts +40 -10
- package/src/util/queue.spec.ts +30 -28
- package/src/util/queue.ts +2 -2
- package/src/util/repeat.ts +45 -0
- package/src/util/semaphore.ts +8 -10
- package/src/util/skip-if.ts +12 -9
- package/src/util/timeutil.spec.ts +42 -16
- package/src/util/timeutil.ts +33 -17
- package/src/util/tracing.spec.ts +88 -0
- package/src/util/tracing.ts +211 -33
- package/src/util/workspace-port-authentication.ts +12 -15
- package/src/webhook-event.ts +55 -0
- package/src/workspace-class.ts +14 -0
- package/src/workspace-cluster.ts +121 -0
- package/src/workspace-instance.ts +120 -36
- package/src/wsready.ts +11 -4
- package/data/builtin-theia-plugins.json +0 -362
- package/lib/email-protocol.d.ts +0 -49
- package/lib/email-protocol.d.ts.map +0 -1
- package/lib/email-protocol.js +0 -27
- package/lib/email-protocol.js.map +0 -1
- package/lib/messaging/connection-error-handler.d.ts +0 -27
- package/lib/messaging/connection-error-handler.d.ts.map +0 -1
- package/lib/messaging/connection-error-handler.js +0 -45
- package/lib/messaging/connection-error-handler.js.map +0 -1
- package/lib/theia-plugins.d.ts +0 -11
- package/lib/theia-plugins.d.ts.map +0 -1
- package/lib/theia-plugins.js +0 -8
- package/lib/theia-plugins.js.map +0 -1
- package/lib/util/repeater.d.ts +0 -22
- package/lib/util/repeater.d.ts.map +0 -1
- package/lib/util/repeater.js +0 -117
- package/lib/util/repeater.js.map +0 -1
- package/lib/util/safe-promise.d.ts +0 -11
- package/lib/util/safe-promise.d.ts.map +0 -1
- package/lib/util/safe-promise.js +0 -33
- package/lib/util/safe-promise.js.map +0 -1
- package/lib/util/without.d.ts +0 -7
- package/lib/util/without.d.ts.map +0 -1
- package/lib/util/without.js +0 -8
- package/lib/util/without.js.map +0 -1
- package/src/email-protocol.ts +0 -67
- package/src/messaging/connection-error-handler.ts +0 -62
- package/src/theia-plugins.ts +0 -11
- package/src/util/jaeger-client.d.ts +0 -105
- package/src/util/repeater.ts +0 -49
- package/src/util/safe-promise.ts +0 -26
- package/src/util/without.ts +0 -8
package/src/util/logging.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c) 2020
|
|
2
|
+
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
|
|
3
3
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
-
* See License
|
|
4
|
+
* See License.AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
const inspect: (object: any) => string = require(
|
|
7
|
+
const inspect: (object: any) => string = require("util").inspect; // undefined in frontend
|
|
8
8
|
|
|
9
|
+
let plainLogging: boolean = false; // set to true during development to get non JSON output
|
|
9
10
|
let jsonLogging: boolean = false;
|
|
10
11
|
let component: string | undefined;
|
|
11
12
|
let version: string | undefined;
|
|
@@ -15,73 +16,81 @@ export interface LogContext {
|
|
|
15
16
|
sessionId?: string;
|
|
16
17
|
userId?: string;
|
|
17
18
|
workspaceId?: string;
|
|
18
|
-
}
|
|
19
|
+
}
|
|
20
|
+
export namespace LogContext {
|
|
21
|
+
export function from(params: { userId?: string; user?: any; request?: any }) {
|
|
22
|
+
return <LogContext>{
|
|
23
|
+
sessionId: params.request?.requestID,
|
|
24
|
+
userId: params.userId || params.user?.id,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
19
28
|
|
|
20
29
|
export interface LogPayload {
|
|
21
30
|
// placeholder to indicate that only dictionary-style objects should be passed as payload
|
|
22
|
-
}
|
|
31
|
+
}
|
|
23
32
|
|
|
24
33
|
export namespace log {
|
|
25
|
-
export function error(context: LogContext, message: string, error:
|
|
26
|
-
export function error(context: LogContext, message: string, error:
|
|
34
|
+
export function error(context: LogContext, message: string, error: any, payload: LogPayload): void;
|
|
35
|
+
export function error(context: LogContext, message: string, error: any): void;
|
|
27
36
|
export function error(context: LogContext, message: string, payload: LogPayload): void;
|
|
28
37
|
export function error(context: LogContext, message: string): void;
|
|
29
|
-
export function error(context: LogContext, error:
|
|
30
|
-
export function error(context: LogContext, error:
|
|
31
|
-
export function error(message: string, error:
|
|
32
|
-
export function error(message: string, error:
|
|
38
|
+
export function error(context: LogContext, error: any, payload: LogPayload): void;
|
|
39
|
+
export function error(context: LogContext, error: any): void;
|
|
40
|
+
export function error(message: string, error: any, payload: LogPayload): void;
|
|
41
|
+
export function error(message: string, error: any): void;
|
|
33
42
|
export function error(message: string, payload: LogPayload): void;
|
|
34
43
|
export function error(message: string): void;
|
|
35
|
-
export function error(error:
|
|
36
|
-
export function error(error:
|
|
44
|
+
export function error(error: any, payload: LogPayload): void;
|
|
45
|
+
export function error(error: any): void;
|
|
37
46
|
export function error(...args: any[]): void {
|
|
38
47
|
errorLog(false, args);
|
|
39
48
|
}
|
|
40
49
|
|
|
41
|
-
export function warn(context: LogContext, message: string, error:
|
|
42
|
-
export function warn(context: LogContext, message: string, error:
|
|
50
|
+
export function warn(context: LogContext, message: string, error: any, payload: LogPayload): void;
|
|
51
|
+
export function warn(context: LogContext, message: string, error: any): void;
|
|
43
52
|
export function warn(context: LogContext, message: string, payload: LogPayload): void;
|
|
44
53
|
export function warn(context: LogContext, message: string): void;
|
|
45
|
-
export function warn(context: LogContext, error:
|
|
46
|
-
export function warn(context: LogContext, error:
|
|
47
|
-
export function warn(message: string, error:
|
|
48
|
-
export function warn(message: string, error:
|
|
54
|
+
export function warn(context: LogContext, error: any, payload: LogPayload): void;
|
|
55
|
+
export function warn(context: LogContext, error: any): void;
|
|
56
|
+
export function warn(message: string, error: any, payload: LogPayload): void;
|
|
57
|
+
export function warn(message: string, error: any): void;
|
|
49
58
|
export function warn(message: string, payload: LogPayload): void;
|
|
50
59
|
export function warn(message: string): void;
|
|
51
|
-
export function warn(error:
|
|
52
|
-
export function warn(error:
|
|
60
|
+
export function warn(error: any, payload: LogPayload): void;
|
|
61
|
+
export function warn(error: any): void;
|
|
53
62
|
export function warn(...args: any[]): void {
|
|
54
63
|
warnLog(false, args);
|
|
55
64
|
}
|
|
56
65
|
|
|
57
|
-
export function info(context: LogContext, message: string, error:
|
|
58
|
-
export function info(context: LogContext, message: string, error:
|
|
66
|
+
export function info(context: LogContext, message: string, error: any, payload: LogPayload): void;
|
|
67
|
+
export function info(context: LogContext, message: string, error: any): void;
|
|
59
68
|
export function info(context: LogContext, message: string, payload: LogPayload): void;
|
|
60
69
|
export function info(context: LogContext, message: string): void;
|
|
61
|
-
export function info(context: LogContext, error:
|
|
62
|
-
export function info(context: LogContext, error:
|
|
63
|
-
export function info(message: string, error:
|
|
64
|
-
export function info(message: string, error:
|
|
70
|
+
export function info(context: LogContext, error: any, payload: LogPayload): void;
|
|
71
|
+
export function info(context: LogContext, error: any): void;
|
|
72
|
+
export function info(message: string, error: any, payload: LogPayload): void;
|
|
73
|
+
export function info(message: string, error: any): void;
|
|
65
74
|
export function info(message: string, payload: LogPayload): void;
|
|
66
75
|
export function info(message: string): void;
|
|
67
|
-
export function info(error:
|
|
68
|
-
export function info(error:
|
|
76
|
+
export function info(error: any, payload: LogPayload): void;
|
|
77
|
+
export function info(error: any): void;
|
|
69
78
|
export function info(...args: any[]): void {
|
|
70
79
|
infoLog(false, args);
|
|
71
80
|
}
|
|
72
81
|
|
|
73
|
-
export function debug(context: LogContext, message: string, error:
|
|
74
|
-
export function debug(context: LogContext, message: string, error:
|
|
82
|
+
export function debug(context: LogContext, message: string, error: any, payload: LogPayload): void;
|
|
83
|
+
export function debug(context: LogContext, message: string, error: any): void;
|
|
75
84
|
export function debug(context: LogContext, message: string, payload: LogPayload): void;
|
|
76
85
|
export function debug(context: LogContext, message: string): void;
|
|
77
|
-
export function debug(context: LogContext, error:
|
|
78
|
-
export function debug(context: LogContext, error:
|
|
79
|
-
export function debug(message: string, error:
|
|
80
|
-
export function debug(message: string, error:
|
|
86
|
+
export function debug(context: LogContext, error: any, payload: LogPayload): void;
|
|
87
|
+
export function debug(context: LogContext, error: any): void;
|
|
88
|
+
export function debug(message: string, error: any, payload: LogPayload): void;
|
|
89
|
+
export function debug(message: string, error: any): void;
|
|
81
90
|
export function debug(message: string, payload: LogPayload): void;
|
|
82
91
|
export function debug(message: string): void;
|
|
83
|
-
export function debug(error:
|
|
84
|
-
export function debug(error:
|
|
92
|
+
export function debug(error: any, payload: LogPayload): void;
|
|
93
|
+
export function debug(error: any): void;
|
|
85
94
|
export function debug(...args: any[]): void {
|
|
86
95
|
debugLog(false, args);
|
|
87
96
|
}
|
|
@@ -89,26 +98,46 @@ export namespace log {
|
|
|
89
98
|
/**
|
|
90
99
|
* Do not use in frontend.
|
|
91
100
|
*/
|
|
92
|
-
export function enableJSONLogging(
|
|
101
|
+
export function enableJSONLogging(
|
|
102
|
+
componentArg: string,
|
|
103
|
+
versionArg: string | undefined,
|
|
104
|
+
logLevel?: LogrusLogLevel,
|
|
105
|
+
): void {
|
|
93
106
|
component = componentArg;
|
|
94
107
|
version = versionArg;
|
|
95
108
|
|
|
109
|
+
setLogLevel(logLevel);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function setLogLevel(logLevel: LogrusLogLevel | undefined) {
|
|
96
113
|
jsonLogging = true;
|
|
97
114
|
|
|
98
115
|
console.error = function (...args: any[]): void {
|
|
99
116
|
errorLog(true, args);
|
|
100
|
-
}
|
|
117
|
+
};
|
|
101
118
|
console.warn = function (...args: any[]): void {
|
|
102
119
|
warnLog(true, args);
|
|
103
|
-
}
|
|
120
|
+
};
|
|
104
121
|
console.info = function (...args: any[]): void {
|
|
105
122
|
infoLog(true, args);
|
|
106
|
-
}
|
|
123
|
+
};
|
|
107
124
|
console.debug = function (...args: any[]): void {
|
|
108
125
|
debugLog(true, args);
|
|
109
|
-
}
|
|
126
|
+
};
|
|
127
|
+
|
|
110
128
|
console.log = console.info;
|
|
111
129
|
// FIXME wrap also other console methods (e.g. trace())
|
|
130
|
+
|
|
131
|
+
// set/unset log functions based on loglevel so we only have to evaluate once, not every call
|
|
132
|
+
const noop = () => {};
|
|
133
|
+
const setLog = (logFunc: DoLogFunction, funcLevel: LogrusLogLevel): DoLogFunction => {
|
|
134
|
+
return LogrusLogLevel.isGreatherOrEqual(funcLevel, logLevel) ? logFunc : noop;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
errorLog = setLog(doErrorLog, "error");
|
|
138
|
+
warnLog = setLog(doWarnLog, "warning");
|
|
139
|
+
infoLog = setLog(doInfoLog, "info");
|
|
140
|
+
debugLog = setLog(doDebugLog, "debug");
|
|
112
141
|
}
|
|
113
142
|
|
|
114
143
|
export function resetToDefaultLogging(): void {
|
|
@@ -120,31 +149,79 @@ export namespace log {
|
|
|
120
149
|
console.info = infoConsoleLog;
|
|
121
150
|
console.debug = debugConsoleLog;
|
|
122
151
|
}
|
|
152
|
+
|
|
153
|
+
export function setVersion(versionArg: string) {
|
|
154
|
+
version = versionArg;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
type DoLogFunction = (calledViaConsole: boolean, args: any[]) => void;
|
|
159
|
+
|
|
160
|
+
let errorLog = doErrorLog;
|
|
161
|
+
function doErrorLog(calledViaConsole: boolean, args: any[]): void {
|
|
162
|
+
doLog(calledViaConsole, errorConsoleLog, "ERROR", args);
|
|
123
163
|
}
|
|
124
164
|
|
|
125
|
-
|
|
126
|
-
|
|
165
|
+
let warnLog = doWarnLog;
|
|
166
|
+
function doWarnLog(calledViaConsole: boolean, args: any[]): void {
|
|
167
|
+
doLog(calledViaConsole, warnConsoleLog, "WARNING", args);
|
|
127
168
|
}
|
|
128
169
|
|
|
129
|
-
|
|
130
|
-
|
|
170
|
+
let infoLog = doInfoLog;
|
|
171
|
+
function doInfoLog(calledViaConsole: boolean, args: any[]): void {
|
|
172
|
+
doLog(calledViaConsole, infoConsoleLog, "INFO", args);
|
|
131
173
|
}
|
|
132
174
|
|
|
133
|
-
|
|
134
|
-
|
|
175
|
+
let debugLog = doDebugLog;
|
|
176
|
+
function doDebugLog(calledViaConsole: boolean, args: any[]): void {
|
|
177
|
+
doLog(calledViaConsole, debugConsoleLog, "DEBUG", args);
|
|
135
178
|
}
|
|
136
179
|
|
|
137
|
-
|
|
138
|
-
|
|
180
|
+
// Ref: https://github.com/sirupsen/logrus#level-logging
|
|
181
|
+
export type LogrusLogLevel = keyof typeof LogrusLogLevels;
|
|
182
|
+
export const LogrusLogLevels = {
|
|
183
|
+
trace: true,
|
|
184
|
+
debug: true,
|
|
185
|
+
info: true,
|
|
186
|
+
warning: true,
|
|
187
|
+
error: true,
|
|
188
|
+
fatal: true,
|
|
189
|
+
panic: true,
|
|
190
|
+
};
|
|
191
|
+
export namespace LogrusLogLevel {
|
|
192
|
+
export function isGreatherOrEqual(lvl: LogrusLogLevel | undefined, ref: LogrusLogLevel | undefined): boolean {
|
|
193
|
+
if (lvl === undefined) {
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
if (ref === undefined) {
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
return getLevelArity(lvl) >= getLevelArity(ref);
|
|
200
|
+
}
|
|
201
|
+
function getLevelArity(lvl: LogrusLogLevel): number {
|
|
202
|
+
return Object.keys(LogrusLogLevels).findIndex((l) => l === lvl);
|
|
203
|
+
}
|
|
204
|
+
export function getFromEnv(): LogrusLogLevel | undefined {
|
|
205
|
+
const lvlStr = process.env.LOG_LEVEL;
|
|
206
|
+
if (!lvlStr) {
|
|
207
|
+
return undefined;
|
|
208
|
+
}
|
|
209
|
+
const lvl = lvlStr as LogrusLogLevel;
|
|
210
|
+
const exists = LogrusLogLevels[lvl];
|
|
211
|
+
if (!exists) {
|
|
212
|
+
return undefined;
|
|
213
|
+
}
|
|
214
|
+
return lvl;
|
|
215
|
+
}
|
|
139
216
|
}
|
|
140
217
|
|
|
141
218
|
// Source: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#LogSeverity
|
|
142
|
-
type GoogleLogSeverity =
|
|
219
|
+
type GoogleLogSeverity = "EMERGENCY" | "ALERT" | "CRITICAL" | "ERROR" | "WARNING" | "INFO" | "DEBUG";
|
|
143
220
|
namespace GoogleLogSeverity {
|
|
144
221
|
export const isGreaterOrEqualThanWarning = (severity: GoogleLogSeverity) => {
|
|
145
222
|
switch (severity) {
|
|
146
|
-
case
|
|
147
|
-
case
|
|
223
|
+
case "INFO":
|
|
224
|
+
case "DEBUG":
|
|
148
225
|
return false;
|
|
149
226
|
default:
|
|
150
227
|
return true;
|
|
@@ -172,7 +249,7 @@ function doLog(calledViaConsole: boolean, consoleLog: ConsoleLog, severity: Goog
|
|
|
172
249
|
// console.xyz(Error, ...any) / log.xyz(Error) / log.xyz(Error, LogPayload)
|
|
173
250
|
error = args[0];
|
|
174
251
|
payloadArgs = args.slice(1);
|
|
175
|
-
} else if (typeof args[0] ===
|
|
252
|
+
} else if (typeof args[0] === "string") {
|
|
176
253
|
message = args[0];
|
|
177
254
|
if (args.length < 2 || !(args[1] instanceof Error)) {
|
|
178
255
|
// console.xyz(string) / console.xyz(string, !Error, ...any) / log.xyz(string) / log.xyz(string, LogPayload)
|
|
@@ -192,7 +269,7 @@ function doLog(calledViaConsole: boolean, consoleLog: ConsoleLog, severity: Goog
|
|
|
192
269
|
// log.xyz(LogContext, Error) / log.xyz(LogContext, Error, LogPayload)
|
|
193
270
|
error = args[1];
|
|
194
271
|
payloadArgs = args.slice(2);
|
|
195
|
-
} else if (typeof args[1] ===
|
|
272
|
+
} else if (typeof args[1] === "string") {
|
|
196
273
|
message = args[1];
|
|
197
274
|
if (args.length < 3 || !(args[2] instanceof Error)) {
|
|
198
275
|
// log.xyz(LogContext, string) / log.xyz(LogContext, string, LogPayload)
|
|
@@ -215,9 +292,14 @@ function doLog(calledViaConsole: boolean, consoleLog: ConsoleLog, severity: Goog
|
|
|
215
292
|
}
|
|
216
293
|
}
|
|
217
294
|
|
|
218
|
-
function makeLogItem(
|
|
219
|
-
|
|
220
|
-
|
|
295
|
+
function makeLogItem(
|
|
296
|
+
severity: GoogleLogSeverity,
|
|
297
|
+
context: LogContext | undefined,
|
|
298
|
+
message: string | undefined,
|
|
299
|
+
error: Error | undefined,
|
|
300
|
+
payloadArgs: any[],
|
|
301
|
+
calledViaConsole: boolean,
|
|
302
|
+
): string | undefined {
|
|
221
303
|
if (context !== undefined && Object.keys(context).length == 0) {
|
|
222
304
|
context = undefined;
|
|
223
305
|
}
|
|
@@ -228,34 +310,40 @@ function makeLogItem(severity: GoogleLogSeverity, context: LogContext | undefine
|
|
|
228
310
|
}
|
|
229
311
|
|
|
230
312
|
const payload: any = payloadArgs.length == 0 ? undefined : payloadArgs.length == 1 ? payloadArgs[0] : payloadArgs;
|
|
231
|
-
const logItem
|
|
313
|
+
const logItem = {
|
|
232
314
|
// undefined fields get eliminated in JSON.stringify()
|
|
233
315
|
...reportedErrorEvent,
|
|
234
316
|
component,
|
|
235
317
|
severity,
|
|
236
318
|
time: new Date().toISOString(),
|
|
237
|
-
environment: process.env.KUBE_STAGE,
|
|
238
|
-
region: process.env.GITPOD_REGION,
|
|
239
319
|
context,
|
|
240
320
|
message,
|
|
241
321
|
error,
|
|
242
322
|
payload,
|
|
243
|
-
loggedViaConsole: calledViaConsole ? true : undefined
|
|
323
|
+
loggedViaConsole: calledViaConsole ? true : undefined,
|
|
244
324
|
};
|
|
325
|
+
if (plainLogging) {
|
|
326
|
+
return `[${logItem.severity}] [${logItem.component}] ${logItem.message}
|
|
327
|
+
${JSON.stringify(payload || "", undefined, " ")}
|
|
328
|
+
${error || ""}
|
|
329
|
+
`.trim();
|
|
330
|
+
}
|
|
245
331
|
let result: string = stringifyLogItem(logItem);
|
|
246
332
|
|
|
247
333
|
if (result.length > maxAllowedLogItemLength && payload !== undefined) {
|
|
248
334
|
delete logItem.payload;
|
|
249
|
-
|
|
335
|
+
(<any>(
|
|
336
|
+
logItem
|
|
337
|
+
)).payloadStub = `Payload stripped as log item was longer than ${maxAllowedLogItemLength} characters`;
|
|
250
338
|
|
|
251
339
|
result = stringifyLogItem(logItem);
|
|
252
340
|
|
|
253
341
|
if (result.length <= maxAllowedLogItemLength) {
|
|
254
|
-
log.warn(
|
|
342
|
+
log.warn("Log item too large, stripping payload", { logItemStub: makeLogItemStub(logItem) });
|
|
255
343
|
}
|
|
256
344
|
}
|
|
257
345
|
if (result.length > maxAllowedLogItemLength) {
|
|
258
|
-
log.error(
|
|
346
|
+
log.error("Log item too large w/o payload, discarding", { logItemStub: makeLogItemStub(logItem) });
|
|
259
347
|
return undefined;
|
|
260
348
|
}
|
|
261
349
|
|
|
@@ -269,10 +357,10 @@ function makeReportedErrorEvent(error: Error | undefined) {
|
|
|
269
357
|
// Serves as marker only
|
|
270
358
|
"@type": "type.googleapis.com/google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent",
|
|
271
359
|
// This is useful for filtering in the UI
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}
|
|
360
|
+
serviceContext: {
|
|
361
|
+
service: component || "<ts-not-set>",
|
|
362
|
+
version: version || "<ts-not-set>",
|
|
363
|
+
},
|
|
276
364
|
};
|
|
277
365
|
|
|
278
366
|
if (error) {
|
|
@@ -292,9 +380,9 @@ function makeLogItemStub(logItem: any): any {
|
|
|
292
380
|
severity: logItem.severity,
|
|
293
381
|
time: logItem.time,
|
|
294
382
|
environment: logItem.environment,
|
|
295
|
-
region: logItem.region
|
|
383
|
+
region: logItem.region,
|
|
296
384
|
};
|
|
297
|
-
if (typeof
|
|
385
|
+
if (typeof logItem.message === "string") {
|
|
298
386
|
if (logItem.message.length <= maxMessageStubLength) {
|
|
299
387
|
result.message = logItem.message;
|
|
300
388
|
} else {
|
|
@@ -328,10 +416,12 @@ function stringifyLogItem(logItem: any): string {
|
|
|
328
416
|
* Jsonifies Errors properly, not as {} only.
|
|
329
417
|
*/
|
|
330
418
|
function jsonStringifyWithErrors(value: any): string {
|
|
331
|
-
return JSON.stringify(value, (key: string, value: any): any => {
|
|
419
|
+
return JSON.stringify(value, (key: string, value: any): any => {
|
|
420
|
+
return value instanceof Error ? value.stack : value;
|
|
421
|
+
});
|
|
332
422
|
}
|
|
333
423
|
|
|
334
|
-
type ConsoleLog = (message?: any, ...optionalArgs: any[]) => void;
|
|
424
|
+
type ConsoleLog = (message?: any, ...optionalArgs: any[]) => void; // signature of console.xyz
|
|
335
425
|
const logConsoleLog: ConsoleLog = console.log;
|
|
336
426
|
const errorConsoleLog: ConsoleLog = console.error;
|
|
337
427
|
const warnConsoleLog: ConsoleLog = console.warn;
|
package/src/util/make-link.ts
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c) 2020
|
|
2
|
+
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
|
|
3
3
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
-
* See License
|
|
4
|
+
* See License.AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
function isOpenNewTab(event: MouseEvent): boolean {
|
|
8
|
-
return event.metaKey ||
|
|
8
|
+
return event.metaKey || event.ctrlKey;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export function makeLink(node: HTMLElement, url: string, hover: string): void {
|
|
12
|
-
node.onclick = event => {
|
|
13
|
-
let target =
|
|
12
|
+
node.onclick = (event) => {
|
|
13
|
+
let target = "_self";
|
|
14
14
|
if (isOpenNewTab(event)) {
|
|
15
|
-
target =
|
|
15
|
+
target = "_blank";
|
|
16
16
|
}
|
|
17
17
|
window.open(url, target);
|
|
18
|
-
}
|
|
19
|
-
node.style.cursor =
|
|
18
|
+
};
|
|
19
|
+
node.style.cursor = "pointer";
|
|
20
20
|
node.title = hover;
|
|
21
21
|
}
|
|
22
|
-
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
|
|
3
|
+
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
+
* See License.AGPL.txt in the project root for license information.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { isAbortError } from "abort-controller-x";
|
|
8
|
+
import {
|
|
9
|
+
CallOptions,
|
|
10
|
+
ClientError,
|
|
11
|
+
ClientMiddleware,
|
|
12
|
+
ClientMiddlewareCall,
|
|
13
|
+
Status,
|
|
14
|
+
MethodDescriptor,
|
|
15
|
+
} from "nice-grpc-common";
|
|
16
|
+
import { GrpcMethodType, IClientCallMetrics } from "./grpc";
|
|
17
|
+
|
|
18
|
+
function getLabels(method: MethodDescriptor) {
|
|
19
|
+
const callType = method.requestStream
|
|
20
|
+
? method.responseStream
|
|
21
|
+
? "bidi_stream"
|
|
22
|
+
: "client_stream"
|
|
23
|
+
: method.responseStream
|
|
24
|
+
? "server_stream"
|
|
25
|
+
: "unary";
|
|
26
|
+
const { path } = method;
|
|
27
|
+
const [serviceName, methodName] = path.split("/").slice(1);
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
type: callType as GrpcMethodType,
|
|
31
|
+
service: serviceName,
|
|
32
|
+
method: methodName,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function* incrementStreamMessagesCounter<T>(iterable: AsyncIterable<T>, callback: () => void): AsyncIterable<T> {
|
|
37
|
+
for await (const item of iterable) {
|
|
38
|
+
callback();
|
|
39
|
+
yield item;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function prometheusClientMiddleware(metrics: IClientCallMetrics): ClientMiddleware {
|
|
44
|
+
return async function* prometheusClientMiddlewareGenerator<Request, Response>(
|
|
45
|
+
call: ClientMiddlewareCall<Request, Response>,
|
|
46
|
+
options: CallOptions,
|
|
47
|
+
): AsyncGenerator<Response, Response | void, undefined> {
|
|
48
|
+
const labels = getLabels(call.method);
|
|
49
|
+
|
|
50
|
+
metrics.started(labels);
|
|
51
|
+
|
|
52
|
+
const stopTimer = metrics.startHandleTimer(labels);
|
|
53
|
+
|
|
54
|
+
let settled = false;
|
|
55
|
+
let status: Status = Status.OK;
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
let request;
|
|
59
|
+
|
|
60
|
+
if (!call.requestStream) {
|
|
61
|
+
request = call.request;
|
|
62
|
+
} else {
|
|
63
|
+
request = incrementStreamMessagesCounter(call.request, metrics.sent.bind(metrics, labels));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!call.responseStream) {
|
|
67
|
+
const response = yield* call.next(request, options);
|
|
68
|
+
settled = true;
|
|
69
|
+
return response;
|
|
70
|
+
} else {
|
|
71
|
+
yield* incrementStreamMessagesCounter(
|
|
72
|
+
call.next(request, options),
|
|
73
|
+
metrics.received.bind(metrics, labels),
|
|
74
|
+
);
|
|
75
|
+
settled = true;
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
} catch (err) {
|
|
79
|
+
settled = true;
|
|
80
|
+
if (err instanceof ClientError) {
|
|
81
|
+
status = err.code;
|
|
82
|
+
} else if (isAbortError(err)) {
|
|
83
|
+
status = Status.CANCELLED;
|
|
84
|
+
} else {
|
|
85
|
+
status = Status.UNKNOWN;
|
|
86
|
+
}
|
|
87
|
+
throw err;
|
|
88
|
+
} finally {
|
|
89
|
+
if (!settled) {
|
|
90
|
+
status = Status.CANCELLED;
|
|
91
|
+
}
|
|
92
|
+
stopTimer({ grpc_code: Status[status] });
|
|
93
|
+
metrics.handled({ ...labels, code: Status[status] });
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
@@ -1,35 +1,85 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c) 2020
|
|
2
|
+
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
|
|
3
3
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
-
* See License
|
|
4
|
+
* See License.AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import * as chai from
|
|
8
|
-
import { suite, test } from
|
|
9
|
-
import {
|
|
7
|
+
import * as chai from "chai";
|
|
8
|
+
import { suite, test } from "mocha-typescript";
|
|
9
|
+
import {
|
|
10
|
+
matchesInstanceIdOrLegacyWorkspaceIdExactly,
|
|
11
|
+
matchesNewWorkspaceIdExactly,
|
|
12
|
+
parseWorkspaceIdFromHostname,
|
|
13
|
+
} from "./parse-workspace-id";
|
|
10
14
|
const expect = chai.expect;
|
|
11
15
|
|
|
12
16
|
@suite
|
|
13
17
|
export class ParseWorkspaceIdTest {
|
|
14
|
-
|
|
15
18
|
@test public parseWorkspaceIdFromHostname_fromWorkspaceLocation() {
|
|
19
|
+
const actual = parseWorkspaceIdFromHostname("moccasin-ferret-155799b3.ws-eu01.gitpod.io");
|
|
20
|
+
expect(actual).to.equal("moccasin-ferret-155799b3");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@test public parseWorkspaceIdFromHostname_fromWorkspacePortLocation() {
|
|
24
|
+
const actual = parseWorkspaceIdFromHostname("3000-moccasin-ferret-155799b3.ws-eu01.gitpod.io");
|
|
25
|
+
expect(actual).to.equal("moccasin-ferret-155799b3");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@test public parseWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefix() {
|
|
29
|
+
const actual = parseWorkspaceIdFromHostname("webview-3000-moccasin-ferret-155799b3.ws-eu01.gitpod.io");
|
|
30
|
+
expect(actual).to.equal("moccasin-ferret-155799b3");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@test public parseWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefixCustomHost() {
|
|
34
|
+
const actual = parseWorkspaceIdFromHostname(
|
|
35
|
+
"webview-3000-moccasin-ferret-155799b3.ws-eu01.some.subdomain.somehost.com",
|
|
36
|
+
);
|
|
37
|
+
expect(actual).to.equal("moccasin-ferret-155799b3");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// legacy mode
|
|
41
|
+
@test public parseLegacyWorkspaceIdFromHostname_fromWorkspaceLocation() {
|
|
16
42
|
const actual = parseWorkspaceIdFromHostname("b7e0eaf8-ec73-44ec-81ea-04859263b656.ws-eu01.gitpod.io");
|
|
17
43
|
expect(actual).to.equal("b7e0eaf8-ec73-44ec-81ea-04859263b656");
|
|
18
44
|
}
|
|
19
45
|
|
|
20
|
-
@test public
|
|
46
|
+
@test public parseLegacyWorkspaceIdFromHostname_fromWorkspacePortLocation() {
|
|
21
47
|
const actual = parseWorkspaceIdFromHostname("3000-b7e0eaf8-ec73-44ec-81ea-04859263b656.ws-eu01.gitpod.io");
|
|
22
48
|
expect(actual).to.equal("b7e0eaf8-ec73-44ec-81ea-04859263b656");
|
|
23
49
|
}
|
|
24
50
|
|
|
25
|
-
@test public
|
|
26
|
-
const actual = parseWorkspaceIdFromHostname(
|
|
51
|
+
@test public parseLegacyWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefix() {
|
|
52
|
+
const actual = parseWorkspaceIdFromHostname(
|
|
53
|
+
"webview-3000-b7e0eaf8-ec73-44ec-81ea-04859263b656.ws-eu01.gitpod.io",
|
|
54
|
+
);
|
|
27
55
|
expect(actual).to.equal("b7e0eaf8-ec73-44ec-81ea-04859263b656");
|
|
28
56
|
}
|
|
29
57
|
|
|
30
|
-
@test public
|
|
31
|
-
const actual = parseWorkspaceIdFromHostname(
|
|
58
|
+
@test public parseLegacyWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefixCustomHost() {
|
|
59
|
+
const actual = parseWorkspaceIdFromHostname(
|
|
60
|
+
"webview-3000-ca81a50f-09d7-465c-acd9-264a747d5351.ws-eu01.some.subdomain.somehost.com",
|
|
61
|
+
);
|
|
32
62
|
expect(actual).to.equal("ca81a50f-09d7-465c-acd9-264a747d5351");
|
|
33
63
|
}
|
|
64
|
+
|
|
65
|
+
// match - instance ID
|
|
66
|
+
@test public matchesInstanceIdOrLegacyWorkspaceIdExactly_positive() {
|
|
67
|
+
const actual = matchesInstanceIdOrLegacyWorkspaceIdExactly("b7e0eaf8-ec73-44ec-81ea-04859263b656");
|
|
68
|
+
expect(actual).to.be.true;
|
|
69
|
+
}
|
|
70
|
+
@test public matchesInstanceIdOrLegacyWorkspaceIdExactly_negative() {
|
|
71
|
+
const actual = matchesInstanceIdOrLegacyWorkspaceIdExactly("b7e0eaf8-ec73-44ec-81a-04859263b656");
|
|
72
|
+
expect(actual).to.be.false;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// match - new workspace ID
|
|
76
|
+
@test public matchesWorkspaceIdExactly_new_positive() {
|
|
77
|
+
const actual = matchesNewWorkspaceIdExactly("moccasin-ferret-155799b3");
|
|
78
|
+
expect(actual).to.be.true;
|
|
79
|
+
}
|
|
80
|
+
@test public matchesWorkspaceIdExactly_new_negative() {
|
|
81
|
+
const actual = matchesNewWorkspaceIdExactly("moccasin-ferret-15599b3");
|
|
82
|
+
expect(actual).to.be.false;
|
|
83
|
+
}
|
|
34
84
|
}
|
|
35
|
-
module.exports = new ParseWorkspaceIdTest()
|
|
85
|
+
module.exports = new ParseWorkspaceIdTest();
|