@gitpod/gitpod-protocol 0.1.5-svenefftinge-patch-1.3 → 0.1.5-tarun-telemetry-users.1

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 (259) 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 +18 -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 +13 -1
  11. package/lib/analytics.d.ts.map +1 -1
  12. package/lib/context-url.d.ts +1 -0
  13. package/lib/context-url.d.ts.map +1 -1
  14. package/lib/context-url.js +7 -5
  15. package/lib/context-url.js.map +1 -1
  16. package/lib/context-url.spec.js +45 -48
  17. package/lib/context-url.spec.js.map +1 -1
  18. package/lib/email-protocol.js +4 -4
  19. package/lib/email-protocol.js.map +1 -1
  20. package/lib/encryption/container-module.js +4 -4
  21. package/lib/encryption/container-module.js.map +1 -1
  22. package/lib/encryption/encryption-engine.js +19 -20
  23. package/lib/encryption/encryption-engine.js.map +1 -1
  24. package/lib/encryption/encryption-engine.spec.js +29 -36
  25. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  26. package/lib/encryption/encryption-service.js +29 -43
  27. package/lib/encryption/encryption-service.js.map +1 -1
  28. package/lib/encryption/key-provider.js +25 -30
  29. package/lib/encryption/key-provider.js.map +1 -1
  30. package/lib/env.d.ts +1 -2
  31. package/lib/env.d.ts.map +1 -1
  32. package/lib/env.js +20 -21
  33. package/lib/env.js.map +1 -1
  34. package/lib/gitpod-file-parser.js +25 -41
  35. package/lib/gitpod-file-parser.js.map +1 -1
  36. package/lib/gitpod-file-parser.spec.js +116 -116
  37. package/lib/gitpod-file-parser.spec.js.map +1 -1
  38. package/lib/gitpod-service.d.ts +68 -20
  39. package/lib/gitpod-service.d.ts.map +1 -1
  40. package/lib/gitpod-service.js +151 -295
  41. package/lib/gitpod-service.js.map +1 -1
  42. package/lib/headless-workspace-log.d.ts +1 -12
  43. package/lib/headless-workspace-log.d.ts.map +1 -1
  44. package/lib/headless-workspace-log.js +1 -7
  45. package/lib/headless-workspace-log.js.map +1 -1
  46. package/lib/ide-protocol.d.ts +101 -0
  47. package/lib/ide-protocol.d.ts.map +1 -0
  48. package/lib/ide-protocol.js +8 -0
  49. package/lib/ide-protocol.js.map +1 -0
  50. package/lib/index.d.ts +3 -0
  51. package/lib/index.d.ts.map +1 -1
  52. package/lib/index.js +3 -0
  53. package/lib/index.js.map +1 -1
  54. package/lib/installation-admin-protocol.d.ts +25 -0
  55. package/lib/installation-admin-protocol.d.ts.map +1 -0
  56. package/lib/installation-admin-protocol.js +30 -0
  57. package/lib/installation-admin-protocol.js.map +1 -0
  58. package/lib/messaging/browser/connection.d.ts +3 -3
  59. package/lib/messaging/browser/connection.d.ts.map +1 -1
  60. package/lib/messaging/browser/connection.js +172 -35
  61. package/lib/messaging/browser/connection.js.map +1 -1
  62. package/lib/messaging/browser/window-connection.js +35 -55
  63. package/lib/messaging/browser/window-connection.js.map +1 -1
  64. package/lib/messaging/client-call-metrics.d.ts +35 -0
  65. package/lib/messaging/client-call-metrics.d.ts.map +1 -0
  66. package/lib/messaging/client-call-metrics.js +83 -0
  67. package/lib/messaging/client-call-metrics.js.map +1 -0
  68. package/lib/messaging/connection-error-handler.js +11 -23
  69. package/lib/messaging/connection-error-handler.js.map +1 -1
  70. package/lib/messaging/error.d.ts +2 -1
  71. package/lib/messaging/error.d.ts.map +1 -1
  72. package/lib/messaging/error.js +4 -2
  73. package/lib/messaging/error.js.map +1 -1
  74. package/lib/messaging/handler.d.ts +10 -0
  75. package/lib/messaging/handler.d.ts.map +1 -1
  76. package/lib/messaging/node/connection.d.ts +1 -17
  77. package/lib/messaging/node/connection.d.ts.map +1 -1
  78. package/lib/messaging/node/connection.js +23 -59
  79. package/lib/messaging/node/connection.js.map +1 -1
  80. package/lib/messaging/proxy-factory.d.ts +2 -0
  81. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  82. package/lib/messaging/proxy-factory.js +74 -159
  83. package/lib/messaging/proxy-factory.js.map +1 -1
  84. package/lib/oss-allowlist.d.ts +14 -0
  85. package/lib/oss-allowlist.d.ts.map +1 -0
  86. package/lib/oss-allowlist.js +8 -0
  87. package/lib/oss-allowlist.js.map +1 -0
  88. package/lib/permission.d.ts +4 -2
  89. package/lib/permission.d.ts.map +1 -1
  90. package/lib/permission.js +16 -13
  91. package/lib/permission.js.map +1 -1
  92. package/lib/plans.d.ts +1 -1
  93. package/lib/plans.d.ts.map +1 -1
  94. package/lib/plans.js +38 -57
  95. package/lib/plans.js.map +1 -1
  96. package/lib/protocol.d.ts +51 -49
  97. package/lib/protocol.d.ts.map +1 -1
  98. package/lib/protocol.js +57 -115
  99. package/lib/protocol.js.map +1 -1
  100. package/lib/snapshot-url.d.ts +14 -0
  101. package/lib/snapshot-url.d.ts.map +1 -0
  102. package/lib/snapshot-url.js +26 -0
  103. package/lib/snapshot-url.js.map +1 -0
  104. package/lib/snapshot-url.spec.d.ts +7 -0
  105. package/lib/snapshot-url.spec.d.ts.map +1 -0
  106. package/lib/snapshot-url.spec.js +41 -0
  107. package/lib/snapshot-url.spec.js.map +1 -0
  108. package/lib/team-subscription-protocol.js +13 -13
  109. package/lib/team-subscription-protocol.js.map +1 -1
  110. package/lib/teams-projects-protocol.d.ts +59 -6
  111. package/lib/teams-projects-protocol.d.ts.map +1 -1
  112. package/lib/teams-projects-protocol.js +18 -15
  113. package/lib/teams-projects-protocol.js.map +1 -1
  114. package/lib/util/analytics.d.ts.map +1 -1
  115. package/lib/util/analytics.js +35 -26
  116. package/lib/util/analytics.js.map +1 -1
  117. package/lib/util/async-iterator.js +55 -133
  118. package/lib/util/async-iterator.js.map +1 -1
  119. package/lib/util/cancelable.js +17 -59
  120. package/lib/util/cancelable.js.map +1 -1
  121. package/lib/util/date-time.js +8 -8
  122. package/lib/util/date-time.js.map +1 -1
  123. package/lib/util/deferred.js +10 -12
  124. package/lib/util/deferred.js.map +1 -1
  125. package/lib/util/disposable.js +26 -39
  126. package/lib/util/disposable.js.map +1 -1
  127. package/lib/util/event.js +58 -74
  128. package/lib/util/event.js.map +1 -1
  129. package/lib/util/garbage-collected-cache.d.ts +1 -0
  130. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  131. package/lib/util/garbage-collected-cache.js +26 -46
  132. package/lib/util/garbage-collected-cache.js.map +1 -1
  133. package/lib/util/generate-workspace-id.d.ts +1 -1
  134. package/lib/util/generate-workspace-id.d.ts.map +1 -1
  135. package/lib/util/generate-workspace-id.js +29 -68
  136. package/lib/util/generate-workspace-id.js.map +1 -1
  137. package/lib/util/generate-workspace-id.spec.js +57 -78
  138. package/lib/util/generate-workspace-id.spec.js.map +1 -1
  139. package/lib/util/gitpod-cookie.d.ts +20 -0
  140. package/lib/util/gitpod-cookie.d.ts.map +1 -0
  141. package/lib/util/gitpod-cookie.js +44 -0
  142. package/lib/util/gitpod-cookie.js.map +1 -0
  143. package/lib/util/gitpod-host-url.d.ts +1 -1
  144. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  145. package/lib/util/gitpod-host-url.js +93 -103
  146. package/lib/util/gitpod-host-url.js.map +1 -1
  147. package/lib/util/gitpod-host-url.spec.js +87 -135
  148. package/lib/util/gitpod-host-url.spec.js.map +1 -1
  149. package/lib/util/grpc.d.ts +15 -0
  150. package/lib/util/grpc.d.ts.map +1 -0
  151. package/lib/util/grpc.js +18 -0
  152. package/lib/util/grpc.js.map +1 -0
  153. package/lib/util/jaeger-client-types.d.ts +68 -0
  154. package/lib/util/jaeger-client-types.d.ts.map +1 -0
  155. package/lib/util/jaeger-client-types.js +8 -0
  156. package/lib/util/jaeger-client-types.js.map +1 -0
  157. package/lib/util/logging.d.ts +49 -33
  158. package/lib/util/logging.d.ts.map +1 -1
  159. package/lib/util/logging.js +107 -110
  160. package/lib/util/logging.js.map +1 -1
  161. package/lib/util/make-link.js +2 -2
  162. package/lib/util/make-link.js.map +1 -1
  163. package/lib/util/parse-workspace-id.d.ts +10 -0
  164. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  165. package/lib/util/parse-workspace-id.js +31 -7
  166. package/lib/util/parse-workspace-id.js.map +1 -1
  167. package/lib/util/parse-workspace-id.spec.d.ts +4 -0
  168. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  169. package/lib/util/parse-workspace-id.spec.js +123 -84
  170. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  171. package/lib/util/queue.js +16 -55
  172. package/lib/util/queue.js.map +1 -1
  173. package/lib/util/queue.spec.js +144 -288
  174. package/lib/util/queue.spec.js.map +1 -1
  175. package/lib/util/repeat.d.ts +15 -0
  176. package/lib/util/repeat.d.ts.map +1 -0
  177. package/lib/util/repeat.js +55 -0
  178. package/lib/util/repeat.js.map +1 -0
  179. package/lib/util/semaphore.js +15 -46
  180. package/lib/util/semaphore.js.map +1 -1
  181. package/lib/util/skip-if.js +6 -6
  182. package/lib/util/skip-if.js.map +1 -1
  183. package/lib/util/timeutil.js +16 -16
  184. package/lib/util/timeutil.js.map +1 -1
  185. package/lib/util/timeutil.spec.js +21 -24
  186. package/lib/util/timeutil.spec.js.map +1 -1
  187. package/lib/util/tracing.d.ts +51 -5
  188. package/lib/util/tracing.d.ts.map +1 -1
  189. package/lib/util/tracing.js +196 -62
  190. package/lib/util/tracing.js.map +1 -1
  191. package/lib/util/tracing.spec.d.ts +7 -0
  192. package/lib/util/tracing.spec.d.ts.map +1 -0
  193. package/lib/util/tracing.spec.js +121 -0
  194. package/lib/util/tracing.spec.js.map +1 -0
  195. package/lib/util/workspace-port-authentication.js +2 -2
  196. package/lib/util/workspace-port-authentication.js.map +1 -1
  197. package/lib/workspace-cluster.d.ts +8 -1
  198. package/lib/workspace-cluster.d.ts.map +1 -1
  199. package/lib/workspace-cluster.js +3 -3
  200. package/lib/workspace-cluster.js.map +1 -1
  201. package/lib/workspace-instance.d.ts +24 -2
  202. package/lib/workspace-instance.d.ts.map +1 -1
  203. package/lib/wsready.js +1 -1
  204. package/package.json +24 -13
  205. package/pkg-yarn.lock +14 -7
  206. package/provenance-bundle.jsonl +2 -0
  207. package/src/accounting-protocol.ts +1 -3
  208. package/src/admin-protocol.ts +25 -6
  209. package/src/analytics.ts +16 -1
  210. package/src/context-url.ts +3 -1
  211. package/src/email-protocol.ts +1 -1
  212. package/src/env.ts +10 -10
  213. package/src/gitpod-service.ts +88 -33
  214. package/src/headless-workspace-log.ts +1 -14
  215. package/src/ide-frontend-service.ts +1 -1
  216. package/src/ide-protocol.ts +114 -0
  217. package/src/index.ts +3 -0
  218. package/src/installation-admin-protocol.ts +40 -0
  219. package/src/messaging/browser/connection.ts +176 -10
  220. package/src/messaging/client-call-metrics.ts +97 -0
  221. package/src/messaging/error.ts +5 -2
  222. package/src/messaging/handler.ts +12 -0
  223. package/src/messaging/node/connection.ts +21 -68
  224. package/src/messaging/proxy-factory.ts +13 -5
  225. package/src/oss-allowlist.ts +15 -0
  226. package/src/permission.ts +5 -1
  227. package/src/protocol.ts +70 -54
  228. package/src/snapshot-url.spec.ts +25 -0
  229. package/src/snapshot-url.ts +27 -0
  230. package/src/team-subscription-protocol.ts +1 -1
  231. package/src/teams-projects-protocol.ts +78 -7
  232. package/src/util/analytics.ts +17 -1
  233. package/src/util/garbage-collected-cache.ts +7 -1
  234. package/src/util/generate-workspace-id.spec.ts +17 -0
  235. package/src/util/generate-workspace-id.ts +20 -2
  236. package/src/util/gitpod-cookie.ts +39 -0
  237. package/src/util/gitpod-host-url.ts +11 -11
  238. package/src/util/grpc.ts +15 -0
  239. package/src/util/jaeger-client-types.ts +102 -0
  240. package/src/util/logging.ts +102 -38
  241. package/src/util/parse-workspace-id.spec.ts +21 -1
  242. package/src/util/parse-workspace-id.ts +32 -6
  243. package/src/util/repeat.ts +45 -0
  244. package/src/util/tracing.spec.ts +83 -0
  245. package/src/util/tracing.ts +183 -18
  246. package/src/workspace-cluster.ts +3 -1
  247. package/src/workspace-instance.ts +35 -6
  248. package/src/wsready.ts +1 -1
  249. package/lib/util/repeater.d.ts +0 -22
  250. package/lib/util/repeater.d.ts.map +0 -1
  251. package/lib/util/repeater.js +0 -118
  252. package/lib/util/repeater.js.map +0 -1
  253. package/lib/util/safe-promise.d.ts +0 -11
  254. package/lib/util/safe-promise.d.ts.map +0 -1
  255. package/lib/util/safe-promise.js +0 -34
  256. package/lib/util/safe-promise.js.map +0 -1
  257. package/src/util/jaeger-client.d.ts +0 -105
  258. package/src/util/repeater.ts +0 -49
  259. package/src/util/safe-promise.ts +0 -26
@@ -6,40 +6,183 @@
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 && parentCtx.span && !!parentCtx.span.context().toSpanId()) {
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
+ // note2: we need to filter out debug spans (spanId === "")
33
+ options.references = referencedSpans.filter(s => s !== undefined)
34
+ .filter(s => !!s!.context().toSpanId())
35
+ .map(s => followsFrom(s!.context()));
21
36
  }
37
+
22
38
  return opentracing.globalTracer().startSpan(operation, options);
23
39
  }
24
40
 
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())];
41
+ export function childContext(operation: string, parentCtx: TraceContext): TraceContextWithSpan {
42
+ const span = startSpan(operation, parentCtx);
43
+ return { span };
44
+ }
45
+
46
+ export function withSpan(operation: string, callback: () => void, ctx?: TraceContext, ...referencedSpans: (opentracing.Span | undefined)[]): void {
47
+ // if we don't have a parent span, don't create a trace here as those <trace-without-root-spans> are not useful.
48
+ if (!ctx || !ctx.span || !ctx.span.context()) {
49
+ callback();
50
+ return;
29
51
  }
30
- return opentracing.globalTracer().startSpan(operation, options);
52
+
53
+ const span = TraceContext.startSpan(operation, ctx, ...referencedSpans);
54
+ try {
55
+ callback();
56
+ } catch (e) {
57
+ TraceContext.setError({span}, e);
58
+ throw e;
59
+ } finally {
60
+ span.finish();
61
+ }
62
+ }
63
+
64
+ export function setError(ctx: TraceContext, err: Error) {
65
+ if (!ctx.span) {
66
+ return;
67
+ }
68
+
69
+ TraceContext.addNestedTags(ctx, {
70
+ error: {
71
+ message: err.message,
72
+ stacktrace: err.stack,
73
+ },
74
+ });
75
+ ctx.span.setTag("error", true);
76
+ }
77
+
78
+ export function setJsonRPCMetadata(ctx: TraceContext, method?: string) {
79
+ if (!ctx.span) {
80
+ return;
81
+ }
82
+
83
+ const tags: { [key: string]: any } = {
84
+ rpc: {
85
+ system: "jsonrpc",
86
+ // version,
87
+ },
88
+ };
89
+ if (method) {
90
+ tags.rpc.method = method;
91
+ }
92
+ addNestedTags(ctx, tags);
31
93
  }
32
94
 
33
- export function logError(ctx: TraceContext, err: Error) {
95
+ export function setJsonRPCError(ctx: TraceContext, method: string, err: ResponseError<any>, withStatusCode: boolean = false) {
34
96
  if (!ctx.span) {
35
97
  return;
36
98
  }
99
+ // not use setError bc this is (most likely) a working operation
37
100
 
38
- ctx.span.log({
39
- "error": err.message,
40
- "stacktrace": err.stack
41
- })
42
- ctx.span.setTag("error", true)
101
+ setJsonRPCMetadata(ctx, method);
102
+ // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/rpc.md#json-rpc
103
+ addNestedTags(ctx, {
104
+ rpc: {
105
+ jsonrpc: {
106
+ error_code: err.code,
107
+ error_message: err.message,
108
+ },
109
+ },
110
+ });
111
+
112
+ // the field "status_code" is used by honeycomb to derive insights like success rate, etc. Defaults to "0".
113
+ if (withStatusCode) {
114
+ ctx.span.setTag("status_code", err.code);
115
+ }
116
+ }
117
+
118
+ export function addJsonRPCParameters(ctx: TraceContext, params: { [key: string]: any }) {
119
+ if (!ctx.span) {
120
+ return;
121
+ }
122
+
123
+ setJsonRPCMetadata(ctx);
124
+ addNestedTags(ctx, {
125
+ rpc: {
126
+ jsonrpc: {
127
+ parameters: params,
128
+ },
129
+ },
130
+ });
131
+ }
132
+
133
+ /**
134
+ * Does what one would expect from `span.addTags`: Calls `span.addTag` for all keys in map, recursively for objects.
135
+ * Example:
136
+ * ```
137
+ * TraceContext.addNestedTags(ctx, {
138
+ * rpc: {
139
+ * system: "jsonrpc",
140
+ * jsonrpc: {
141
+ * version: "1.0",
142
+ * method: "test",
143
+ * parameters: ["abc", "def"],
144
+ * },
145
+ * },
146
+ * });
147
+ * ```
148
+ * gives
149
+ * rpc.system = "jsonrpc"
150
+ * rpc.jsonrpc.version = "1.0"
151
+ * rpc.jsonrpc.method = "test"
152
+ * rpc.jsonrpc.parameters.0 = "abc"
153
+ * rpc.jsonrpc.parameters.1 = "def"
154
+ * @param ctx
155
+ * @param keyValueMap
156
+ * @returns
157
+ */
158
+ export function addNestedTags(ctx: TraceContext, keyValueMap: { [key: string]: any }, _namespace?: string) {
159
+ if (!ctx.span) {
160
+ return;
161
+ }
162
+ const namespace = _namespace ? `${_namespace}.` : '';
163
+
164
+ try {
165
+ for (const k of Object.keys(keyValueMap)) {
166
+ const v = keyValueMap[k];
167
+ if (v instanceof Object) {
168
+ addNestedTags(ctx, v, `${namespace}${k}`);
169
+ } else {
170
+ ctx.span.setTag(`${namespace}${k}`, v);
171
+ }
172
+ }
173
+ } catch (err) {
174
+ // general resilience against odd shapes/parameters
175
+ log.error("Tracing.addNestedTags", err, { namespace });
176
+ }
177
+ }
178
+
179
+ export function setOWI(ctx: TraceContext, owi: LogContext) {
180
+ if (!ctx.span) {
181
+ return;
182
+ }
183
+ addNestedTags(ctx, {
184
+ context: owi,
185
+ });
43
186
  }
44
187
  }
45
188
 
@@ -56,11 +199,16 @@ export class TracingManager {
56
199
  reporter: {
57
200
  logSpans: false
58
201
  },
59
- serviceName
202
+ serviceName,
60
203
  }
61
204
  const t = initTracerFromEnv(config, {
62
- logger: console
205
+ logger: console,
206
+ tags: {
207
+ 'service.build.commit': process.env.GITPOD_BUILD_GIT_COMMIT,
208
+ 'service.build.version': process.env.GITPOD_BUILD_VERSION,
209
+ }
63
210
  });
211
+
64
212
  if (opts) {
65
213
  if (opts.perOpSampling) {
66
214
  (t as any)._sampler = new PerOperationSampler((t as any)._sampler, opts.perOpSampling);
@@ -132,3 +280,20 @@ export class PerOperationSampler implements Sampler {
132
280
  }
133
281
  }
134
282
  }
283
+
284
+ // Augment interfaces with an leading parameter "TraceContext" on every method
285
+ type IsValidArg<T> = T extends object ? keyof T extends never ? false : true : true;
286
+ type AddTraceContext<T> =
287
+ T extends (a: infer A, b: infer B, c: infer C, d: infer D, e: infer E, f: infer F) => infer R ? (
288
+ IsValidArg<F> extends true ? (ctx: TraceContextWithSpan, a: A, b: B, c: C, d: D, e: E, f: F) => R :
289
+ IsValidArg<E> extends true ? (ctx: TraceContextWithSpan, a: A, b: B, c: C, d: D, e: E) => R :
290
+ IsValidArg<D> extends true ? (ctx: TraceContextWithSpan, a: A, b: B, c: C, d: D) => R :
291
+ IsValidArg<C> extends true ? (ctx: TraceContextWithSpan, a: A, b: B, c: C) => R :
292
+ IsValidArg<B> extends true ? (ctx: TraceContextWithSpan, a: A, b: B) => R :
293
+ IsValidArg<A> extends true ? (ctx: TraceContextWithSpan, a: A) => R :
294
+ (ctx: TraceContextWithSpan) => Promise<R>
295
+ ) : never;
296
+
297
+ export type InterfaceWithTraceContext<T> = {
298
+ [P in keyof T]: AddTraceContext<T[P]>
299
+ };
@@ -52,9 +52,11 @@ export namespace TLSConfig {
52
52
  export type WorkspaceClusterWoTLS = Omit<WorkspaceCluster, "tls">;
53
53
  export type WorkspaceManagerConnectionInfo = Pick<WorkspaceCluster, "name" | "url" | "tls">;
54
54
 
55
- export type AdmissionConstraint = AdmissionConstraintFeaturePreview | AdmissionConstraintHasRole;
55
+ export type AdmissionConstraint = AdmissionConstraintFeaturePreview | AdmissionConstraintHasRole | AdmissionConstraintHasUserLevel | AdmissionConstraintHasMoreResources;
56
56
  export type AdmissionConstraintFeaturePreview = { type: "has-feature-preview" };
57
57
  export type AdmissionConstraintHasRole = { type: "has-permission", permission: PermissionName };
58
+ export type AdmissionConstraintHasUserLevel = { type: "has-user-level", level: string };
59
+ export type AdmissionConstraintHasMoreResources = { type: "has-more-resources" };
58
60
 
59
61
 
60
62
  export const WorkspaceClusterDB = Symbol("WorkspaceClusterDB");
@@ -23,6 +23,9 @@ export interface WorkspaceInstance {
23
23
  // The time an instance has switched phase to 'Running'
24
24
  startedTime?: string;
25
25
 
26
+ // The time an instance has switched phase to 'Stopping' */
27
+ stoppingTime?: string;
28
+
26
29
  // The time an instance has switched phase to 'Stopped' */
27
30
  stoppedTime?: string;
28
31
 
@@ -48,6 +51,11 @@ export interface WorkspaceInstance {
48
51
 
49
52
  // instance is hard-deleted on the database and about to be collected by db-sync
50
53
  readonly deleted?: boolean;
54
+
55
+ /**
56
+ * Contains information about the image build, if there was any
57
+ */
58
+ imageBuildInfo?: ImageBuildInfo;
51
59
  }
52
60
 
53
61
  // WorkspaceInstanceStatus describes the current state of a workspace instance
@@ -131,9 +139,6 @@ export interface WorkspaceInstanceConditions {
131
139
  // PullingImages marks if the workspace is currently pulling its images. This condition can only be set during PhaseCreating
132
140
  pullingImages?: boolean
133
141
 
134
- // ServiceExists denotes if the workspace theia-/ports- services exist. This condition will be true if either of the two services exist.
135
- serviceExists?: boolean
136
-
137
142
  // deployed marks that a workspace instance was sent/deployed at a workspace manager
138
143
  deployed?: boolean;
139
144
 
@@ -142,6 +147,12 @@ export interface WorkspaceInstanceConditions {
142
147
 
143
148
  // ISO8601 timestamp when the first user activity was registered in the frontend. Only set if the workspace is running.
144
149
  firstUserActivity?: string;
150
+
151
+ // headless_task_failed indicates that a headless workspace task failed
152
+ headlessTaskFailed?: string;
153
+
154
+ // stopped_by_request is true if the workspace was stopped using a StopWorkspace call
155
+ stoppedByRequest?: boolean;
145
156
  }
146
157
 
147
158
  // AdmissionLevel describes who can access a workspace instance and its ports.
@@ -155,9 +166,6 @@ export interface WorkspaceInstancePort {
155
166
  // The outward-facing port number
156
167
  port: number;
157
168
 
158
- // An optional inward-facing port number. If not present we'll use port.
159
- targetPort?: number;
160
-
161
169
  // The visiblity of this port. Optional for backwards compatibility.
162
170
  visibility?: PortVisibility;
163
171
 
@@ -203,4 +211,25 @@ export interface WorkspaceInstanceConfiguration {
203
211
 
204
212
  // ideImage is the ref of the IDE image this instance uses.
205
213
  ideImage: string;
214
+
215
+ // desktopIdeImage is the ref of the desktop IDE image this instance uses.
216
+ desktopIdeImage?: string
217
+
218
+ // supervisorImage is the ref of the supervisor image this instance uses.
219
+ supervisorImage?: string;
220
+ }
221
+
222
+ /**
223
+ * Holds information about the image build (if there was one) for this WorkspaceInstance
224
+ */
225
+ export interface ImageBuildInfo {
226
+ log?: ImageBuildLogInfo,
227
+ }
228
+
229
+ /**
230
+ * Holds information about how to access logs for this an image build
231
+ */
232
+ export interface ImageBuildLogInfo {
233
+ url: string,
234
+ headers: { [key: string]: string },
206
235
  }
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-07-01 13:33:23.288163364 +0000 UTC m=+0.012145659
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"}
@@ -1,11 +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 { LogContext } from './logging';
7
- export declare class SafePromise {
8
- static catchAndLog<T>(p: Promise<T>, logCtx?: LogContext): Promise<T>;
9
- static catch<T>(p: Promise<T>, handler: (err: any) => void): Promise<T>;
10
- }
11
- //# sourceMappingURL=safe-promise.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"safe-promise.d.ts","sourceRoot":"","sources":["../../src/util/safe-promise.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAO,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,qBAAa,WAAW;WACN,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,UAAU;WASjD,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC;CAMjF"}
@@ -1,34 +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
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.SafePromise = void 0;
9
- var logging_1 = require("./logging");
10
- var SafePromise = /** @class */ (function () {
11
- function SafePromise() {
12
- }
13
- SafePromise.catchAndLog = function (p, logCtx) {
14
- return SafePromise.catch(p, function (err) {
15
- if (logCtx) {
16
- logging_1.log.error(logCtx, err);
17
- }
18
- else {
19
- logging_1.log.error(err);
20
- }
21
- });
22
- };
23
- ;
24
- SafePromise.catch = function (p, handler) {
25
- return p.catch(function (err) {
26
- handler(err);
27
- return {}; // Nobody will ever see this value as the Promise already failed. It's just there to please the compiler
28
- });
29
- };
30
- ;
31
- return SafePromise;
32
- }());
33
- exports.SafePromise = SafePromise;
34
- //# sourceMappingURL=safe-promise.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"safe-promise.js","sourceRoot":"","sources":["../../src/util/safe-promise.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAGH,qCAA4C;AAE5C;IAAA;IAgBA,CAAC;IAfiB,uBAAW,GAAzB,UAA6B,CAAa,EAAE,MAAmB;QAC3D,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,UAAC,GAAG;YAC5B,IAAI,MAAM,EAAE;gBACR,aAAG,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;aAC1B;iBAAM;gBACH,aAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;aAClB;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAAA,CAAC;IACY,iBAAK,GAAnB,UAAuB,CAAa,EAAE,OAA2B;QAC7D,OAAO,CAAC,CAAC,KAAK,CAAC,UAAC,GAAG;YACf,OAAO,CAAC,GAAG,CAAC,CAAC;YACb,OAAO,EAAO,CAAC,CAAC,wGAAwG;QAC5H,CAAC,CAAC,CAAC;IACP,CAAC;IAAA,CAAC;IACN,kBAAC;AAAD,CAAC,AAhBD,IAgBC;AAhBY,kCAAW"}
@@ -1,105 +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
-
7
- // Type definitions for jaeger-client
8
- // Project: https://github.com/uber/jaeger-client-node
9
- // Definitions by: Julian Steger <https://github.com/julianste>
10
- // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
11
-
12
- declare module 'jaeger-client' {
13
- import * as opentracing from "opentracing";
14
-
15
- export interface TracingConfig {
16
- serviceName?: string;
17
- disable?: boolean;
18
- sampler?: SamplerConfig;
19
- reporter?: ReporterConfig;
20
- }
21
-
22
- export interface TracingOptions {
23
- reporter?: Reporter;
24
- metrics?: MetricsFactory;
25
- logger?: Logger;
26
- tags?: any;
27
- }
28
-
29
- export interface ReporterConfig {
30
- logSpans?: boolean;
31
- agentHost?: string;
32
- agentPort?: number;
33
- flushIntervalMs?: number;
34
- }
35
-
36
- export interface SamplerConfig {
37
- type: string;
38
- param: number;
39
- host?: string;
40
- port?: number;
41
- refreshIntervalMs?: number;
42
- }
43
-
44
- export interface Logger {
45
- info(msg: string): void;
46
- error(msg: string): void;
47
- }
48
-
49
- export interface Reporter {
50
- report(span: opentracing.Span): void;
51
- close(callback?: () => void): void;
52
- setProcess(serviceName: string, tags: any): void;
53
- }
54
-
55
- export interface MetricsFactory {
56
- createCounter(name: string, tags: any): Counter;
57
- createTimer(name: string, tags: any): Timer;
58
- createGauge(name: string, tags: any): Gauge;
59
- }
60
-
61
- // Counter tracks the number of times an event has occurred
62
- export interface Counter {
63
- // Adds the given value to the counter.
64
- increment(delta: number): void;
65
- }
66
-
67
- // Timer tracks how long an operation took and also computes percentiles.
68
- export interface Timer {
69
- // Records the time passed in.
70
- record(value: number): void;
71
- }
72
-
73
- // Gauge returns instantaneous measurements of something as an int64 value
74
- export interface Gauge {
75
- // Update the gauge to the value passed in.
76
- update(value: number): void;
77
- }
78
-
79
- export function initTracer(
80
- tracingConfig: TracingConfig,
81
- tracingOptions: TracingOptions,
82
- ): opentracing.Tracer;
83
-
84
- export function initTracerFromEnv(
85
- tracingConfig: TracingConfig,
86
- tracingOptions: TracingOptions,
87
- ): opentracing.Tracer;
88
-
89
- export interface SamplingDecision {
90
- sample: boolean;
91
- retryable: boolean;
92
- tags: any;
93
- }
94
-
95
- // added by TypeFox
96
- export interface Sampler {
97
- name(): string
98
- isSampled(operation: string, tags: any): boolean;
99
- onCreateSpan(span: opentracing.Span): SamplingDecision;
100
- onSetOperationName(span: opentracing.Span, operationName: string): SamplingDecision;
101
- onSetTag(span: opentracing.Span, key: string, value: any): SamplingDecision;
102
- close(callback: () => void): void
103
- }
104
-
105
- }