@gitpod/gitpod-protocol 0.1.5-sje-cert-manager.0 → 0.1.5-sje-server-installation-admin.8

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.
Files changed (214) hide show
  1. package/data/gitpod-schema.json +21 -2
  2. package/lib/accounting-protocol.d.ts +0 -1
  3. package/lib/accounting-protocol.d.ts.map +1 -1
  4. package/lib/accounting-protocol.js +10 -11
  5. package/lib/accounting-protocol.js.map +1 -1
  6. package/lib/admin-protocol.d.ts +8 -2
  7. package/lib/admin-protocol.d.ts.map +1 -1
  8. package/lib/admin-protocol.js +2 -13
  9. package/lib/admin-protocol.js.map +1 -1
  10. package/lib/analytics.d.ts +1 -0
  11. package/lib/analytics.d.ts.map +1 -1
  12. package/lib/context-url.js +4 -4
  13. package/lib/context-url.js.map +1 -1
  14. package/lib/context-url.spec.js +45 -48
  15. package/lib/context-url.spec.js.map +1 -1
  16. package/lib/email-protocol.js +4 -4
  17. package/lib/email-protocol.js.map +1 -1
  18. package/lib/encryption/container-module.js +4 -4
  19. package/lib/encryption/container-module.js.map +1 -1
  20. package/lib/encryption/encryption-engine.js +19 -20
  21. package/lib/encryption/encryption-engine.js.map +1 -1
  22. package/lib/encryption/encryption-engine.spec.js +29 -36
  23. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  24. package/lib/encryption/encryption-service.js +29 -43
  25. package/lib/encryption/encryption-service.js.map +1 -1
  26. package/lib/encryption/key-provider.js +25 -30
  27. package/lib/encryption/key-provider.js.map +1 -1
  28. package/lib/env.js +12 -13
  29. package/lib/env.js.map +1 -1
  30. package/lib/gitpod-file-parser.js +25 -41
  31. package/lib/gitpod-file-parser.js.map +1 -1
  32. package/lib/gitpod-file-parser.spec.js +116 -116
  33. package/lib/gitpod-file-parser.spec.js.map +1 -1
  34. package/lib/gitpod-service.d.ts +24 -11
  35. package/lib/gitpod-service.d.ts.map +1 -1
  36. package/lib/gitpod-service.js +149 -295
  37. package/lib/gitpod-service.js.map +1 -1
  38. package/lib/ide-protocol.d.ts +81 -0
  39. package/lib/ide-protocol.d.ts.map +1 -0
  40. package/lib/ide-protocol.js +8 -0
  41. package/lib/ide-protocol.js.map +1 -0
  42. package/lib/index.d.ts +2 -0
  43. package/lib/index.d.ts.map +1 -1
  44. package/lib/index.js +2 -0
  45. package/lib/index.js.map +1 -1
  46. package/lib/messaging/browser/connection.js +91 -156
  47. package/lib/messaging/browser/connection.js.map +1 -1
  48. package/lib/messaging/browser/window-connection.js +35 -55
  49. package/lib/messaging/browser/window-connection.js.map +1 -1
  50. package/lib/messaging/client-call-metrics.js +17 -18
  51. package/lib/messaging/client-call-metrics.js.map +1 -1
  52. package/lib/messaging/connection-error-handler.js +11 -23
  53. package/lib/messaging/connection-error-handler.js.map +1 -1
  54. package/lib/messaging/error.d.ts +1 -1
  55. package/lib/messaging/error.d.ts.map +1 -1
  56. package/lib/messaging/error.js +2 -2
  57. package/lib/messaging/error.js.map +1 -1
  58. package/lib/messaging/node/connection.d.ts +0 -10
  59. package/lib/messaging/node/connection.d.ts.map +1 -1
  60. package/lib/messaging/node/connection.js +11 -49
  61. package/lib/messaging/node/connection.js.map +1 -1
  62. package/lib/messaging/proxy-factory.js +71 -162
  63. package/lib/messaging/proxy-factory.js.map +1 -1
  64. package/lib/oss-allowlist.d.ts +14 -0
  65. package/lib/oss-allowlist.d.ts.map +1 -0
  66. package/lib/oss-allowlist.js +8 -0
  67. package/lib/oss-allowlist.js.map +1 -0
  68. package/lib/permission.js +12 -12
  69. package/lib/permission.js.map +1 -1
  70. package/lib/plans.d.ts +1 -1
  71. package/lib/plans.d.ts.map +1 -1
  72. package/lib/plans.js +38 -57
  73. package/lib/plans.js.map +1 -1
  74. package/lib/protocol.d.ts +13 -40
  75. package/lib/protocol.d.ts.map +1 -1
  76. package/lib/protocol.js +44 -114
  77. package/lib/protocol.js.map +1 -1
  78. package/lib/snapshot-url.d.ts +14 -0
  79. package/lib/snapshot-url.d.ts.map +1 -0
  80. package/lib/snapshot-url.js +26 -0
  81. package/lib/snapshot-url.js.map +1 -0
  82. package/lib/snapshot-url.spec.d.ts +7 -0
  83. package/lib/snapshot-url.spec.d.ts.map +1 -0
  84. package/lib/snapshot-url.spec.js +41 -0
  85. package/lib/snapshot-url.spec.js.map +1 -0
  86. package/lib/team-subscription-protocol.js +13 -13
  87. package/lib/team-subscription-protocol.js.map +1 -1
  88. package/lib/teams-projects-protocol.d.ts +15 -0
  89. package/lib/teams-projects-protocol.d.ts.map +1 -1
  90. package/lib/teams-projects-protocol.js +4 -15
  91. package/lib/teams-projects-protocol.js.map +1 -1
  92. package/lib/util/analytics.js +25 -32
  93. package/lib/util/analytics.js.map +1 -1
  94. package/lib/util/async-iterator.js +55 -133
  95. package/lib/util/async-iterator.js.map +1 -1
  96. package/lib/util/cancelable.js +17 -59
  97. package/lib/util/cancelable.js.map +1 -1
  98. package/lib/util/date-time.js +8 -8
  99. package/lib/util/date-time.js.map +1 -1
  100. package/lib/util/deferred.js +10 -12
  101. package/lib/util/deferred.js.map +1 -1
  102. package/lib/util/disposable.js +26 -39
  103. package/lib/util/disposable.js.map +1 -1
  104. package/lib/util/event.js +58 -74
  105. package/lib/util/event.js.map +1 -1
  106. package/lib/util/garbage-collected-cache.d.ts +1 -0
  107. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  108. package/lib/util/garbage-collected-cache.js +26 -46
  109. package/lib/util/garbage-collected-cache.js.map +1 -1
  110. package/lib/util/generate-workspace-id.d.ts +1 -1
  111. package/lib/util/generate-workspace-id.d.ts.map +1 -1
  112. package/lib/util/generate-workspace-id.js +28 -68
  113. package/lib/util/generate-workspace-id.js.map +1 -1
  114. package/lib/util/generate-workspace-id.spec.js +56 -78
  115. package/lib/util/generate-workspace-id.spec.js.map +1 -1
  116. package/lib/util/gitpod-cookie.d.ts +20 -0
  117. package/lib/util/gitpod-cookie.d.ts.map +1 -0
  118. package/lib/util/gitpod-cookie.js +44 -0
  119. package/lib/util/gitpod-cookie.js.map +1 -0
  120. package/lib/util/gitpod-host-url.d.ts +1 -1
  121. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  122. package/lib/util/gitpod-host-url.js +93 -103
  123. package/lib/util/gitpod-host-url.js.map +1 -1
  124. package/lib/util/gitpod-host-url.spec.js +87 -135
  125. package/lib/util/gitpod-host-url.spec.js.map +1 -1
  126. package/lib/util/jaeger-client-types.d.ts +68 -0
  127. package/lib/util/jaeger-client-types.d.ts.map +1 -0
  128. package/lib/util/jaeger-client-types.js +8 -0
  129. package/lib/util/jaeger-client-types.js.map +1 -0
  130. package/lib/util/logging.d.ts +32 -32
  131. package/lib/util/logging.d.ts.map +1 -1
  132. package/lib/util/logging.js +50 -113
  133. package/lib/util/logging.js.map +1 -1
  134. package/lib/util/make-link.js +2 -2
  135. package/lib/util/make-link.js.map +1 -1
  136. package/lib/util/parse-workspace-id.d.ts +10 -0
  137. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  138. package/lib/util/parse-workspace-id.js +31 -7
  139. package/lib/util/parse-workspace-id.js.map +1 -1
  140. package/lib/util/parse-workspace-id.spec.d.ts +4 -0
  141. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  142. package/lib/util/parse-workspace-id.spec.js +123 -84
  143. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  144. package/lib/util/queue.js +16 -55
  145. package/lib/util/queue.js.map +1 -1
  146. package/lib/util/queue.spec.js +144 -288
  147. package/lib/util/queue.spec.js.map +1 -1
  148. package/lib/util/repeat.d.ts +15 -0
  149. package/lib/util/repeat.d.ts.map +1 -0
  150. package/lib/util/repeat.js +55 -0
  151. package/lib/util/repeat.js.map +1 -0
  152. package/lib/util/safe-promise.js +9 -12
  153. package/lib/util/safe-promise.js.map +1 -1
  154. package/lib/util/semaphore.js +15 -46
  155. package/lib/util/semaphore.js.map +1 -1
  156. package/lib/util/skip-if.js +6 -6
  157. package/lib/util/skip-if.js.map +1 -1
  158. package/lib/util/timeutil.js +16 -16
  159. package/lib/util/timeutil.js.map +1 -1
  160. package/lib/util/timeutil.spec.js +21 -24
  161. package/lib/util/timeutil.spec.js.map +1 -1
  162. package/lib/util/tracing.d.ts +51 -5
  163. package/lib/util/tracing.d.ts.map +1 -1
  164. package/lib/util/tracing.js +193 -62
  165. package/lib/util/tracing.js.map +1 -1
  166. package/lib/util/tracing.spec.d.ts +7 -0
  167. package/lib/util/tracing.spec.d.ts.map +1 -0
  168. package/lib/util/tracing.spec.js +121 -0
  169. package/lib/util/tracing.spec.js.map +1 -0
  170. package/lib/util/workspace-port-authentication.js +2 -2
  171. package/lib/util/workspace-port-authentication.js.map +1 -1
  172. package/lib/workspace-cluster.js +3 -3
  173. package/lib/workspace-cluster.js.map +1 -1
  174. package/lib/workspace-instance.d.ts +3 -2
  175. package/lib/workspace-instance.d.ts.map +1 -1
  176. package/lib/wsready.js +1 -1
  177. package/package.json +22 -13
  178. package/pkg-yarn.lock +12 -7
  179. package/provenance-bundle.jsonl +2 -0
  180. package/src/accounting-protocol.ts +1 -3
  181. package/src/admin-protocol.ts +9 -3
  182. package/src/analytics.ts +2 -0
  183. package/src/email-protocol.ts +1 -1
  184. package/src/gitpod-service.ts +27 -16
  185. package/src/ide-protocol.ts +92 -0
  186. package/src/index.ts +2 -0
  187. package/src/messaging/error.ts +2 -2
  188. package/src/messaging/node/connection.ts +1 -45
  189. package/src/oss-allowlist.ts +15 -0
  190. package/src/protocol.ts +17 -42
  191. package/src/snapshot-url.spec.ts +25 -0
  192. package/src/snapshot-url.ts +27 -0
  193. package/src/team-subscription-protocol.ts +1 -1
  194. package/src/teams-projects-protocol.ts +19 -1
  195. package/src/util/garbage-collected-cache.ts +7 -1
  196. package/src/util/generate-workspace-id.spec.ts +16 -0
  197. package/src/util/generate-workspace-id.ts +19 -2
  198. package/src/util/gitpod-cookie.ts +39 -0
  199. package/src/util/gitpod-host-url.ts +10 -10
  200. package/src/util/jaeger-client-types.ts +102 -0
  201. package/src/util/logging.ts +32 -32
  202. package/src/util/parse-workspace-id.spec.ts +21 -1
  203. package/src/util/parse-workspace-id.ts +32 -6
  204. package/src/util/repeat.ts +45 -0
  205. package/src/util/tracing.spec.ts +83 -0
  206. package/src/util/tracing.ts +180 -18
  207. package/src/workspace-instance.ts +9 -6
  208. package/src/wsready.ts +1 -1
  209. package/lib/util/repeater.d.ts +0 -22
  210. package/lib/util/repeater.d.ts.map +0 -1
  211. package/lib/util/repeater.js +0 -118
  212. package/lib/util/repeater.js.map +0 -1
  213. package/src/util/jaeger-client.d.ts +0 -105
  214. package/src/util/repeater.ts +0 -49
@@ -4,6 +4,14 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
+ const REGEX_WORKSPACE_ID = /[0-9a-z]{2,16}-[0-9a-z]{2,16}-[0-9a-z]{8,11}/;
8
+ const REGEX_WORKSPACE_ID_EXACT = new RegExp(`^${REGEX_WORKSPACE_ID.source}$`);
9
+ // We need to parse the workspace id precisely here to get the case '<some-str>-<port>-<wsid>.ws.' right
10
+ const REGEX_WORKSPACE_ID_FROM_HOSTNAME = new RegExp(`(${REGEX_WORKSPACE_ID.source})\.ws`);
11
+
12
+ const REGEX_WORKSPACE_ID_LEGACY = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;
13
+ const REGEX_WORKSPACE_ID_LEGACY_EXACT = new RegExp(`^${REGEX_WORKSPACE_ID_LEGACY.source}$`);
14
+ const REGEX_WORKSPACE_ID_LEGACY_FROM_HOSTNAME = new RegExp(`(${REGEX_WORKSPACE_ID_LEGACY.source})\.ws`);
7
15
 
8
16
  /**
9
17
  * Hostname may be of the form:
@@ -13,17 +21,35 @@
13
21
  * @param hostname The hostname the request is headed to
14
22
  */
15
23
  export const parseWorkspaceIdFromHostname = function(hostname: string) {
16
- // We need to parse the workspace id precisely here to get the case '<some-str>-<port>-<wsid>.ws.' right
17
- const wsIdExpression = /([0-9a-z]{2,16}-[0-9a-z]{2,16}-[0-9a-z]{8})\.ws/g;
18
- const match = wsIdExpression.exec(hostname);
24
+ const match = REGEX_WORKSPACE_ID_FROM_HOSTNAME.exec(hostname);
19
25
  if (match && match.length >= 2) {
20
26
  return match[1];
21
27
  } else {
22
- const legacyUrlFormat = /([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.ws/g;
23
- const legacyMatch = legacyUrlFormat.exec(hostname);
28
+ const legacyMatch = REGEX_WORKSPACE_ID_LEGACY_FROM_HOSTNAME.exec(hostname);
24
29
  if (legacyMatch && legacyMatch.length >= 2) {
25
30
  return legacyMatch[1];
26
31
  }
27
32
  return undefined;
28
33
  }
29
- }
34
+ };
35
+
36
+ /** Equalls UUIDv4 (and REGEX_WORKSPACE_ID_LEGACY!) */
37
+ const REGEX_INSTANCE_ID = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;
38
+ const REGEX_INSTANCE_ID_EXACT = new RegExp(`^${REGEX_INSTANCE_ID.source}$`);
39
+
40
+ /**
41
+ * @param maybeId
42
+ * @returns
43
+ */
44
+ export const matchesInstanceIdOrLegacyWorkspaceIdExactly = function(maybeId: string): boolean {
45
+ return REGEX_INSTANCE_ID_EXACT.test(maybeId)
46
+ || REGEX_WORKSPACE_ID_LEGACY_EXACT.test(maybeId);
47
+ };
48
+
49
+ /**
50
+ * @param maybeWorkspaceId
51
+ * @returns
52
+ */
53
+ export const matchesNewWorkspaceIdExactly = function(maybeWorkspaceId: string): boolean {
54
+ return REGEX_WORKSPACE_ID_EXACT.test(maybeWorkspaceId);
55
+ };
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Copyright (c) 2021 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 { Disposable } from "..";
8
+ import { log } from "./logging";
9
+
10
+ /**
11
+ * This intends to be a drop-in replacement for 'setInterval' implemented with a 'setTimeout' chain
12
+ * to ensure we're not creating more timeouts than we can process.
13
+ * @param op
14
+ * @param everyMilliseconds
15
+ * @returns
16
+ */
17
+ export function repeat(op: () => Promise<void> | void, everyMilliseconds: number): Disposable {
18
+ let timer: NodeJS.Timeout | undefined = undefined;
19
+ let stopped = false;
20
+ const repeated = () => {
21
+ if (stopped) {
22
+ // in case we missed the clearTimeout i 'await'
23
+ return;
24
+ }
25
+
26
+ timer = setTimeout(async () => {
27
+ try {
28
+ await op();
29
+ } catch (err) {
30
+ // catch error here to
31
+ log.error(err);
32
+ }
33
+
34
+ repeated(); // chain ourselves - after the 'await'
35
+ }, everyMilliseconds);
36
+ };
37
+ repeated();
38
+
39
+ return Disposable.create(() => {
40
+ stopped = true;
41
+ if (timer) {
42
+ clearTimeout(timer);
43
+ }
44
+ });
45
+ }
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Copyright (c) 2021 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 { suite, test } from "mocha-typescript"
8
+ import * as chai from "chai"
9
+ import { TraceContext } from "./tracing";
10
+ import { MockTracer } from "opentracing";
11
+
12
+ const expect = chai.expect
13
+
14
+ @suite class TestTracing {
15
+
16
+ @test public async testTracingContext_addNestedTags() {
17
+ const tracer = new MockTracer();
18
+ const span = tracer.startSpan('testTracingContext_addNestedTags');
19
+ TraceContext.addNestedTags({ span }, {
20
+ rpc: {
21
+ system: "jsonrpc",
22
+ jsonrpc: {
23
+ version: "1.0",
24
+ method: "test",
25
+ parameters: ["abc", "def"],
26
+ },
27
+ },
28
+ });
29
+
30
+ const mockSpan = tracer.report().spans[0];
31
+ expect(mockSpan.tags()).to.deep.equal({
32
+ "rpc.system": "jsonrpc",
33
+ "rpc.jsonrpc.version": "1.0",
34
+ "rpc.jsonrpc.method": "test",
35
+ "rpc.jsonrpc.parameters.0": "abc",
36
+ "rpc.jsonrpc.parameters.1": "def",
37
+ });
38
+ }
39
+
40
+ @test public async testTracingContext_addNestedTags_null() {
41
+ const tracer = new MockTracer();
42
+ const span = tracer.startSpan('testTracingContext_addNestedTags_null');
43
+ TraceContext.addNestedTags({ span }, {
44
+ someShape: {
45
+ thisIsNull: null,
46
+ thisIsUndefined: undefined,
47
+ },
48
+ });
49
+
50
+ const mockSpan = tracer.report().spans[0];
51
+ expect(mockSpan.tags()).to.deep.equal({
52
+ "someShape.thisIsNull": null,
53
+ "someShape.thisIsUndefined": undefined,
54
+ });
55
+ }
56
+
57
+ @test public async testTracingContext_addJsonRPCParameters() {
58
+ const tracer = new MockTracer();
59
+ const span = tracer.startSpan('testTracingContext_addJsonRPCParameters');
60
+ const ctx = { span };
61
+ TraceContext.addJsonRPCParameters(ctx, {
62
+ one: "one",
63
+ two: {
64
+ name: "two",
65
+ some: "shape",
66
+ containing: "PII",
67
+ },
68
+ three: "three",
69
+ });
70
+
71
+ const mockSpan = tracer.report().spans[0];
72
+ expect(mockSpan.tags()).to.deep.equal({
73
+ "rpc.jsonrpc.parameters.one": "one",
74
+ "rpc.jsonrpc.parameters.two.containing": "PII",
75
+ "rpc.jsonrpc.parameters.two.name": "two",
76
+ "rpc.jsonrpc.parameters.two.some": "shape",
77
+ "rpc.jsonrpc.parameters.three": "three",
78
+ "rpc.system": "jsonrpc",
79
+ });
80
+ }
81
+
82
+ }
83
+ module.exports = new TestTracing()
@@ -6,40 +6,180 @@
6
6
 
7
7
 
8
8
  import * as opentracing from 'opentracing';
9
- import { TracingConfig, initTracerFromEnv, Sampler, SamplingDecision } from 'jaeger-client';
10
- import { initGlobalTracer } from 'opentracing';
9
+ import { TracingConfig, initTracerFromEnv } from 'jaeger-client';
10
+ import { Sampler, SamplingDecision } from './jaeger-client-types';
11
+ import { followsFrom, initGlobalTracer } from 'opentracing';
11
12
  import { injectable } from 'inversify';
13
+ import { ResponseError } from 'vscode-jsonrpc';
14
+ import { log, LogContext } from './logging';
12
15
 
13
16
  export interface TraceContext {
14
17
  span?: opentracing.Span
15
18
  }
19
+ export type TraceContextWithSpan = TraceContext & {
20
+ span: opentracing.Span
21
+ }
22
+
16
23
 
17
24
  export namespace TraceContext {
18
- export function startSpan(operation: string, ctx: TraceContext): opentracing.Span {
19
- const options: opentracing.SpanOptions = {
20
- childOf: ctx.span
25
+ export function startSpan(operation: string, parentCtx?: TraceContext, ...referencedSpans: (opentracing.Span | undefined)[]): opentracing.Span {
26
+ const options: opentracing.SpanOptions = {};
27
+ if (parentCtx) {
28
+ options.childOf = parentCtx.span;
29
+ }
30
+ if (referencedSpans) {
31
+ // note: allthough followsForm's type says it takes 'opentracing.Span | opentracing.SpanContext', it only works with SpanContext (typing mismatch)
32
+ options.references = referencedSpans.filter(s => s !== undefined).map(s => followsFrom(s!.context()));
21
33
  }
34
+
22
35
  return opentracing.globalTracer().startSpan(operation, options);
23
36
  }
24
37
 
25
- export function startAsyncSpan(operation: string, ctx: TraceContext): opentracing.Span {
26
- const options: opentracing.SpanOptions = {};
27
- if (!!ctx.span) {
28
- options.references = [opentracing.followsFrom(ctx.span.context())];
38
+ export function childContext(operation: string, parentCtx: TraceContext): TraceContextWithSpan {
39
+ const span = startSpan(operation, parentCtx);
40
+ return { span };
41
+ }
42
+
43
+ export function withSpan(operation: string, callback: () => void, ctx?: TraceContext, ...referencedSpans: (opentracing.Span | undefined)[]): void {
44
+ // if we don't have a parent span, don't create a trace here as those <trace-without-root-spans> are not useful.
45
+ if (!ctx || !ctx.span || !ctx.span.context()) {
46
+ callback();
47
+ return;
29
48
  }
30
- return opentracing.globalTracer().startSpan(operation, options);
49
+
50
+ const span = TraceContext.startSpan(operation, ctx, ...referencedSpans);
51
+ try {
52
+ callback();
53
+ } catch (e) {
54
+ TraceContext.setError({span}, e);
55
+ throw e;
56
+ } finally {
57
+ span.finish();
58
+ }
59
+ }
60
+
61
+ export function setError(ctx: TraceContext, err: Error) {
62
+ if (!ctx.span) {
63
+ return;
64
+ }
65
+
66
+ TraceContext.addNestedTags(ctx, {
67
+ error: {
68
+ message: err.message,
69
+ stacktrace: err.stack,
70
+ },
71
+ });
72
+ ctx.span.setTag("error", true);
73
+ }
74
+
75
+ export function setJsonRPCMetadata(ctx: TraceContext, method?: string) {
76
+ if (!ctx.span) {
77
+ return;
78
+ }
79
+
80
+ const tags: { [key: string]: any } = {
81
+ rpc: {
82
+ system: "jsonrpc",
83
+ // version,
84
+ },
85
+ };
86
+ if (method) {
87
+ tags.rpc.method = method;
88
+ }
89
+ addNestedTags(ctx, tags);
31
90
  }
32
91
 
33
- export function logError(ctx: TraceContext, err: Error) {
92
+ export function setJsonRPCError(ctx: TraceContext, method: string, err: ResponseError<any>, withStatusCode: boolean = false) {
34
93
  if (!ctx.span) {
35
94
  return;
36
95
  }
96
+ // not use setError bc this is (most likely) a working operation
37
97
 
38
- ctx.span.log({
39
- "error": err.message,
40
- "stacktrace": err.stack
41
- })
42
- ctx.span.setTag("error", true)
98
+ setJsonRPCMetadata(ctx, method);
99
+ // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/rpc.md#json-rpc
100
+ addNestedTags(ctx, {
101
+ rpc: {
102
+ jsonrpc: {
103
+ error_code: err.code,
104
+ error_message: err.message,
105
+ },
106
+ },
107
+ });
108
+
109
+ // the field "status_code" is used by honeycomb to derive insights like success rate, etc. Defaults to "0".
110
+ if (withStatusCode) {
111
+ ctx.span.setTag("status_code", err.code);
112
+ }
113
+ }
114
+
115
+ export function addJsonRPCParameters(ctx: TraceContext, params: { [key: string]: any }) {
116
+ if (!ctx.span) {
117
+ return;
118
+ }
119
+
120
+ setJsonRPCMetadata(ctx);
121
+ addNestedTags(ctx, {
122
+ rpc: {
123
+ jsonrpc: {
124
+ parameters: params,
125
+ },
126
+ },
127
+ });
128
+ }
129
+
130
+ /**
131
+ * Does what one would expect from `span.addTags`: Calls `span.addTag` for all keys in map, recursively for objects.
132
+ * Example:
133
+ * ```
134
+ * TraceContext.addNestedTags(ctx, {
135
+ * rpc: {
136
+ * system: "jsonrpc",
137
+ * jsonrpc: {
138
+ * version: "1.0",
139
+ * method: "test",
140
+ * parameters: ["abc", "def"],
141
+ * },
142
+ * },
143
+ * });
144
+ * ```
145
+ * gives
146
+ * rpc.system = "jsonrpc"
147
+ * rpc.jsonrpc.version = "1.0"
148
+ * rpc.jsonrpc.method = "test"
149
+ * rpc.jsonrpc.parameters.0 = "abc"
150
+ * rpc.jsonrpc.parameters.1 = "def"
151
+ * @param ctx
152
+ * @param keyValueMap
153
+ * @returns
154
+ */
155
+ export function addNestedTags(ctx: TraceContext, keyValueMap: { [key: string]: any }, _namespace?: string) {
156
+ if (!ctx.span) {
157
+ return;
158
+ }
159
+ const namespace = _namespace ? `${_namespace}.` : '';
160
+
161
+ try {
162
+ for (const k of Object.keys(keyValueMap)) {
163
+ const v = keyValueMap[k];
164
+ if (v instanceof Object) {
165
+ addNestedTags(ctx, v, `${namespace}${k}`);
166
+ } else {
167
+ ctx.span.setTag(`${namespace}${k}`, v);
168
+ }
169
+ }
170
+ } catch (err) {
171
+ // general resilience against odd shapes/parameters
172
+ log.error("Tracing.addNestedTags", err, { namespace });
173
+ }
174
+ }
175
+
176
+ export function setOWI(ctx: TraceContext, owi: LogContext) {
177
+ if (!ctx.span) {
178
+ return;
179
+ }
180
+ addNestedTags(ctx, {
181
+ context: owi,
182
+ });
43
183
  }
44
184
  }
45
185
 
@@ -56,11 +196,16 @@ export class TracingManager {
56
196
  reporter: {
57
197
  logSpans: false
58
198
  },
59
- serviceName
199
+ serviceName,
60
200
  }
61
201
  const t = initTracerFromEnv(config, {
62
- logger: console
202
+ logger: console,
203
+ tags: {
204
+ 'service.build.commit': process.env.GITPOD_BUILD_GIT_COMMIT,
205
+ 'service.build.version': process.env.GITPOD_BUILD_VERSION,
206
+ }
63
207
  });
208
+
64
209
  if (opts) {
65
210
  if (opts.perOpSampling) {
66
211
  (t as any)._sampler = new PerOperationSampler((t as any)._sampler, opts.perOpSampling);
@@ -132,3 +277,20 @@ export class PerOperationSampler implements Sampler {
132
277
  }
133
278
  }
134
279
  }
280
+
281
+ // Augment interfaces with an leading parameter "TraceContext" on every method
282
+ type IsValidArg<T> = T extends object ? keyof T extends never ? false : true : true;
283
+ type AddTraceContext<T> =
284
+ T extends (a: infer A, b: infer B, c: infer C, d: infer D, e: infer E, f: infer F) => infer R ? (
285
+ IsValidArg<F> extends true ? (ctx: TraceContextWithSpan, a: A, b: B, c: C, d: D, e: E, f: F) => R :
286
+ IsValidArg<E> extends true ? (ctx: TraceContextWithSpan, a: A, b: B, c: C, d: D, e: E) => R :
287
+ IsValidArg<D> extends true ? (ctx: TraceContextWithSpan, a: A, b: B, c: C, d: D) => R :
288
+ IsValidArg<C> extends true ? (ctx: TraceContextWithSpan, a: A, b: B, c: C) => R :
289
+ IsValidArg<B> extends true ? (ctx: TraceContextWithSpan, a: A, b: B) => R :
290
+ IsValidArg<A> extends true ? (ctx: TraceContextWithSpan, a: A) => R :
291
+ (ctx: TraceContextWithSpan) => Promise<R>
292
+ ) : never;
293
+
294
+ export type InterfaceWithTraceContext<T> = {
295
+ [P in keyof T]: AddTraceContext<T[P]>
296
+ };
@@ -134,9 +134,6 @@ export interface WorkspaceInstanceConditions {
134
134
  // PullingImages marks if the workspace is currently pulling its images. This condition can only be set during PhaseCreating
135
135
  pullingImages?: boolean
136
136
 
137
- // ServiceExists denotes if the workspace theia-/ports- services exist. This condition will be true if either of the two services exist.
138
- serviceExists?: boolean
139
-
140
137
  // deployed marks that a workspace instance was sent/deployed at a workspace manager
141
138
  deployed?: boolean;
142
139
 
@@ -148,6 +145,9 @@ export interface WorkspaceInstanceConditions {
148
145
 
149
146
  // headless_task_failed indicates that a headless workspace task failed
150
147
  headlessTaskFailed?: string;
148
+
149
+ // stopped_by_request is true if the workspace was stopped using a StopWorkspace call
150
+ stoppedByRequest?: boolean;
151
151
  }
152
152
 
153
153
  // AdmissionLevel describes who can access a workspace instance and its ports.
@@ -161,9 +161,6 @@ export interface WorkspaceInstancePort {
161
161
  // The outward-facing port number
162
162
  port: number;
163
163
 
164
- // An optional inward-facing port number. If not present we'll use port.
165
- targetPort?: number;
166
-
167
164
  // The visiblity of this port. Optional for backwards compatibility.
168
165
  visibility?: PortVisibility;
169
166
 
@@ -209,4 +206,10 @@ export interface WorkspaceInstanceConfiguration {
209
206
 
210
207
  // ideImage is the ref of the IDE image this instance uses.
211
208
  ideImage: string;
209
+
210
+ // desktopIdeImage is the ref of the desktop IDE image this instance uses.
211
+ desktopIdeImage?: string
212
+
213
+ // supervisorImage is the ref of the supervisor image this instance uses.
214
+ supervisorImage?: string;
212
215
  }
package/src/wsready.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
- // generated using github.com/32leaves/bel on 2021-08-03 10:42:32.582603295 +0000 UTC m=+0.005734479
7
+ // generated using github.com/32leaves/bel on 2021-11-04 12:16:53.917570766 +0000 UTC m=+0.006002884
8
8
  // DO NOT MODIFY
9
9
 
10
10
  export enum WorkspaceInitSource {
@@ -1,22 +0,0 @@
1
- /**
2
- * Copyright (c) 2020 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
- import { Deferred } from "./deferred";
7
- /**
8
- * Repeats a given function until it is stopped
9
- */
10
- export declare class Repeater {
11
- protected readonly fn: () => Promise<void> | void;
12
- protected readonly timeout: number;
13
- protected shouldRun: boolean;
14
- protected finished: Deferred<void>;
15
- protected timer?: any;
16
- constructor(fn: () => Promise<void> | void, timeout: number);
17
- start(): Promise<void>;
18
- run(): Promise<void>;
19
- protected sleep(timeout: number): Promise<unknown>;
20
- stop(): Promise<void>;
21
- }
22
- //# sourceMappingURL=repeater.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"repeater.d.ts","sourceRoot":"","sources":["../../src/util/repeater.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC;;GAEG;AACH,qBAAa,QAAQ;IAKL,SAAS,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM;IAJjG,SAAS,CAAC,SAAS,EAAE,OAAO,CAAC;IAC7B,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAA;IAClC,SAAS,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC;gBAES,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,EAAqB,OAAO,EAAE,MAAM;IAE3F,KAAK;IAIL,GAAG;cAcO,KAAK,CAAC,OAAO,EAAE,MAAM;IAI/B,IAAI;CAOb"}
@@ -1,118 +0,0 @@
1
- "use strict";
2
- /**
3
- * Copyright (c) 2020 Gitpod GmbH. All rights reserved.
4
- * Licensed under the GNU Affero General Public License (AGPL).
5
- * See License-AGPL.txt in the project root for license information.
6
- */
7
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
9
- return new (P || (P = Promise))(function (resolve, reject) {
10
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
12
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
13
- step((generator = generator.apply(thisArg, _arguments || [])).next());
14
- });
15
- };
16
- var __generator = (this && this.__generator) || function (thisArg, body) {
17
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
18
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
19
- function verb(n) { return function (v) { return step([n, v]); }; }
20
- function step(op) {
21
- if (f) throw new TypeError("Generator is already executing.");
22
- while (_) try {
23
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
24
- if (y = 0, t) op = [op[0] & 2, t.value];
25
- switch (op[0]) {
26
- case 0: case 1: t = op; break;
27
- case 4: _.label++; return { value: op[1], done: false };
28
- case 5: _.label++; y = op[1]; op = [0]; continue;
29
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
30
- default:
31
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
32
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
33
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
34
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
35
- if (t[2]) _.ops.pop();
36
- _.trys.pop(); continue;
37
- }
38
- op = body.call(thisArg, _);
39
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
40
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
41
- }
42
- };
43
- Object.defineProperty(exports, "__esModule", { value: true });
44
- exports.Repeater = void 0;
45
- var deferred_1 = require("./deferred");
46
- var logging_1 = require("./logging");
47
- /**
48
- * Repeats a given function until it is stopped
49
- */
50
- var Repeater = /** @class */ (function () {
51
- function Repeater(fn, timeout) {
52
- this.fn = fn;
53
- this.timeout = timeout;
54
- }
55
- Repeater.prototype.start = function () {
56
- return __awaiter(this, void 0, void 0, function () {
57
- return __generator(this, function (_a) {
58
- this.run();
59
- return [2 /*return*/];
60
- });
61
- });
62
- };
63
- Repeater.prototype.run = function () {
64
- return __awaiter(this, void 0, void 0, function () {
65
- var err_1;
66
- return __generator(this, function (_a) {
67
- switch (_a.label) {
68
- case 0:
69
- this.shouldRun = true;
70
- this.finished = new deferred_1.Deferred();
71
- _a.label = 1;
72
- case 1:
73
- if (!this.shouldRun) return [3 /*break*/, 7];
74
- _a.label = 2;
75
- case 2:
76
- _a.trys.push([2, 4, , 5]);
77
- return [4 /*yield*/, this.fn()];
78
- case 3:
79
- _a.sent();
80
- return [3 /*break*/, 5];
81
- case 4:
82
- err_1 = _a.sent();
83
- logging_1.log.error(err_1);
84
- return [3 /*break*/, 5];
85
- case 5: return [4 /*yield*/, this.sleep(this.timeout)];
86
- case 6:
87
- _a.sent();
88
- return [3 /*break*/, 1];
89
- case 7:
90
- this.finished.resolve();
91
- return [2 /*return*/];
92
- }
93
- });
94
- });
95
- };
96
- Repeater.prototype.sleep = function (timeout) {
97
- return __awaiter(this, void 0, void 0, function () {
98
- var _this = this;
99
- return __generator(this, function (_a) {
100
- return [2 /*return*/, new Promise(function (resolve) { return _this.timer = setTimeout(resolve, timeout); })];
101
- });
102
- });
103
- };
104
- Repeater.prototype.stop = function () {
105
- return __awaiter(this, void 0, void 0, function () {
106
- return __generator(this, function (_a) {
107
- this.shouldRun = false;
108
- if (this.timer) {
109
- clearTimeout(this.timer);
110
- }
111
- return [2 /*return*/, this.finished.promise];
112
- });
113
- });
114
- };
115
- return Repeater;
116
- }());
117
- exports.Repeater = Repeater;
118
- //# sourceMappingURL=repeater.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"repeater.js","sourceRoot":"","sources":["../../src/util/repeater.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAsC;AACtC,qCAAgC;AAEhC;;GAEG;AACH;IAKI,kBAA+B,EAA8B,EAAqB,OAAe;QAAlE,OAAE,GAAF,EAAE,CAA4B;QAAqB,YAAO,GAAP,OAAO,CAAQ;IAAI,CAAC;IAEhG,wBAAK,GAAX;;;gBACI,IAAI,CAAC,GAAG,EAAE,CAAC;;;;KACd;IAEK,sBAAG,GAAT;;;;;;wBACI,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;wBACtB,IAAI,CAAC,QAAQ,GAAG,IAAI,mBAAQ,EAAQ,CAAC;;;6BAC9B,IAAI,CAAC,SAAS;;;;wBAEb,qBAAM,IAAI,CAAC,EAAE,EAAE,EAAA;;wBAAf,SAAe,CAAC;;;;wBAEhB,aAAG,CAAC,KAAK,CAAC,KAAG,CAAC,CAAC;;4BAEnB,qBAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,EAAA;;wBAA9B,SAA8B,CAAC;;;wBAEnC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;;;;;KAC3B;IAEe,wBAAK,GAArB,UAAsB,OAAe;;;;gBACjC,sBAAO,IAAI,OAAO,CAAC,UAAA,OAAO,IAAI,OAAA,KAAI,CAAC,KAAK,GAAG,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,EAAzC,CAAyC,CAAC,EAAC;;;KAC5E;IAEK,uBAAI,GAAV;;;gBACI,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;gBACvB,IAAI,IAAI,CAAC,KAAK,EAAE;oBACZ,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;iBAC5B;gBACD,sBAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAC;;;KAChC;IACL,eAAC;AAAD,CAAC,AApCD,IAoCC;AApCY,4BAAQ"}