@gitpod/gitpod-protocol 0.1.5-sje-installer-namespace-docs.1 → 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 (36) hide show
  1. package/data/gitpod-schema.json +17 -2
  2. package/lib/gitpod-service.d.ts +4 -3
  3. package/lib/gitpod-service.d.ts.map +1 -1
  4. package/lib/gitpod-service.js.map +1 -1
  5. package/lib/protocol.d.ts +4 -33
  6. package/lib/protocol.d.ts.map +1 -1
  7. package/lib/protocol.js.map +1 -1
  8. package/lib/teams-projects-protocol.d.ts +6 -0
  9. package/lib/teams-projects-protocol.d.ts.map +1 -1
  10. package/lib/util/generate-workspace-id.d.ts +1 -1
  11. package/lib/util/generate-workspace-id.d.ts.map +1 -1
  12. package/lib/util/generate-workspace-id.js +18 -2
  13. package/lib/util/generate-workspace-id.js.map +1 -1
  14. package/lib/util/generate-workspace-id.spec.js +23 -0
  15. package/lib/util/generate-workspace-id.spec.js.map +1 -1
  16. package/lib/util/gitpod-host-url.d.ts +0 -1
  17. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  18. package/lib/util/gitpod-host-url.js +3 -6
  19. package/lib/util/gitpod-host-url.js.map +1 -1
  20. package/lib/util/parse-workspace-id.js +1 -1
  21. package/lib/util/parse-workspace-id.js.map +1 -1
  22. package/lib/util/tracing.d.ts +3 -2
  23. package/lib/util/tracing.d.ts.map +1 -1
  24. package/lib/util/tracing.js +32 -7
  25. package/lib/util/tracing.js.map +1 -1
  26. package/package.json +3 -2
  27. package/pkg-yarn.lock +1 -1
  28. package/provenance-bundle.jsonl +2 -0
  29. package/src/gitpod-service.ts +2 -3
  30. package/src/protocol.ts +6 -34
  31. package/src/teams-projects-protocol.ts +7 -0
  32. package/src/util/generate-workspace-id.spec.ts +16 -0
  33. package/src/util/generate-workspace-id.ts +19 -2
  34. package/src/util/gitpod-host-url.ts +3 -7
  35. package/src/util/parse-workspace-id.ts +1 -1
  36. package/src/util/tracing.ts +34 -8
@@ -4,7 +4,7 @@
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}/;
7
+ const REGEX_WORKSPACE_ID = /[0-9a-z]{2,16}-[0-9a-z]{2,16}-[0-9a-z]{8,11}/;
8
8
  const REGEX_WORKSPACE_ID_EXACT = new RegExp(`^${REGEX_WORKSPACE_ID.source}$`);
9
9
  // We need to parse the workspace id precisely here to get the case '<some-str>-<port>-<wsid>.ws.' right
10
10
  const REGEX_WORKSPACE_ID_FROM_HOSTNAME = new RegExp(`(${REGEX_WORKSPACE_ID.source})\.ws`);
@@ -8,7 +8,7 @@
8
8
  import * as opentracing from 'opentracing';
9
9
  import { TracingConfig, initTracerFromEnv } from 'jaeger-client';
10
10
  import { Sampler, SamplingDecision } from './jaeger-client-types';
11
- import { initGlobalTracer } from 'opentracing';
11
+ import { followsFrom, initGlobalTracer } from 'opentracing';
12
12
  import { injectable } from 'inversify';
13
13
  import { ResponseError } from 'vscode-jsonrpc';
14
14
  import { log, LogContext } from './logging';
@@ -22,13 +22,16 @@ export type TraceContextWithSpan = TraceContext & {
22
22
 
23
23
 
24
24
  export namespace TraceContext {
25
- export function startSpan(operation: string, parentCtx?: TraceContext): opentracing.Span {
26
- let options: opentracing.SpanOptions | undefined = undefined;
25
+ export function startSpan(operation: string, parentCtx?: TraceContext, ...referencedSpans: (opentracing.Span | undefined)[]): opentracing.Span {
26
+ const options: opentracing.SpanOptions = {};
27
27
  if (parentCtx) {
28
- options = {
29
- childOf: parentCtx.span
30
- };
28
+ options.childOf = parentCtx.span;
31
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()));
33
+ }
34
+
32
35
  return opentracing.globalTracer().startSpan(operation, options);
33
36
  }
34
37
 
@@ -37,6 +40,24 @@ export namespace TraceContext {
37
40
  return { span };
38
41
  }
39
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;
48
+ }
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
+
40
61
  export function setError(ctx: TraceContext, err: Error) {
41
62
  if (!ctx.span) {
42
63
  return;
@@ -68,13 +89,13 @@ export namespace TraceContext {
68
89
  addNestedTags(ctx, tags);
69
90
  }
70
91
 
71
- export function setJsonRPCError(ctx: TraceContext, method: string, err: ResponseError<any>) {
92
+ export function setJsonRPCError(ctx: TraceContext, method: string, err: ResponseError<any>, withStatusCode: boolean = false) {
72
93
  if (!ctx.span) {
73
94
  return;
74
95
  }
75
96
  // not use setError bc this is (most likely) a working operation
76
97
 
77
- setJsonRPCMetadata(ctx);
98
+ setJsonRPCMetadata(ctx, method);
78
99
  // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/rpc.md#json-rpc
79
100
  addNestedTags(ctx, {
80
101
  rpc: {
@@ -84,6 +105,11 @@ export namespace TraceContext {
84
105
  },
85
106
  },
86
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
+ }
87
113
  }
88
114
 
89
115
  export function addJsonRPCParameters(ctx: TraceContext, params: { [key: string]: any }) {