@gitpod/gitpod-protocol 0.1.5-test.9 → 0.1.5-tweak-workspaceconfig-origin-docs-fork.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.
Files changed (331) hide show
  1. package/data/builtin-theia-plugins.json +28 -18
  2. package/data/gitpod-schema.json +17 -17
  3. package/lib/accounting-protocol.d.ts +155 -0
  4. package/lib/accounting-protocol.d.ts.map +1 -0
  5. package/lib/accounting-protocol.js +109 -0
  6. package/lib/accounting-protocol.js.map +1 -0
  7. package/lib/admin-protocol.d.ts +22 -5
  8. package/lib/admin-protocol.d.ts.map +1 -1
  9. package/lib/admin-protocol.js +16 -1
  10. package/lib/admin-protocol.js.map +1 -1
  11. package/lib/analytics.d.ts +45 -0
  12. package/lib/analytics.d.ts.map +1 -0
  13. package/lib/analytics.js +10 -0
  14. package/lib/analytics.js.map +1 -0
  15. package/lib/auth.d.ts +25 -0
  16. package/lib/auth.d.ts.map +1 -0
  17. package/lib/auth.js +16 -0
  18. package/lib/auth.js.map +1 -0
  19. package/lib/context-url.d.ts +18 -0
  20. package/lib/context-url.d.ts.map +1 -0
  21. package/lib/context-url.js +49 -0
  22. package/lib/context-url.js.map +1 -0
  23. package/lib/context-url.spec.d.ts +12 -0
  24. package/lib/context-url.spec.d.ts.map +1 -0
  25. package/lib/context-url.spec.js +73 -0
  26. package/lib/context-url.spec.js.map +1 -0
  27. package/lib/email-protocol.d.ts +2 -2
  28. package/lib/email-protocol.d.ts.map +1 -1
  29. package/lib/email-protocol.js +6 -5
  30. package/lib/email-protocol.js.map +1 -1
  31. package/lib/encryption/container-module.d.ts +1 -1
  32. package/lib/encryption/container-module.js +7 -5
  33. package/lib/encryption/container-module.js.map +1 -1
  34. package/lib/encryption/encryption-engine.d.ts +1 -1
  35. package/lib/encryption/encryption-engine.js +21 -21
  36. package/lib/encryption/encryption-engine.js.map +1 -1
  37. package/lib/encryption/encryption-engine.spec.d.ts +2 -2
  38. package/lib/encryption/encryption-engine.spec.d.ts.map +1 -1
  39. package/lib/encryption/encryption-engine.spec.js +31 -37
  40. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  41. package/lib/encryption/encryption-service.d.ts +1 -1
  42. package/lib/encryption/encryption-service.js +31 -44
  43. package/lib/encryption/encryption-service.js.map +1 -1
  44. package/lib/encryption/key-provider.d.ts +2 -2
  45. package/lib/encryption/key-provider.d.ts.map +1 -1
  46. package/lib/encryption/key-provider.js +27 -31
  47. package/lib/encryption/key-provider.js.map +1 -1
  48. package/lib/env.d.ts +2 -3
  49. package/lib/env.d.ts.map +1 -1
  50. package/lib/env.js +21 -21
  51. package/lib/env.js.map +1 -1
  52. package/lib/gitpod-file-parser.d.ts +1 -1
  53. package/lib/gitpod-file-parser.js +27 -42
  54. package/lib/gitpod-file-parser.js.map +1 -1
  55. package/lib/gitpod-file-parser.spec.d.ts +1 -1
  56. package/lib/gitpod-file-parser.spec.js +117 -117
  57. package/lib/gitpod-file-parser.spec.js.map +1 -1
  58. package/lib/gitpod-service.d.ts +186 -34
  59. package/lib/gitpod-service.d.ts.map +1 -1
  60. package/lib/gitpod-service.js +239 -116
  61. package/lib/gitpod-service.js.map +1 -1
  62. package/lib/headless-workspace-log.d.ts +9 -12
  63. package/lib/headless-workspace-log.d.ts.map +1 -1
  64. package/lib/headless-workspace-log.js +5 -7
  65. package/lib/headless-workspace-log.js.map +1 -1
  66. package/lib/ide-frontend-service.d.ts +26 -0
  67. package/lib/ide-frontend-service.d.ts.map +1 -0
  68. package/lib/ide-frontend-service.js +8 -0
  69. package/lib/ide-frontend-service.js.map +1 -0
  70. package/lib/ide-protocol.d.ts +81 -0
  71. package/lib/ide-protocol.d.ts.map +1 -0
  72. package/lib/{util/without.js → ide-protocol.js} +2 -2
  73. package/lib/ide-protocol.js.map +1 -0
  74. package/lib/index.d.ts +5 -1
  75. package/lib/index.d.ts.map +1 -1
  76. package/lib/index.js +25 -12
  77. package/lib/index.js.map +1 -1
  78. package/lib/license-protocol.d.ts +1 -1
  79. package/lib/license-protocol.js +2 -1
  80. package/lib/license-protocol.js.map +1 -1
  81. package/lib/messaging/browser/connection.d.ts +6 -4
  82. package/lib/messaging/browser/connection.d.ts.map +1 -1
  83. package/lib/messaging/browser/connection.js +188 -48
  84. package/lib/messaging/browser/connection.js.map +1 -1
  85. package/lib/messaging/browser/window-connection.d.ts +26 -0
  86. package/lib/messaging/browser/window-connection.d.ts.map +1 -0
  87. package/lib/messaging/browser/window-connection.js +68 -0
  88. package/lib/messaging/browser/window-connection.js.map +1 -0
  89. package/lib/messaging/client-call-metrics.d.ts +35 -0
  90. package/lib/messaging/client-call-metrics.d.ts.map +1 -0
  91. package/lib/messaging/client-call-metrics.js +83 -0
  92. package/lib/messaging/client-call-metrics.js.map +1 -0
  93. package/lib/messaging/connection-error-handler.js +12 -23
  94. package/lib/messaging/connection-error-handler.js.map +1 -1
  95. package/lib/messaging/error.d.ts +6 -2
  96. package/lib/messaging/error.d.ts.map +1 -1
  97. package/lib/messaging/error.js +13 -4
  98. package/lib/messaging/error.js.map +1 -1
  99. package/lib/messaging/handler.d.ts +10 -0
  100. package/lib/messaging/handler.d.ts.map +1 -1
  101. package/lib/messaging/handler.js +1 -0
  102. package/lib/messaging/handler.js.map +1 -1
  103. package/lib/messaging/node/connection.js +23 -22
  104. package/lib/messaging/node/connection.js.map +1 -1
  105. package/lib/messaging/proxy-factory.d.ts +2 -0
  106. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  107. package/lib/messaging/proxy-factory.js +75 -169
  108. package/lib/messaging/proxy-factory.js.map +1 -1
  109. package/lib/payment-protocol.d.ts +18 -0
  110. package/lib/payment-protocol.d.ts.map +1 -0
  111. package/lib/payment-protocol.js +13 -0
  112. package/lib/payment-protocol.js.map +1 -0
  113. package/lib/permission.d.ts +14 -12
  114. package/lib/permission.d.ts.map +1 -1
  115. package/lib/permission.js +21 -19
  116. package/lib/permission.js.map +1 -1
  117. package/lib/plans.d.ts +210 -0
  118. package/lib/plans.d.ts.map +1 -0
  119. package/lib/plans.js +570 -0
  120. package/lib/plans.js.map +1 -0
  121. package/lib/protocol.d.ts +123 -30
  122. package/lib/protocol.d.ts.map +1 -1
  123. package/lib/protocol.js +121 -117
  124. package/lib/protocol.js.map +1 -1
  125. package/lib/snapshot-url.d.ts +14 -0
  126. package/lib/snapshot-url.d.ts.map +1 -0
  127. package/lib/snapshot-url.js +26 -0
  128. package/lib/snapshot-url.js.map +1 -0
  129. package/{src/util/without.ts → lib/snapshot-url.spec.d.ts} +3 -4
  130. package/lib/snapshot-url.spec.d.ts.map +1 -0
  131. package/lib/snapshot-url.spec.js +41 -0
  132. package/lib/snapshot-url.spec.js.map +1 -0
  133. package/lib/team-subscription-protocol.d.ts +73 -0
  134. package/lib/team-subscription-protocol.d.ts.map +1 -0
  135. package/lib/team-subscription-protocol.js +63 -0
  136. package/lib/team-subscription-protocol.js.map +1 -0
  137. package/lib/teams-projects-protocol.d.ts +103 -0
  138. package/lib/teams-projects-protocol.d.ts.map +1 -0
  139. package/lib/teams-projects-protocol.js +23 -0
  140. package/lib/teams-projects-protocol.js.map +1 -0
  141. package/lib/theia-plugins.d.ts +1 -1
  142. package/lib/theia-plugins.js +1 -1
  143. package/lib/typings/globals.d.ts +12 -0
  144. package/lib/typings/globals.d.ts.map +1 -0
  145. package/lib/typings/globals.js +7 -0
  146. package/lib/typings/globals.js.map +1 -0
  147. package/lib/util/analytics.d.ts +8 -0
  148. package/lib/util/analytics.d.ts.map +1 -0
  149. package/lib/util/analytics.js +79 -0
  150. package/lib/util/analytics.js.map +1 -0
  151. package/lib/util/async-iterator.d.ts +1 -1
  152. package/lib/util/async-iterator.js +57 -134
  153. package/lib/util/async-iterator.js.map +1 -1
  154. package/lib/util/cancelable.d.ts +1 -1
  155. package/lib/util/cancelable.js +19 -60
  156. package/lib/util/cancelable.js.map +1 -1
  157. package/lib/util/date-time.d.ts +1 -1
  158. package/lib/util/date-time.js +10 -9
  159. package/lib/util/date-time.js.map +1 -1
  160. package/lib/util/deep-partial.d.ts +1 -1
  161. package/lib/util/deep-partial.js +1 -1
  162. package/lib/util/deferred.d.ts +1 -1
  163. package/lib/util/deferred.js +12 -13
  164. package/lib/util/deferred.js.map +1 -1
  165. package/lib/util/disposable.d.ts +2 -2
  166. package/lib/util/disposable.d.ts.map +1 -1
  167. package/lib/util/disposable.js +27 -39
  168. package/lib/util/disposable.js.map +1 -1
  169. package/lib/util/event.d.ts +1 -1
  170. package/lib/util/event.d.ts.map +1 -1
  171. package/lib/util/event.js +59 -74
  172. package/lib/util/event.js.map +1 -1
  173. package/lib/util/garbage-collected-cache.d.ts +1 -1
  174. package/lib/util/garbage-collected-cache.js +24 -47
  175. package/lib/util/garbage-collected-cache.js.map +1 -1
  176. package/lib/util/generate-workspace-id.d.ts +4 -0
  177. package/lib/util/generate-workspace-id.d.ts.map +1 -0
  178. package/lib/util/generate-workspace-id.js +470 -0
  179. package/lib/util/generate-workspace-id.js.map +1 -0
  180. package/lib/util/generate-workspace-id.spec.d.ts +7 -0
  181. package/lib/util/generate-workspace-id.spec.d.ts.map +1 -0
  182. package/lib/util/generate-workspace-id.spec.js +63 -0
  183. package/lib/util/generate-workspace-id.spec.js.map +1 -0
  184. package/lib/util/gitpod-cookie.d.ts +20 -0
  185. package/lib/util/gitpod-cookie.d.ts.map +1 -0
  186. package/lib/util/gitpod-cookie.js +44 -0
  187. package/lib/util/gitpod-cookie.js.map +1 -0
  188. package/lib/util/gitpod-host-url.d.ts +8 -3
  189. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  190. package/lib/util/gitpod-host-url.js +106 -76
  191. package/lib/util/gitpod-host-url.js.map +1 -1
  192. package/lib/util/gitpod-host-url.spec.d.ts +16 -0
  193. package/lib/util/gitpod-host-url.spec.d.ts.map +1 -0
  194. package/lib/util/gitpod-host-url.spec.js +124 -0
  195. package/lib/util/gitpod-host-url.spec.js.map +1 -0
  196. package/lib/util/grpc.d.ts +15 -0
  197. package/lib/util/grpc.d.ts.map +1 -0
  198. package/lib/util/grpc.js +18 -0
  199. package/lib/util/grpc.js.map +1 -0
  200. package/lib/util/logging.d.ts +57 -34
  201. package/lib/util/logging.d.ts.map +1 -1
  202. package/lib/util/logging.js +119 -110
  203. package/lib/util/logging.js.map +1 -1
  204. package/lib/util/make-link.d.ts +1 -1
  205. package/lib/util/make-link.js +4 -3
  206. package/lib/util/make-link.js.map +1 -1
  207. package/lib/util/parse-workspace-id.d.ts +14 -4
  208. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  209. package/lib/util/parse-workspace-id.js +39 -8
  210. package/lib/util/parse-workspace-id.js.map +1 -1
  211. package/lib/util/parse-workspace-id.spec.d.ts +9 -1
  212. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  213. package/lib/util/parse-workspace-id.spec.js +129 -48
  214. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  215. package/lib/util/queue.d.ts +1 -1
  216. package/lib/util/queue.js +18 -56
  217. package/lib/util/queue.js.map +1 -1
  218. package/lib/util/queue.spec.d.ts +1 -1
  219. package/lib/util/queue.spec.js +145 -287
  220. package/lib/util/queue.spec.js.map +1 -1
  221. package/lib/util/repeater.d.ts +1 -1
  222. package/lib/util/repeater.js +37 -89
  223. package/lib/util/repeater.js.map +1 -1
  224. package/lib/util/safe-promise.d.ts +1 -1
  225. package/lib/util/safe-promise.js +11 -13
  226. package/lib/util/safe-promise.js.map +1 -1
  227. package/lib/util/semaphore.d.ts +1 -1
  228. package/lib/util/semaphore.js +17 -47
  229. package/lib/util/semaphore.js.map +1 -1
  230. package/lib/util/skip-if.d.ts +1 -1
  231. package/lib/util/skip-if.js +8 -7
  232. package/lib/util/skip-if.js.map +1 -1
  233. package/lib/util/timeutil.d.ts +1 -1
  234. package/lib/util/timeutil.d.ts.map +1 -1
  235. package/lib/util/timeutil.js +30 -17
  236. package/lib/util/timeutil.js.map +1 -1
  237. package/lib/util/timeutil.spec.d.ts +1 -1
  238. package/lib/util/timeutil.spec.js +23 -25
  239. package/lib/util/timeutil.spec.js.map +1 -1
  240. package/lib/util/tracing.d.ts +15 -2
  241. package/lib/util/tracing.d.ts.map +1 -1
  242. package/lib/util/tracing.js +86 -51
  243. package/lib/util/tracing.js.map +1 -1
  244. package/lib/util/workspace-port-authentication.d.ts +1 -1
  245. package/lib/util/workspace-port-authentication.d.ts.map +1 -1
  246. package/lib/util/workspace-port-authentication.js +5 -3
  247. package/lib/util/workspace-port-authentication.js.map +1 -1
  248. package/lib/workspace-cluster.d.ts +74 -0
  249. package/lib/workspace-cluster.d.ts.map +1 -0
  250. package/lib/workspace-cluster.js +16 -0
  251. package/lib/workspace-cluster.js.map +1 -0
  252. package/lib/workspace-instance.d.ts +10 -4
  253. package/lib/workspace-instance.d.ts.map +1 -1
  254. package/lib/workspace-instance.js +1 -1
  255. package/lib/wsready.d.ts +1 -1
  256. package/lib/wsready.js +3 -2
  257. package/lib/wsready.js.map +1 -1
  258. package/package.json +32 -16
  259. package/pkg-yarn.lock +18 -9
  260. package/src/accounting-protocol.ts +229 -0
  261. package/src/admin-protocol.ts +41 -6
  262. package/src/analytics.ts +54 -0
  263. package/src/auth.ts +27 -0
  264. package/src/context-url.spec.ts +39 -0
  265. package/src/context-url.ts +51 -0
  266. package/src/email-protocol.ts +3 -4
  267. package/src/encryption/container-module.ts +1 -1
  268. package/src/encryption/encryption-engine.spec.ts +1 -1
  269. package/src/encryption/encryption-engine.ts +1 -1
  270. package/src/encryption/encryption-service.ts +1 -1
  271. package/src/encryption/key-provider.ts +1 -1
  272. package/src/env.ts +11 -11
  273. package/src/gitpod-file-parser.spec.ts +1 -1
  274. package/src/gitpod-file-parser.ts +1 -1
  275. package/src/gitpod-service.ts +386 -52
  276. package/src/headless-workspace-log.ts +8 -12
  277. package/src/ide-frontend-service.ts +28 -0
  278. package/src/ide-protocol.ts +92 -0
  279. package/src/index.ts +6 -2
  280. package/src/license-protocol.ts +1 -1
  281. package/src/messaging/browser/connection.ts +201 -23
  282. package/src/messaging/browser/window-connection.ts +72 -0
  283. package/src/messaging/client-call-metrics.ts +97 -0
  284. package/src/messaging/error.ts +16 -4
  285. package/src/messaging/handler.ts +12 -0
  286. package/src/messaging/node/connection.ts +2 -2
  287. package/src/messaging/proxy-factory.ts +16 -14
  288. package/src/payment-protocol.ts +20 -0
  289. package/src/permission.ts +9 -8
  290. package/src/plans.ts +632 -0
  291. package/src/protocol.ts +204 -61
  292. package/src/snapshot-url.spec.ts +25 -0
  293. package/src/snapshot-url.ts +27 -0
  294. package/src/team-subscription-protocol.ts +113 -0
  295. package/src/teams-projects-protocol.ts +132 -0
  296. package/src/theia-plugins.ts +1 -1
  297. package/src/typings/globals.ts +12 -0
  298. package/src/util/analytics.ts +87 -0
  299. package/src/util/async-iterator.ts +1 -1
  300. package/src/util/cancelable.ts +1 -1
  301. package/src/util/date-time.ts +1 -1
  302. package/src/util/deep-partial.ts +1 -1
  303. package/src/util/deferred.ts +2 -2
  304. package/src/util/garbage-collected-cache.ts +3 -3
  305. package/src/util/generate-workspace-id.spec.ts +31 -0
  306. package/src/util/generate-workspace-id.ts +457 -0
  307. package/src/util/gitpod-cookie.ts +39 -0
  308. package/src/util/gitpod-host-url.spec.ts +49 -0
  309. package/src/util/gitpod-host-url.ts +58 -14
  310. package/src/util/grpc.ts +15 -0
  311. package/src/util/jaeger-client.d.ts +1 -1
  312. package/src/util/logging.ts +111 -39
  313. package/src/util/make-link.ts +1 -1
  314. package/src/util/parse-workspace-id.spec.ts +46 -5
  315. package/src/util/parse-workspace-id.ts +39 -8
  316. package/src/util/queue.spec.ts +2 -2
  317. package/src/util/queue.ts +1 -1
  318. package/src/util/repeater.ts +1 -1
  319. package/src/util/safe-promise.ts +1 -1
  320. package/src/util/semaphore.ts +3 -3
  321. package/src/util/skip-if.ts +2 -2
  322. package/src/util/timeutil.spec.ts +1 -1
  323. package/src/util/timeutil.ts +5 -5
  324. package/src/util/tracing.ts +66 -4
  325. package/src/util/workspace-port-authentication.ts +1 -1
  326. package/src/workspace-cluster.ts +96 -0
  327. package/src/workspace-instance.ts +38 -16
  328. package/src/wsready.ts +2 -2
  329. package/lib/util/without.d.ts +0 -7
  330. package/lib/util/without.d.ts.map +0 -1
  331. package/lib/util/without.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2020 TypeFox GmbH. All rights reserved.
2
+ * Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3
3
  * Licensed under the GNU Affero General Public License (AGPL).
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
@@ -16,72 +16,80 @@ export interface LogContext {
16
16
  userId?: string;
17
17
  workspaceId?: string;
18
18
  };
19
+ export namespace LogContext {
20
+ export function from(params : { userId?: string, user?: any, request?: any } ) {
21
+ return <LogContext>{
22
+ sessionId: params.request?.requestID,
23
+ userId: params.userId || params.user?.id
24
+ }
25
+ }
26
+ }
19
27
 
20
28
  export interface LogPayload {
21
29
  // placeholder to indicate that only dictionary-style objects should be passed as payload
22
30
  };
23
31
 
24
32
  export namespace log {
25
- export function error(context: LogContext, message: string, error: Error, payload: LogPayload): void;
26
- export function error(context: LogContext, message: string, error: Error): void;
33
+ export function error(context: LogContext, message: string, error: any, payload: LogPayload): void;
34
+ export function error(context: LogContext, message: string, error: any): void;
27
35
  export function error(context: LogContext, message: string, payload: LogPayload): void;
28
36
  export function error(context: LogContext, message: string): void;
29
- export function error(context: LogContext, error: Error, payload: LogPayload): void;
30
- export function error(context: LogContext, error: Error): void;
31
- export function error(message: string, error: Error, payload: LogPayload): void;
32
- export function error(message: string, error: Error): void;
37
+ export function error(context: LogContext, error: any, payload: LogPayload): void;
38
+ export function error(context: LogContext, error: any): void;
39
+ export function error(message: string, error: any, payload: LogPayload): void;
40
+ export function error(message: string, error: any): void;
33
41
  export function error(message: string, payload: LogPayload): void;
34
42
  export function error(message: string): void;
35
- export function error(error: Error, payload: LogPayload): void;
36
- export function error(error: Error): void;
43
+ export function error(error: any, payload: LogPayload): void;
44
+ export function error(error: any): void;
37
45
  export function error(...args: any[]): void {
38
46
  errorLog(false, args);
39
47
  }
40
48
 
41
- export function warn(context: LogContext, message: string, error: Error, payload: LogPayload): void;
42
- export function warn(context: LogContext, message: string, error: Error): void;
49
+ export function warn(context: LogContext, message: string, error: any, payload: LogPayload): void;
50
+ export function warn(context: LogContext, message: string, error: any): void;
43
51
  export function warn(context: LogContext, message: string, payload: LogPayload): void;
44
52
  export function warn(context: LogContext, message: string): void;
45
- export function warn(context: LogContext, error: Error, payload: LogPayload): void;
46
- export function warn(context: LogContext, error: Error): void;
47
- export function warn(message: string, error: Error, payload: LogPayload): void;
48
- export function warn(message: string, error: Error): void;
53
+ export function warn(context: LogContext, error: any, payload: LogPayload): void;
54
+ export function warn(context: LogContext, error: any): void;
55
+ export function warn(message: string, error: any, payload: LogPayload): void;
56
+ export function warn(message: string, error: any): void;
49
57
  export function warn(message: string, payload: LogPayload): void;
50
58
  export function warn(message: string): void;
51
- export function warn(error: Error, payload: LogPayload): void;
52
- export function warn(error: Error): void;
59
+ export function warn(error: any, payload: LogPayload): void;
60
+ export function warn(error: any): void;
53
61
  export function warn(...args: any[]): void {
54
62
  warnLog(false, args);
55
63
  }
56
64
 
57
- export function info(context: LogContext, message: string, error: Error, payload: LogPayload): void;
58
- export function info(context: LogContext, message: string, error: Error): void;
65
+ export function info(context: LogContext, message: string, error: any, payload: LogPayload): void;
66
+ export function info(context: LogContext, message: string, error: any): void;
59
67
  export function info(context: LogContext, message: string, payload: LogPayload): void;
60
68
  export function info(context: LogContext, message: string): void;
61
- export function info(context: LogContext, error: Error, payload: LogPayload): void;
62
- export function info(context: LogContext, error: Error): void;
63
- export function info(message: string, error: Error, payload: LogPayload): void;
64
- export function info(message: string, error: Error): void;
69
+ export function info(context: LogContext, error: any, payload: LogPayload): void;
70
+ export function info(context: LogContext, error: any): void;
71
+ export function info(message: string, error: any, payload: LogPayload): void;
72
+ export function info(message: string, error: any): void;
65
73
  export function info(message: string, payload: LogPayload): void;
66
74
  export function info(message: string): void;
67
- export function info(error: Error, payload: LogPayload): void;
68
- export function info(error: Error): void;
75
+ export function info(error: any, payload: LogPayload): void;
76
+ export function info(error: any): void;
69
77
  export function info(...args: any[]): void {
70
78
  infoLog(false, args);
71
79
  }
72
80
 
73
- export function debug(context: LogContext, message: string, error: Error, payload: LogPayload): void;
74
- export function debug(context: LogContext, message: string, error: Error): void;
81
+ export function debug(context: LogContext, message: string, error: any, payload: LogPayload): void;
82
+ export function debug(context: LogContext, message: string, error: any): void;
75
83
  export function debug(context: LogContext, message: string, payload: LogPayload): void;
76
84
  export function debug(context: LogContext, message: string): void;
77
- export function debug(context: LogContext, error: Error, payload: LogPayload): void;
78
- export function debug(context: LogContext, error: Error): void;
79
- export function debug(message: string, error: Error, payload: LogPayload): void;
80
- export function debug(message: string, error: Error): void;
85
+ export function debug(context: LogContext, error: any, payload: LogPayload): void;
86
+ export function debug(context: LogContext, error: any): void;
87
+ export function debug(message: string, error: any, payload: LogPayload): void;
88
+ export function debug(message: string, error: any): void;
81
89
  export function debug(message: string, payload: LogPayload): void;
82
90
  export function debug(message: string): void;
83
- export function debug(error: Error, payload: LogPayload): void;
84
- export function debug(error: Error): void;
91
+ export function debug(error: any, payload: LogPayload): void;
92
+ export function debug(error: any): void;
85
93
  export function debug(...args: any[]): void {
86
94
  debugLog(false, args);
87
95
  }
@@ -89,10 +97,14 @@ export namespace log {
89
97
  /**
90
98
  * Do not use in frontend.
91
99
  */
92
- export function enableJSONLogging(componentArg: string, versionArg: string | undefined): void {
100
+ export function enableJSONLogging(componentArg: string, versionArg: string | undefined, logLevel?: LogrusLogLevel): void {
93
101
  component = componentArg;
94
102
  version = versionArg;
95
103
 
104
+ setLogLevel(logLevel);
105
+ }
106
+
107
+ export function setLogLevel(logLevel: LogrusLogLevel | undefined) {
96
108
  jsonLogging = true;
97
109
 
98
110
  console.error = function (...args: any[]): void {
@@ -107,8 +119,20 @@ export namespace log {
107
119
  console.debug = function (...args: any[]): void {
108
120
  debugLog(true, args);
109
121
  }
122
+
110
123
  console.log = console.info;
111
124
  // FIXME wrap also other console methods (e.g. trace())
125
+
126
+ // set/unset log functions based on loglevel so we only have to evaluate once, not every call
127
+ const noop = () => {};
128
+ const setLog = (logFunc: DoLogFunction, funcLevel: LogrusLogLevel): DoLogFunction => {
129
+ return LogrusLogLevel.isGreatherOrEqual(funcLevel, logLevel) ? logFunc : noop;
130
+ };
131
+
132
+ errorLog = setLog(doErrorLog, "error");
133
+ warnLog = setLog(doWarnLog, "warning");
134
+ infoLog = setLog(doInfoLog, "info");
135
+ debugLog = setLog(doDebugLog, "debug");
112
136
  }
113
137
 
114
138
  export function resetToDefaultLogging(): void {
@@ -120,24 +144,73 @@ export namespace log {
120
144
  console.info = infoConsoleLog;
121
145
  console.debug = debugConsoleLog;
122
146
  }
147
+
148
+ export function setVersion(versionArg: string) {
149
+ version = versionArg;
150
+ }
123
151
  }
124
152
 
125
- function errorLog(calledViaConsole: boolean, args: any[]): void {
153
+ type DoLogFunction = (calledViaConsole: boolean, args: any[]) => void;
154
+
155
+ let errorLog = doErrorLog;
156
+ function doErrorLog(calledViaConsole: boolean, args: any[]): void {
126
157
  doLog(calledViaConsole, errorConsoleLog, 'ERROR', args);
127
158
  }
128
159
 
129
- function warnLog(calledViaConsole: boolean, args: any[]): void {
160
+ let warnLog = doWarnLog;
161
+ function doWarnLog(calledViaConsole: boolean, args: any[]): void {
130
162
  doLog(calledViaConsole, warnConsoleLog, 'WARNING', args);
131
163
  }
132
164
 
133
- function infoLog(calledViaConsole: boolean, args: any[]): void {
165
+ let infoLog = doInfoLog;
166
+ function doInfoLog(calledViaConsole: boolean, args: any[]): void {
134
167
  doLog(calledViaConsole, infoConsoleLog, 'INFO', args);
135
168
  }
136
169
 
137
- function debugLog(calledViaConsole: boolean, args: any[]): void {
170
+ let debugLog = doDebugLog;
171
+ function doDebugLog(calledViaConsole: boolean, args: any[]): void {
138
172
  doLog(calledViaConsole, debugConsoleLog, 'DEBUG', args);
139
173
  }
140
174
 
175
+ // Ref: https://github.com/sirupsen/logrus#level-logging
176
+ export type LogrusLogLevel = keyof (typeof LogrusLogLevels);
177
+ export const LogrusLogLevels = {
178
+ trace: true,
179
+ debug: true,
180
+ info: true,
181
+ warning: true,
182
+ error: true,
183
+ fatal: true,
184
+ panic: true,
185
+ }
186
+ export namespace LogrusLogLevel {
187
+ export function isGreatherOrEqual(lvl: LogrusLogLevel | undefined, ref: LogrusLogLevel | undefined): boolean {
188
+ if (lvl === undefined) {
189
+ return false;
190
+ }
191
+ if (ref === undefined) {
192
+ return true;
193
+ }
194
+ return getLevelArity(lvl) >= getLevelArity(ref);
195
+ }
196
+ function getLevelArity(lvl: LogrusLogLevel): number {
197
+ return Object.keys(LogrusLogLevels)
198
+ .findIndex((l) => l === lvl);
199
+ }
200
+ export function getFromEnv(): LogrusLogLevel | undefined {
201
+ const lvlStr = process.env.LOG_LEVEL;
202
+ if (!lvlStr) {
203
+ return undefined;
204
+ }
205
+ const lvl = lvlStr as LogrusLogLevel;
206
+ const exists = LogrusLogLevels[lvl]
207
+ if (!exists) {
208
+ return undefined;
209
+ }
210
+ return lvl;
211
+ }
212
+ }
213
+
141
214
  // Source: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#LogSeverity
142
215
  type GoogleLogSeverity = 'EMERGENCY' | 'ALERT' | 'CRITICAL' | 'ERROR' | 'WARNING' | 'INFO' | 'DEBUG';
143
216
  namespace GoogleLogSeverity {
@@ -235,7 +308,6 @@ function makeLogItem(severity: GoogleLogSeverity, context: LogContext | undefine
235
308
  severity,
236
309
  time: new Date().toISOString(),
237
310
  environment: process.env.KUBE_STAGE,
238
- region: process.env.GITPOD_REGION,
239
311
  context,
240
312
  message,
241
313
  error,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2020 TypeFox GmbH. All rights reserved.
2
+ * Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3
3
  * Licensed under the GNU Affero General Public License (AGPL).
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
@@ -1,35 +1,76 @@
1
1
  /**
2
- * Copyright (c) 2020 TypeFox GmbH. All rights reserved.
2
+ * Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3
3
  * Licensed under the GNU Affero General Public License (AGPL).
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
7
  import * as chai from 'chai';
8
8
  import { suite, test } from 'mocha-typescript';
9
- import { parseWorkspaceIdFromHostname } from './parse-workspace-id';
9
+ import { matchesInstanceIdOrLegacyWorkspaceIdExactly, matchesNewWorkspaceIdExactly, parseWorkspaceIdFromHostname } from './parse-workspace-id';
10
10
  const expect = chai.expect;
11
11
 
12
12
  @suite
13
13
  export class ParseWorkspaceIdTest {
14
14
 
15
15
  @test public parseWorkspaceIdFromHostname_fromWorkspaceLocation() {
16
+ const actual = parseWorkspaceIdFromHostname("moccasin-ferret-155799b3.ws-eu01.gitpod.io");
17
+ expect(actual).to.equal("moccasin-ferret-155799b3");
18
+ }
19
+
20
+ @test public parseWorkspaceIdFromHostname_fromWorkspacePortLocation() {
21
+ const actual = parseWorkspaceIdFromHostname("3000-moccasin-ferret-155799b3.ws-eu01.gitpod.io");
22
+ expect(actual).to.equal("moccasin-ferret-155799b3");
23
+ }
24
+
25
+ @test public parseWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefix() {
26
+ const actual = parseWorkspaceIdFromHostname("webview-3000-moccasin-ferret-155799b3.ws-eu01.gitpod.io");
27
+ expect(actual).to.equal("moccasin-ferret-155799b3");
28
+ }
29
+
30
+ @test public parseWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefixCustomHost() {
31
+ const actual = parseWorkspaceIdFromHostname("webview-3000-moccasin-ferret-155799b3.ws-eu01.some.subdomain.somehost.com");
32
+ expect(actual).to.equal("moccasin-ferret-155799b3");
33
+ }
34
+
35
+ // legacy mode
36
+ @test public parseLegacyWorkspaceIdFromHostname_fromWorkspaceLocation() {
16
37
  const actual = parseWorkspaceIdFromHostname("b7e0eaf8-ec73-44ec-81ea-04859263b656.ws-eu01.gitpod.io");
17
38
  expect(actual).to.equal("b7e0eaf8-ec73-44ec-81ea-04859263b656");
18
39
  }
19
40
 
20
- @test public parseWorkspaceIdFromHostname_fromWorkspacePortLocation() {
41
+ @test public parseLegacyWorkspaceIdFromHostname_fromWorkspacePortLocation() {
21
42
  const actual = parseWorkspaceIdFromHostname("3000-b7e0eaf8-ec73-44ec-81ea-04859263b656.ws-eu01.gitpod.io");
22
43
  expect(actual).to.equal("b7e0eaf8-ec73-44ec-81ea-04859263b656");
23
44
  }
24
45
 
25
- @test public parseWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefix() {
46
+ @test public parseLegacyWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefix() {
26
47
  const actual = parseWorkspaceIdFromHostname("webview-3000-b7e0eaf8-ec73-44ec-81ea-04859263b656.ws-eu01.gitpod.io");
27
48
  expect(actual).to.equal("b7e0eaf8-ec73-44ec-81ea-04859263b656");
28
49
  }
29
50
 
30
- @test public parseWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefixCustomHost() {
51
+ @test public parseLegacyWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefixCustomHost() {
31
52
  const actual = parseWorkspaceIdFromHostname("webview-3000-ca81a50f-09d7-465c-acd9-264a747d5351.ws-eu01.some.subdomain.somehost.com");
32
53
  expect(actual).to.equal("ca81a50f-09d7-465c-acd9-264a747d5351");
33
54
  }
55
+
56
+ // match - instance ID
57
+ @test public matchesInstanceIdOrLegacyWorkspaceIdExactly_positive() {
58
+ const actual = matchesInstanceIdOrLegacyWorkspaceIdExactly("b7e0eaf8-ec73-44ec-81ea-04859263b656");
59
+ expect(actual).to.be.true;
60
+ }
61
+ @test public matchesInstanceIdOrLegacyWorkspaceIdExactly_negative() {
62
+ const actual = matchesInstanceIdOrLegacyWorkspaceIdExactly("b7e0eaf8-ec73-44ec-81a-04859263b656");
63
+ expect(actual).to.be.false;
64
+ }
65
+
66
+ // match - new workspace ID
67
+ @test public matchesWorkspaceIdExactly_new_positive() {
68
+ const actual = matchesNewWorkspaceIdExactly("moccasin-ferret-155799b3");
69
+ expect(actual).to.be.true;
70
+ }
71
+ @test public matchesWorkspaceIdExactly_new_negative() {
72
+ const actual = matchesNewWorkspaceIdExactly("moccasin-ferret-15599b3");
73
+ expect(actual).to.be.false;
74
+ }
34
75
  }
35
76
  module.exports = new ParseWorkspaceIdTest()
@@ -1,24 +1,55 @@
1
1
  /**
2
- * Copyright (c) 2020 TypeFox GmbH. All rights reserved.
2
+ * Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3
3
  * Licensed under the GNU Affero General Public License (AGPL).
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}/;
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:
10
- * - b7e0eaf8-ec73-44ec-81ea-04859263b656.ws-eu01.gitpod.io
11
- * - 1234-b7e0eaf8-ec73-44ec-81ea-04859263b656.ws-eu01.gitpod.io
12
- * - webview-1234-b7e0eaf8-ec73-44ec-81ea-04859263b656.ws-eu01.gitpod.io (or any other string replacing webview)
18
+ * - moccasin-ferret-155799b3.ws-eu01.gitpod.io
19
+ * - 1234-moccasin-ferret-155799b3.ws-eu01.gitpod.io
20
+ * - webview-1234-moccasin-ferret-155799b3.ws-eu01.gitpod.io (or any other string replacing webview)
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 = /([a-z][0-9a-z]+\-([0-9a-z]+\-){3}[0-9a-z]+)\.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 {
28
+ const legacyMatch = REGEX_WORKSPACE_ID_LEGACY_FROM_HOSTNAME.exec(hostname);
29
+ if (legacyMatch && legacyMatch.length >= 2) {
30
+ return legacyMatch[1];
31
+ }
22
32
  return undefined;
23
33
  }
24
- }
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
+ };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2020 TypeFox GmbH. All rights reserved.
2
+ * Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3
3
  * Licensed under the GNU Affero General Public License (AGPL).
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
@@ -32,7 +32,7 @@ const expect = chai.expect
32
32
  return new Promise((resolve) => {
33
33
  setTimeout(() => {
34
34
  this.seq.push(seqNr);
35
- resolve();
35
+ resolve(undefined);
36
36
  }, sleep);
37
37
  });
38
38
  else
package/src/util/queue.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2020 TypeFox GmbH. All rights reserved.
2
+ * Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3
3
  * Licensed under the GNU Affero General Public License (AGPL).
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2020 TypeFox GmbH. All rights reserved.
2
+ * Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3
3
  * Licensed under the GNU Affero General Public License (AGPL).
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2020 TypeFox GmbH. All rights reserved.
2
+ * Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3
3
  * Licensed under the GNU Affero General Public License (AGPL).
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2020 TypeFox GmbH. All rights reserved.
2
+ * Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3
3
  * Licensed under the GNU Affero General Public License (AGPL).
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
@@ -9,7 +9,7 @@ export class Semaphore {
9
9
  protected queue: (() => void)[] = [];
10
10
  protected used: number;
11
11
 
12
- constructor(protected readonly capacity: number) {
12
+ constructor(protected readonly capacity: number) {
13
13
  if(capacity < 1) {
14
14
  throw new Error("Capacity cannot be less than 1");
15
15
  }
@@ -17,7 +17,7 @@ export class Semaphore {
17
17
 
18
18
  public release() {
19
19
  if(this.used == 0) return;
20
-
20
+
21
21
  const queued = this.queue.shift();
22
22
  if (queued) {
23
23
  queued();
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2020 TypeFox GmbH. All rights reserved.
2
+ * Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3
3
  * Licensed under the GNU Affero General Public License (AGPL).
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
@@ -27,7 +27,7 @@ export function skipIf(doSkip: (suite: TestSuiteContext) => boolean): MochaTypeS
27
27
  }
28
28
  })
29
29
  };
30
-
30
+
31
31
  // Mark as "trait": mimics the behavior of https://github.com/testdeck/testdeck/blob/9d2dd6a458c2c86c945f6f2999b8278b7528a7a7/index.ts#L433
32
32
  (trait as any)["__mts_isTrait"] = true;
33
33
  return trait;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2020 TypeFox GmbH. All rights reserved.
2
+ * Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3
3
  * Licensed under the GNU Affero General Public License (AGPL).
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
@@ -1,17 +1,17 @@
1
1
  /**
2
- * Copyright (c) 2020 TypeFox GmbH. All rights reserved.
2
+ * Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3
3
  * Licensed under the GNU Affero General Public License (AGPL).
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
7
  /**
8
8
  * Returns the <code>day</code>th of the next month from <code>formDate</code>.
9
- * If the next month does not have a <code>day</code>th, the last day of that
9
+ * If the next month does not have a <code>day</code>th, the last day of that
10
10
  * month is taken.
11
11
  * The time is copied from <code>fromDate</code>.
12
- *
13
- * @param fromDate
14
- * @param day
12
+ *
13
+ * @param fromDate
14
+ * @param day
15
15
  */
16
16
  export function oneMonthLater(fromDate: string, day?: number): string {
17
17
  const later = new Date(fromDate);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2020 TypeFox GmbH. All rights reserved.
2
+ * Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3
3
  * Licensed under the GNU Affero General Public License (AGPL).
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
@@ -9,19 +9,29 @@ import * as opentracing from 'opentracing';
9
9
  import { TracingConfig, initTracerFromEnv, Sampler, SamplingDecision } from 'jaeger-client';
10
10
  import { initGlobalTracer } from 'opentracing';
11
11
  import { injectable } from 'inversify';
12
+ import { ResponseError } from 'vscode-jsonrpc';
12
13
 
13
14
  export interface TraceContext {
14
15
  span?: opentracing.Span
15
16
  }
17
+ export type TraceContextWithSpan = TraceContext & {
18
+ span: opentracing.Span
19
+ }
20
+
16
21
 
17
22
  export namespace TraceContext {
18
- export function startSpan(operation: string, ctx: TraceContext): opentracing.Span {
23
+ export function startSpan(operation: string, parentCtx: TraceContext): opentracing.Span {
19
24
  const options: opentracing.SpanOptions = {
20
- childOf: ctx.span
25
+ childOf: parentCtx.span
21
26
  }
22
27
  return opentracing.globalTracer().startSpan(operation, options);
23
28
  }
24
29
 
30
+ export function childContextWithSpan(operation: string, parentCtx: TraceContext): TraceContextWithSpan {
31
+ const span = startSpan(operation, parentCtx);
32
+ return { span };
33
+ }
34
+
25
35
  export function startAsyncSpan(operation: string, ctx: TraceContext): opentracing.Span {
26
36
  const options: opentracing.SpanOptions = {};
27
37
  if (!!ctx.span) {
@@ -39,7 +49,42 @@ export namespace TraceContext {
39
49
  "error": err.message,
40
50
  "stacktrace": err.stack
41
51
  })
42
- ctx.span.setTag("error", true)
52
+ ctx.span.setTag("error", true);
53
+ }
54
+
55
+ export function logJsonRPCError(ctx: TraceContext, method: string, err: ResponseError<any>) {
56
+ if (!ctx.span) {
57
+ return;
58
+ }
59
+ logError(ctx, err);
60
+
61
+ // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/rpc.md#json-rpc
62
+ ctx.span.addTags({
63
+ rpc: {
64
+ system: "jsonrpc",
65
+ method,
66
+ jsonrpc: {
67
+ error_code: err.code,
68
+ error_message: err.message,
69
+ },
70
+ },
71
+ });
72
+ }
73
+
74
+ export function addJsonRPCParameters(ctx: TraceContext, method: string, args: any[]) {
75
+ if (!ctx.span) {
76
+ return;
77
+ }
78
+
79
+ ctx.span.addTags({
80
+ rpc: {
81
+ system: "jsonrpc",
82
+ method,
83
+ jsonrpc: {
84
+ parameters: args.slice(),
85
+ },
86
+ },
87
+ });
43
88
  }
44
89
  }
45
90
 
@@ -132,3 +177,20 @@ export class PerOperationSampler implements Sampler {
132
177
  }
133
178
  }
134
179
  }
180
+
181
+ // Augment interfaces with an leading parameter "TraceContext" on every method
182
+ type IsValidArg<T> = T extends object ? keyof T extends never ? false : true : true;
183
+ type AddTraceContext<T> =
184
+ T extends (a: infer A, b: infer B, c: infer C, d: infer D, e: infer E, f: infer F) => infer R ? (
185
+ IsValidArg<F> extends true ? (ctx: TraceContextWithSpan, a: A, b: B, c: C, d: D, e: E, f: F) => R :
186
+ IsValidArg<E> extends true ? (ctx: TraceContextWithSpan, a: A, b: B, c: C, d: D, e: E) => R :
187
+ IsValidArg<D> extends true ? (ctx: TraceContextWithSpan, a: A, b: B, c: C, d: D) => R :
188
+ IsValidArg<C> extends true ? (ctx: TraceContextWithSpan, a: A, b: B, c: C) => R :
189
+ IsValidArg<B> extends true ? (ctx: TraceContextWithSpan, a: A, b: B) => R :
190
+ IsValidArg<A> extends true ? (ctx: TraceContextWithSpan, a: A) => R :
191
+ (ctx: TraceContextWithSpan) => Promise<R>
192
+ ) : never;
193
+
194
+ export type InterfaceWithTraceContext<T> = {
195
+ [P in keyof T]: AddTraceContext<T[P]>
196
+ };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2020 TypeFox GmbH. All rights reserved.
2
+ * Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3
3
  * Licensed under the GNU Affero General Public License (AGPL).
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */