@gitpod/gitpod-protocol 0.1.5-wth-update-mysql-dependencies-2.31 → 0.1.5-wth-test.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/gitpod-schema.json +25 -24
- package/lib/accounting-protocol.d.ts +3 -6
- package/lib/accounting-protocol.d.ts.map +1 -1
- package/lib/accounting-protocol.js +10 -16
- package/lib/accounting-protocol.js.map +1 -1
- package/lib/admin-protocol.d.ts +26 -4
- package/lib/admin-protocol.d.ts.map +1 -1
- package/lib/admin-protocol.js +15 -0
- package/lib/admin-protocol.js.map +1 -1
- package/lib/analytics.d.ts +44 -0
- package/lib/analytics.d.ts.map +1 -0
- package/lib/analytics.js +10 -0
- package/lib/analytics.js.map +1 -0
- package/lib/context-url.d.ts +31 -0
- package/lib/context-url.d.ts.map +1 -0
- package/lib/context-url.js +102 -0
- package/lib/context-url.js.map +1 -0
- package/lib/context-url.spec.d.ts +14 -0
- package/lib/context-url.spec.d.ts.map +1 -0
- package/lib/context-url.spec.js +94 -0
- package/lib/context-url.spec.js.map +1 -0
- package/lib/email-protocol.d.ts +1 -2
- package/lib/email-protocol.d.ts.map +1 -1
- package/lib/email-protocol.js +4 -4
- package/lib/email-protocol.js.map +1 -1
- package/lib/encryption/container-module.js +5 -4
- package/lib/encryption/container-module.js.map +1 -1
- package/lib/encryption/encryption-engine.js +19 -20
- package/lib/encryption/encryption-engine.js.map +1 -1
- package/lib/encryption/encryption-engine.spec.js +29 -36
- package/lib/encryption/encryption-engine.spec.js.map +1 -1
- package/lib/encryption/encryption-service.js +29 -43
- package/lib/encryption/encryption-service.js.map +1 -1
- package/lib/encryption/key-provider.js +25 -30
- package/lib/encryption/key-provider.js.map +1 -1
- package/lib/env.d.ts +1 -2
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +20 -21
- package/lib/env.js.map +1 -1
- package/lib/gitpod-file-parser.js +25 -41
- package/lib/gitpod-file-parser.js.map +1 -1
- package/lib/gitpod-file-parser.spec.js +116 -116
- package/lib/gitpod-file-parser.spec.js.map +1 -1
- package/lib/gitpod-service.d.ts +124 -22
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +169 -278
- package/lib/gitpod-service.js.map +1 -1
- package/lib/headless-workspace-log.d.ts +8 -11
- package/lib/headless-workspace-log.d.ts.map +1 -1
- package/lib/headless-workspace-log.js +4 -7
- package/lib/headless-workspace-log.js.map +1 -1
- package/lib/ide-protocol.d.ts +105 -0
- package/lib/ide-protocol.d.ts.map +1 -0
- package/lib/ide-protocol.js +8 -0
- package/lib/ide-protocol.js.map +1 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -1
- package/lib/index.js.map +1 -1
- package/lib/installation-admin-protocol.d.ts +27 -0
- package/lib/installation-admin-protocol.d.ts.map +1 -0
- package/lib/installation-admin-protocol.js +30 -0
- package/lib/installation-admin-protocol.js.map +1 -0
- package/lib/messaging/browser/connection.d.ts +5 -3
- package/lib/messaging/browser/connection.d.ts.map +1 -1
- package/lib/messaging/browser/connection.js +183 -33
- package/lib/messaging/browser/connection.js.map +1 -1
- package/lib/messaging/browser/window-connection.js +35 -55
- package/lib/messaging/browser/window-connection.js.map +1 -1
- package/lib/messaging/client-call-metrics.d.ts +35 -0
- package/lib/messaging/client-call-metrics.d.ts.map +1 -0
- package/lib/messaging/client-call-metrics.js +83 -0
- package/lib/messaging/client-call-metrics.js.map +1 -0
- package/lib/messaging/error.d.ts +3 -1
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js +6 -2
- package/lib/messaging/error.js.map +1 -1
- package/lib/messaging/handler.d.ts +10 -0
- package/lib/messaging/handler.d.ts.map +1 -1
- package/lib/messaging/node/connection.d.ts +1 -17
- package/lib/messaging/node/connection.d.ts.map +1 -1
- package/lib/messaging/node/connection.js +23 -59
- package/lib/messaging/node/connection.js.map +1 -1
- package/lib/messaging/proxy-factory.d.ts +2 -0
- package/lib/messaging/proxy-factory.d.ts.map +1 -1
- package/lib/messaging/proxy-factory.js +74 -159
- package/lib/messaging/proxy-factory.js.map +1 -1
- package/lib/oss-allowlist.d.ts +14 -0
- package/lib/oss-allowlist.d.ts.map +1 -0
- package/lib/oss-allowlist.js +8 -0
- package/lib/oss-allowlist.js.map +1 -0
- package/lib/permission.d.ts +8 -1
- package/lib/permission.d.ts.map +1 -1
- package/lib/permission.js +36 -15
- package/lib/permission.js.map +1 -1
- package/lib/plans.d.ts +210 -0
- package/lib/plans.d.ts.map +1 -0
- package/lib/plans.js +570 -0
- package/lib/plans.js.map +1 -0
- package/lib/protocol.d.ts +121 -54
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +117 -131
- package/lib/protocol.js.map +1 -1
- package/lib/snapshot-url.d.ts +14 -0
- package/lib/snapshot-url.d.ts.map +1 -0
- package/lib/snapshot-url.js +26 -0
- package/lib/snapshot-url.js.map +1 -0
- package/{src/util/without.ts → lib/snapshot-url.spec.d.ts} +2 -3
- package/lib/snapshot-url.spec.d.ts.map +1 -0
- package/lib/snapshot-url.spec.js +41 -0
- package/lib/snapshot-url.spec.js.map +1 -0
- package/lib/team-subscription-protocol.d.ts +4 -4
- package/lib/team-subscription-protocol.d.ts.map +1 -1
- package/lib/team-subscription-protocol.js +15 -12
- package/lib/team-subscription-protocol.js.map +1 -1
- package/lib/teams-projects-protocol.d.ts +113 -0
- package/lib/teams-projects-protocol.d.ts.map +1 -0
- package/lib/teams-projects-protocol.js +30 -0
- package/lib/teams-projects-protocol.js.map +1 -0
- package/lib/util/analytics.d.ts +8 -0
- package/lib/util/analytics.d.ts.map +1 -0
- package/lib/util/analytics.js +88 -0
- package/lib/util/analytics.js.map +1 -0
- package/lib/util/async-iterator.js +55 -133
- package/lib/util/async-iterator.js.map +1 -1
- package/lib/util/cancelable.js +17 -59
- package/lib/util/cancelable.js.map +1 -1
- package/lib/util/date-time.js +8 -8
- package/lib/util/date-time.js.map +1 -1
- package/lib/util/deferred.js +10 -12
- package/lib/util/deferred.js.map +1 -1
- package/lib/util/disposable.js +26 -39
- package/lib/util/disposable.js.map +1 -1
- package/lib/util/event.js +58 -74
- package/lib/util/event.js.map +1 -1
- package/lib/util/garbage-collected-cache.d.ts +1 -0
- package/lib/util/garbage-collected-cache.d.ts.map +1 -1
- package/lib/util/garbage-collected-cache.js +26 -46
- package/lib/util/garbage-collected-cache.js.map +1 -1
- package/lib/util/generate-workspace-id.d.ts +1 -1
- package/lib/util/generate-workspace-id.d.ts.map +1 -1
- package/lib/util/generate-workspace-id.js +31 -68
- package/lib/util/generate-workspace-id.js.map +1 -1
- package/lib/util/generate-workspace-id.spec.js +57 -78
- package/lib/util/generate-workspace-id.spec.js.map +1 -1
- package/lib/util/gitpod-cookie.d.ts +20 -0
- package/lib/util/gitpod-cookie.d.ts.map +1 -0
- package/lib/util/gitpod-cookie.js +44 -0
- package/lib/util/gitpod-cookie.js.map +1 -0
- package/lib/util/gitpod-host-url.d.ts +1 -2
- package/lib/util/gitpod-host-url.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.js +95 -98
- package/lib/util/gitpod-host-url.js.map +1 -1
- package/lib/util/gitpod-host-url.spec.d.ts +7 -1
- package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.spec.js +103 -31
- package/lib/util/gitpod-host-url.spec.js.map +1 -1
- package/lib/util/grpc.d.ts +15 -0
- package/lib/util/grpc.d.ts.map +1 -0
- package/lib/util/grpc.js +18 -0
- package/lib/util/grpc.js.map +1 -0
- package/lib/util/jaeger-client-types.d.ts +68 -0
- package/lib/util/jaeger-client-types.d.ts.map +1 -0
- package/lib/util/{without.js → jaeger-client-types.js} +1 -1
- package/lib/util/jaeger-client-types.js.map +1 -0
- package/lib/util/logging.d.ts +49 -33
- package/lib/util/logging.d.ts.map +1 -1
- package/lib/util/logging.js +107 -110
- package/lib/util/logging.js.map +1 -1
- package/lib/util/make-link.js +2 -2
- package/lib/util/make-link.js.map +1 -1
- package/lib/util/parse-workspace-id.d.ts +10 -0
- package/lib/util/parse-workspace-id.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.js +32 -7
- package/lib/util/parse-workspace-id.js.map +1 -1
- package/lib/util/parse-workspace-id.spec.d.ts +4 -0
- package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.spec.js +123 -84
- package/lib/util/parse-workspace-id.spec.js.map +1 -1
- package/lib/util/queue.js +16 -55
- package/lib/util/queue.js.map +1 -1
- package/lib/util/queue.spec.js +144 -288
- package/lib/util/queue.spec.js.map +1 -1
- package/lib/util/repeat.d.ts +15 -0
- package/lib/util/repeat.d.ts.map +1 -0
- package/lib/util/repeat.js +55 -0
- package/lib/util/repeat.js.map +1 -0
- package/lib/util/semaphore.js +15 -46
- package/lib/util/semaphore.js.map +1 -1
- package/lib/util/skip-if.js +6 -6
- package/lib/util/skip-if.js.map +1 -1
- package/lib/util/timeutil.js +28 -16
- package/lib/util/timeutil.js.map +1 -1
- package/lib/util/timeutil.spec.js +21 -24
- package/lib/util/timeutil.spec.js.map +1 -1
- package/lib/util/tracing.d.ts +51 -5
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +197 -62
- package/lib/util/tracing.js.map +1 -1
- package/lib/util/tracing.spec.d.ts +7 -0
- package/lib/util/tracing.spec.d.ts.map +1 -0
- package/lib/util/tracing.spec.js +121 -0
- package/lib/util/tracing.spec.js.map +1 -0
- package/lib/util/workspace-port-authentication.js +3 -2
- package/lib/util/workspace-port-authentication.js.map +1 -1
- package/lib/workspace-cluster.d.ts +76 -0
- package/lib/workspace-cluster.d.ts.map +1 -0
- package/lib/workspace-cluster.js +33 -0
- package/lib/workspace-cluster.js.map +1 -0
- package/lib/workspace-instance.d.ts +24 -2
- package/lib/workspace-instance.d.ts.map +1 -1
- package/lib/wsready.d.ts +1 -1
- package/lib/wsready.js +2 -2
- package/package.json +31 -17
- package/pkg-yarn.lock +17 -9
- package/provenance-bundle.jsonl +2 -0
- package/src/accounting-protocol.ts +4 -10
- package/src/admin-protocol.ts +47 -5
- package/src/analytics.ts +52 -0
- package/src/context-url.spec.ts +53 -0
- package/src/context-url.ts +107 -0
- package/src/email-protocol.ts +2 -3
- package/src/env.ts +10 -10
- package/src/gitpod-service.ts +181 -44
- package/src/headless-workspace-log.ts +7 -11
- package/src/ide-frontend-service.ts +1 -1
- package/src/ide-protocol.ts +119 -0
- package/src/index.ts +7 -1
- package/src/installation-admin-protocol.ts +42 -0
- package/src/messaging/browser/connection.ts +195 -14
- package/src/messaging/client-call-metrics.ts +97 -0
- package/src/messaging/error.ts +8 -2
- package/src/messaging/handler.ts +12 -0
- package/src/messaging/node/connection.ts +21 -68
- package/src/messaging/proxy-factory.ts +14 -6
- package/src/oss-allowlist.ts +15 -0
- package/src/permission.ts +24 -4
- package/src/plans.ts +632 -0
- package/src/protocol.ts +196 -85
- package/src/snapshot-url.spec.ts +25 -0
- package/src/snapshot-url.ts +27 -0
- package/src/team-subscription-protocol.ts +7 -5
- package/src/teams-projects-protocol.ts +147 -0
- package/src/util/analytics.ts +105 -0
- package/src/util/deferred.ts +1 -1
- package/src/util/garbage-collected-cache.ts +9 -3
- package/src/util/generate-workspace-id.spec.ts +20 -3
- package/src/util/generate-workspace-id.ts +22 -2
- package/src/util/gitpod-cookie.ts +39 -0
- package/src/util/gitpod-host-url.spec.ts +25 -1
- package/src/util/gitpod-host-url.ts +22 -13
- package/src/util/grpc.ts +15 -0
- package/src/util/jaeger-client-types.ts +102 -0
- package/src/util/logging.ts +102 -38
- package/src/util/parse-workspace-id.spec.ts +21 -1
- package/src/util/parse-workspace-id.ts +32 -6
- package/src/util/queue.spec.ts +1 -1
- package/src/util/repeat.ts +45 -0
- package/src/util/semaphore.ts +2 -2
- package/src/util/skip-if.ts +1 -1
- package/src/util/timeutil.ts +4 -4
- package/src/util/tracing.spec.ts +83 -0
- package/src/util/tracing.ts +183 -17
- package/src/workspace-cluster.ts +104 -0
- package/src/workspace-instance.ts +45 -13
- package/src/wsready.ts +2 -2
- package/lib/messaging/connection-error-handler.d.ts +0 -27
- package/lib/messaging/connection-error-handler.d.ts.map +0 -1
- package/lib/messaging/connection-error-handler.js +0 -46
- package/lib/messaging/connection-error-handler.js.map +0 -1
- package/lib/util/context-url.d.ts +0 -13
- package/lib/util/context-url.d.ts.map +0 -1
- package/lib/util/context-url.js +0 -26
- package/lib/util/context-url.js.map +0 -1
- package/lib/util/context-url.spec.d.ts +0 -10
- package/lib/util/context-url.spec.d.ts.map +0 -1
- package/lib/util/context-url.spec.js +0 -52
- package/lib/util/context-url.spec.js.map +0 -1
- package/lib/util/repeater.d.ts +0 -22
- package/lib/util/repeater.d.ts.map +0 -1
- package/lib/util/repeater.js +0 -118
- package/lib/util/repeater.js.map +0 -1
- package/lib/util/safe-promise.d.ts +0 -11
- package/lib/util/safe-promise.d.ts.map +0 -1
- package/lib/util/safe-promise.js +0 -34
- package/lib/util/safe-promise.js.map +0 -1
- package/lib/util/without.d.ts +0 -7
- package/lib/util/without.d.ts.map +0 -1
- package/lib/util/without.js.map +0 -1
- package/src/messaging/connection-error-handler.ts +0 -62
- package/src/util/context-url.spec.ts +0 -25
- package/src/util/context-url.ts +0 -23
- package/src/util/jaeger-client.d.ts +0 -105
- package/src/util/repeater.ts +0 -49
- package/src/util/safe-promise.ts +0 -26
|
@@ -0,0 +1,147 @@
|
|
|
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 { PrebuiltWorkspaceState } from "./protocol";
|
|
8
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
9
|
+
import { DeepPartial } from "./util/deep-partial";
|
|
10
|
+
|
|
11
|
+
export interface ProjectConfig {
|
|
12
|
+
'.gitpod.yml': string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ProjectSettings {
|
|
16
|
+
useIncrementalPrebuilds?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface Project {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
slug?: string;
|
|
23
|
+
cloneUrl: string;
|
|
24
|
+
teamId?: string;
|
|
25
|
+
userId?: string;
|
|
26
|
+
appInstallationId: string;
|
|
27
|
+
config?: ProjectConfig;
|
|
28
|
+
settings?: ProjectSettings;
|
|
29
|
+
creationTime: string;
|
|
30
|
+
/** This is a flag that triggers the HARD DELETION of this entity */
|
|
31
|
+
deleted?: boolean;
|
|
32
|
+
markedDeleted?: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export namespace Project {
|
|
36
|
+
export const create = (project: Omit<Project, 'id' | 'creationTime'>): Project => {
|
|
37
|
+
return {
|
|
38
|
+
...project,
|
|
39
|
+
id: uuidv4(),
|
|
40
|
+
creationTime: new Date().toISOString()
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface Overview {
|
|
45
|
+
branches: BranchDetails[];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export namespace Overview {
|
|
49
|
+
export function is(data?: any): data is Project.Overview {
|
|
50
|
+
return Array.isArray(data?.branches);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface BranchDetails {
|
|
55
|
+
name: string;
|
|
56
|
+
url: string;
|
|
57
|
+
isDefault: boolean;
|
|
58
|
+
|
|
59
|
+
// Latest commit
|
|
60
|
+
changeTitle: string;
|
|
61
|
+
changeDate?: string;
|
|
62
|
+
changeAuthor?: string;
|
|
63
|
+
changeAuthorAvatar?: string;
|
|
64
|
+
changePR?: string;
|
|
65
|
+
changeUrl?: string;
|
|
66
|
+
changeHash: string;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export type PartialProject = DeepPartial<Project> & Pick<Project, 'id'>;
|
|
71
|
+
|
|
72
|
+
export interface PrebuildWithStatus {
|
|
73
|
+
info: PrebuildInfo;
|
|
74
|
+
status: PrebuiltWorkspaceState;
|
|
75
|
+
error?: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface PrebuildInfo {
|
|
79
|
+
id: string;
|
|
80
|
+
buildWorkspaceId: string;
|
|
81
|
+
basedOnPrebuildId?: string;
|
|
82
|
+
|
|
83
|
+
teamId?: string;
|
|
84
|
+
userId?: string;
|
|
85
|
+
|
|
86
|
+
projectId: string;
|
|
87
|
+
projectName: string;
|
|
88
|
+
|
|
89
|
+
cloneUrl: string;
|
|
90
|
+
branch: string;
|
|
91
|
+
|
|
92
|
+
startedAt: string;
|
|
93
|
+
startedBy: string;
|
|
94
|
+
startedByAvatar?: string;
|
|
95
|
+
|
|
96
|
+
changeTitle: string;
|
|
97
|
+
changeDate: string;
|
|
98
|
+
changeAuthor: string;
|
|
99
|
+
changeAuthorAvatar?: string;
|
|
100
|
+
changePR?: string;
|
|
101
|
+
changeUrl?: string;
|
|
102
|
+
changeHash: string;
|
|
103
|
+
}
|
|
104
|
+
export namespace PrebuildInfo {
|
|
105
|
+
export function is(data?: any): data is PrebuildInfo {
|
|
106
|
+
return typeof data === "object" && ["id", "buildWorkspaceId", "projectId", "branch"].every(p => p in data);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface StartPrebuildResult {
|
|
111
|
+
prebuildId: string;
|
|
112
|
+
wsid: string;
|
|
113
|
+
done: boolean;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface Team {
|
|
117
|
+
id: string;
|
|
118
|
+
name: string;
|
|
119
|
+
slug: string;
|
|
120
|
+
creationTime: string;
|
|
121
|
+
markedDeleted?: boolean;
|
|
122
|
+
/** This is a flag that triggers the HARD DELETION of this entity */
|
|
123
|
+
deleted?: boolean;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export type TeamMemberRole = "owner" | "member";
|
|
127
|
+
|
|
128
|
+
export interface TeamMemberInfo {
|
|
129
|
+
userId: string;
|
|
130
|
+
fullName?: string;
|
|
131
|
+
primaryEmail?: string;
|
|
132
|
+
avatarUrl?: string;
|
|
133
|
+
role: TeamMemberRole;
|
|
134
|
+
memberSince: string;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface TeamMembershipInvite {
|
|
138
|
+
id: string;
|
|
139
|
+
teamId: string;
|
|
140
|
+
role: TeamMemberRole;
|
|
141
|
+
creationTime: string;
|
|
142
|
+
invalidationTime: string;
|
|
143
|
+
invitedEmail?: string;
|
|
144
|
+
|
|
145
|
+
/** This is a flag that triggers the HARD DELETION of this entity */
|
|
146
|
+
deleted?: boolean;
|
|
147
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
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 Analytics = require("analytics-node");
|
|
8
|
+
import { IAnalyticsWriter, IdentifyMessage, TrackMessage, PageMessage } from "../analytics";
|
|
9
|
+
import { log } from './logging';
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export function newAnalyticsWriterFromEnv(): IAnalyticsWriter {
|
|
13
|
+
switch (process.env.GITPOD_ANALYTICS_WRITER) {
|
|
14
|
+
case "segment":
|
|
15
|
+
return new SegmentAnalyticsWriter(process.env.GITPOD_ANALYTICS_SEGMENT_KEY || "");
|
|
16
|
+
case "log":
|
|
17
|
+
return new LogAnalyticsWriter();
|
|
18
|
+
default:
|
|
19
|
+
return new NoAnalyticsWriter();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
class SegmentAnalyticsWriter implements IAnalyticsWriter {
|
|
24
|
+
|
|
25
|
+
protected readonly analytics: Analytics;
|
|
26
|
+
|
|
27
|
+
constructor(writeKey: string) {
|
|
28
|
+
this.analytics = new Analytics(writeKey);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
identify(msg: IdentifyMessage) {
|
|
32
|
+
try {
|
|
33
|
+
this.analytics.identify({
|
|
34
|
+
...msg,
|
|
35
|
+
integrations: {
|
|
36
|
+
"All": true,
|
|
37
|
+
"Mixpanel": !!msg.userId
|
|
38
|
+
}
|
|
39
|
+
}, (err: Error) => {
|
|
40
|
+
if (err) {
|
|
41
|
+
log.warn("analytics.identify failed", err);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
} catch (err) {
|
|
45
|
+
log.warn("analytics.identify failed", err);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
track(msg: TrackMessage) {
|
|
50
|
+
try {
|
|
51
|
+
this.analytics.track({
|
|
52
|
+
...msg,
|
|
53
|
+
integrations: {
|
|
54
|
+
"All": true,
|
|
55
|
+
"Mixpanel": !!msg.userId
|
|
56
|
+
}
|
|
57
|
+
}, (err: Error) => {
|
|
58
|
+
if (err) {
|
|
59
|
+
log.warn("analytics.track failed", err);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
} catch (err) {
|
|
63
|
+
log.warn("analytics.track failed", err);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
page(msg: PageMessage) {
|
|
68
|
+
try{
|
|
69
|
+
this.analytics.page({
|
|
70
|
+
...msg,
|
|
71
|
+
integrations: {
|
|
72
|
+
"All": true,
|
|
73
|
+
"Mixpanel": !!msg.userId
|
|
74
|
+
}
|
|
75
|
+
}, (err: Error) => {
|
|
76
|
+
if (err) {
|
|
77
|
+
log.warn("analytics.page failed", err);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
} catch (err) {
|
|
81
|
+
log.warn("analytics.page failed", err);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
class LogAnalyticsWriter implements IAnalyticsWriter {
|
|
88
|
+
|
|
89
|
+
identify(msg: IdentifyMessage): void {
|
|
90
|
+
log.debug("analytics identify", msg);
|
|
91
|
+
}
|
|
92
|
+
track(msg: TrackMessage): void {
|
|
93
|
+
log.debug("analytics track", msg);
|
|
94
|
+
}
|
|
95
|
+
page(msg: PageMessage): void {
|
|
96
|
+
log.debug("analytics page", msg);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
class NoAnalyticsWriter implements IAnalyticsWriter {
|
|
102
|
+
identify(msg: IdentifyMessage): void {}
|
|
103
|
+
track(msg: TrackMessage): void {}
|
|
104
|
+
page(msg: PageMessage): void {}
|
|
105
|
+
}
|
package/src/util/deferred.ts
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* See License-AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { repeat } from "./repeat";
|
|
8
|
+
|
|
7
9
|
|
|
8
10
|
interface CacheEntry<T> {
|
|
9
11
|
key: string;
|
|
@@ -13,13 +15,13 @@ interface CacheEntry<T> {
|
|
|
13
15
|
|
|
14
16
|
export class GarbageCollectedCache<T> {
|
|
15
17
|
protected readonly store = new Map<string, CacheEntry<T>>();
|
|
16
|
-
|
|
18
|
+
|
|
17
19
|
constructor(
|
|
18
20
|
protected readonly defaultMaxAgeSeconds: number,
|
|
19
21
|
protected readonly gcIntervalSeconds: number) {
|
|
20
22
|
this.regularlyCollectGarbage();
|
|
21
23
|
}
|
|
22
|
-
|
|
24
|
+
|
|
23
25
|
public set(key: string, value: T) {
|
|
24
26
|
const oldValue = this.store.get(key);
|
|
25
27
|
if (oldValue) {
|
|
@@ -41,8 +43,12 @@ export class GarbageCollectedCache<T> {
|
|
|
41
43
|
return entry.value;
|
|
42
44
|
}
|
|
43
45
|
|
|
46
|
+
public delete(key: string) {
|
|
47
|
+
this.store.delete(key);
|
|
48
|
+
}
|
|
49
|
+
|
|
44
50
|
protected regularlyCollectGarbage() {
|
|
45
|
-
|
|
51
|
+
repeat(() => this.collectGarbage(), this.gcIntervalSeconds * 1000);
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
protected collectGarbage() {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { suite, test } from "mocha-typescript"
|
|
8
8
|
import * as chai from "chai"
|
|
9
9
|
import { generateWorkspaceID, colors, animals } from "./generate-workspace-id";
|
|
10
|
-
import {
|
|
10
|
+
import { GitpodHostUrl } from "./gitpod-host-url";
|
|
11
11
|
|
|
12
12
|
const expect = chai.expect
|
|
13
13
|
|
|
@@ -15,8 +15,8 @@ const expect = chai.expect
|
|
|
15
15
|
|
|
16
16
|
@test public async testGenerateWorkspaceId() {
|
|
17
17
|
for (let i = 0; i < 100; i++) {
|
|
18
|
-
const
|
|
19
|
-
expect(
|
|
18
|
+
const id = await generateWorkspaceID();
|
|
19
|
+
expect(new GitpodHostUrl().withWorkspacePrefix(id, "eu").workspaceId).to.equal(id);
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -27,5 +27,22 @@ const expect = chai.expect
|
|
|
27
27
|
expect(longestName.length <= 36, `"${longestName}" is longer than 36 chars (${longestName.length})`).to.be.true;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
@test public async testCustomName() {
|
|
31
|
+
const data = [
|
|
32
|
+
['foo','bar','foo-bar-'],
|
|
33
|
+
['f','bar','.{2,16}-bar-'],
|
|
34
|
+
['gitpod-io','gitpod','gitpodio-gitpod-'],
|
|
35
|
+
['this is rather long and has some "§$"% special chars','also here pretty long and needs abbreviation','thisisratherlon-alsohere-'],
|
|
36
|
+
['breatheco-de', 'python-flask-api-tutorial', 'breathecode-pythonflaska-'],
|
|
37
|
+
['UPPER', "CaSe", "upper-case-"]
|
|
38
|
+
]
|
|
39
|
+
for (const d of data) {
|
|
40
|
+
const id = await generateWorkspaceID(d[0], d[1]);
|
|
41
|
+
expect(id).match(new RegExp("^"+d[2]));
|
|
42
|
+
expect(new GitpodHostUrl().withWorkspacePrefix(id, "eu").workspaceId).to.equal(id);
|
|
43
|
+
expect(id.length <= 36, `"${id}" is longer than 36 chars (${id.length})`).to.be.true;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
30
47
|
}
|
|
31
48
|
module.exports = new TestGenerateWorkspaceId()
|
|
@@ -5,8 +5,26 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import randomNumber = require("random-number-csprng");
|
|
7
7
|
|
|
8
|
-
export async function generateWorkspaceID(): Promise<string> {
|
|
9
|
-
|
|
8
|
+
export async function generateWorkspaceID(firstSegment?: string, secondSegment?: string): Promise<string> {
|
|
9
|
+
const firstSeg = clean(firstSegment) || await random(colors);
|
|
10
|
+
const secSeg = clean(secondSegment, Math.min(15, 23 - firstSeg.length)) || await random(animals);
|
|
11
|
+
return firstSeg+'-'+secSeg+'-'+(await random(characters, 11));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function clean(segment: string | undefined, maxChars: number = 15) {
|
|
15
|
+
if (!segment) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
segment = segment.toLowerCase();
|
|
19
|
+
let result = '';
|
|
20
|
+
for (let i =0; i < segment.length; i++) {
|
|
21
|
+
if (characters.indexOf(segment[i]) !== -1) {
|
|
22
|
+
result += segment[i];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (result.length >= 2) {
|
|
26
|
+
return result.substring(0, maxChars);
|
|
27
|
+
}
|
|
10
28
|
}
|
|
11
29
|
|
|
12
30
|
async function random(array: string[], length: number = 1): Promise<string> {
|
|
@@ -48,6 +66,7 @@ export const colors = [
|
|
|
48
66
|
'indigo',
|
|
49
67
|
'ivory',
|
|
50
68
|
'jade',
|
|
69
|
+
'kumquat',
|
|
51
70
|
'lavender',
|
|
52
71
|
'lime',
|
|
53
72
|
'magenta',
|
|
@@ -172,6 +191,7 @@ export const colors = [
|
|
|
172
191
|
'deer',
|
|
173
192
|
'dingo',
|
|
174
193
|
'dinosaur',
|
|
194
|
+
'dodo',
|
|
175
195
|
'dog',
|
|
176
196
|
'dolphin',
|
|
177
197
|
'donkey',
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
import * as cookie from 'cookie';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* This cookie indicates whether the connected client is a Gitpod user (= "has logged in within the last year") or not.
|
|
11
|
+
* This is used by "gitpod.io" and "www.gitpod.io" to display different content/buttons.
|
|
12
|
+
*/
|
|
13
|
+
export const NAME = "gitpod-user";
|
|
14
|
+
export const VALUE = "true";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param domain The domain the Gitpod installation is installed onto
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
export function options(domain: string): cookie.CookieSerializeOptions {
|
|
21
|
+
// Reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies
|
|
22
|
+
return {
|
|
23
|
+
path: "/", // make sure we send the cookie to all sub-pages
|
|
24
|
+
httpOnly: false,
|
|
25
|
+
secure: false,
|
|
26
|
+
maxAge: 60 * 60 * 24 * 365, // 1 year
|
|
27
|
+
sameSite: "lax", // default: true. "Lax" needed to ensure we see cookies from users that neavigate to gitpod.io from external sites
|
|
28
|
+
domain: `.${domain}`, // explicilty include subdomains to not only cover "gitpod.io", but also "www.gitpod.io" or workspaces
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export function generateCookie(domain: string): string {
|
|
33
|
+
return cookie.serialize(NAME, VALUE, options(domain));
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export function isPresent(cookies: string): boolean {
|
|
37
|
+
// needs to match the old (gitpod-user=loggedIn) and new (gitpod-user=true) values to ensure a smooth transition during rollout.
|
|
38
|
+
return !!cookies.match(`${NAME}=`);
|
|
39
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c) 2020
|
|
2
|
+
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
|
|
3
3
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
4
|
* See License-AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
@@ -21,5 +21,29 @@ export class GitpodHostUrlTest {
|
|
|
21
21
|
const actual = GitpodHostUrl.fromWorkspaceUrl("https://gray-grasshopper-nfbitfia.ws-eu02.gitpod-staging.com/#passedin=test%20value/https://github.com/gitpod-io/gitpod-test-repo").workspaceId;
|
|
22
22
|
expect(actual).to.equal("gray-grasshopper-nfbitfia");
|
|
23
23
|
}
|
|
24
|
+
|
|
25
|
+
@test public async testWithoutWorkspacePrefix() {
|
|
26
|
+
expect(GitpodHostUrl.fromWorkspaceUrl("https://3000-moccasin-ferret-155799b3.ws-eu02.gitpod-staging.com/").withoutWorkspacePrefix().toString()).to.equal("https://gitpod-staging.com/");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@test public async testWithoutWorkspacePrefix2() {
|
|
30
|
+
expect(GitpodHostUrl.fromWorkspaceUrl("https://gitpod-staging.com/").withoutWorkspacePrefix().toString()).to.equal("https://gitpod-staging.com/");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@test public async testWithoutWorkspacePrefix3() {
|
|
34
|
+
expect(GitpodHostUrl.fromWorkspaceUrl("https://gray-rook-5523v5d8.ws-dev.my-branch-1234.staging.gitpod-dev.com/").withoutWorkspacePrefix().toString()).to.equal("https://my-branch-1234.staging.gitpod-dev.com/");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@test public async testWithoutWorkspacePrefix4() {
|
|
38
|
+
expect(GitpodHostUrl.fromWorkspaceUrl("https://my-branch-1234.staging.gitpod-dev.com/").withoutWorkspacePrefix().toString()).to.equal("https://my-branch-1234.staging.gitpod-dev.com/");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@test public async testWithoutWorkspacePrefix5() {
|
|
42
|
+
expect(GitpodHostUrl.fromWorkspaceUrl("https://abc-nice-brunch-4224.staging.gitpod-dev.com/").withoutWorkspacePrefix().toString()).to.equal("https://abc-nice-brunch-4224.staging.gitpod-dev.com/");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@test public async testWithoutWorkspacePrefix6() {
|
|
46
|
+
expect(GitpodHostUrl.fromWorkspaceUrl("https://gray-rook-5523v5d8.ws-dev.abc-nice-brunch-4224.staging.gitpod-dev.com/").withoutWorkspacePrefix().toString()).to.equal("https://abc-nice-brunch-4224.staging.gitpod-dev.com/");
|
|
47
|
+
}
|
|
24
48
|
}
|
|
25
49
|
module.exports = new GitpodHostUrlTest()
|
|
@@ -12,8 +12,13 @@ export interface UrlChange {
|
|
|
12
12
|
}
|
|
13
13
|
export type UrlUpdate = UrlChange | Partial<URL>;
|
|
14
14
|
|
|
15
|
+
const baseWorkspaceIDRegex = "(([a-f][0-9a-f]{7}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})|([0-9a-z]{2,16}-[0-9a-z]{2,16}-[0-9a-z]{8,11}))";
|
|
16
|
+
|
|
15
17
|
// this pattern matches v4 UUIDs as well as the new generated workspace ids (e.g. pink-panda-ns35kd21)
|
|
16
|
-
|
|
18
|
+
const workspaceIDRegex = RegExp(`^${baseWorkspaceIDRegex}$`);
|
|
19
|
+
|
|
20
|
+
// this pattern matches URL prefixes of workspaces
|
|
21
|
+
const workspaceUrlPrefixRegex = RegExp(`^([0-9]{4,6}-)?${baseWorkspaceIDRegex}\\.`);
|
|
17
22
|
|
|
18
23
|
export class GitpodHostUrl {
|
|
19
24
|
readonly url: URL;
|
|
@@ -44,7 +49,7 @@ export class GitpodHostUrl {
|
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
withoutWorkspacePrefix(): GitpodHostUrl {
|
|
47
|
-
if (!this.url.host.match(
|
|
52
|
+
if (!this.url.host.match(workspaceUrlPrefixRegex)) {
|
|
48
53
|
// URL has no workspace prefix
|
|
49
54
|
return this;
|
|
50
55
|
}
|
|
@@ -80,27 +85,27 @@ export class GitpodHostUrl {
|
|
|
80
85
|
}
|
|
81
86
|
|
|
82
87
|
asDashboard(): GitpodHostUrl {
|
|
83
|
-
return this.with(url => ({ pathname: '/
|
|
88
|
+
return this.with(url => ({ pathname: '/' }));
|
|
84
89
|
}
|
|
85
90
|
|
|
86
91
|
asLogin(): GitpodHostUrl {
|
|
87
|
-
return this.with(url => ({ pathname: '/login
|
|
92
|
+
return this.with(url => ({ pathname: '/login' }));
|
|
88
93
|
}
|
|
89
94
|
|
|
90
95
|
asUpgradeSubscription(): GitpodHostUrl {
|
|
91
|
-
return this.with(url => ({ pathname: '/
|
|
96
|
+
return this.with(url => ({ pathname: '/plans' }));
|
|
92
97
|
}
|
|
93
98
|
|
|
94
99
|
asAccessControl(): GitpodHostUrl {
|
|
95
|
-
return this.with(url => ({ pathname: '/
|
|
100
|
+
return this.with(url => ({ pathname: '/integrations' }));
|
|
96
101
|
}
|
|
97
102
|
|
|
98
103
|
asSettings(): GitpodHostUrl {
|
|
99
|
-
return this.with(url => ({ pathname: '/settings
|
|
104
|
+
return this.with(url => ({ pathname: '/settings' }));
|
|
100
105
|
}
|
|
101
106
|
|
|
102
|
-
|
|
103
|
-
return this.with(url => ({ pathname: '/
|
|
107
|
+
asPreferences(): GitpodHostUrl {
|
|
108
|
+
return this.with(url => ({ pathname: '/preferences' }));
|
|
104
109
|
}
|
|
105
110
|
|
|
106
111
|
asStart(workspaceId = this.workspaceId): GitpodHostUrl {
|
|
@@ -128,9 +133,13 @@ export class GitpodHostUrl {
|
|
|
128
133
|
|
|
129
134
|
get workspaceId(): string | undefined {
|
|
130
135
|
const hostSegs = this.url.host.split(".");
|
|
131
|
-
if (hostSegs.length > 1
|
|
132
|
-
|
|
133
|
-
|
|
136
|
+
if (hostSegs.length > 1) {
|
|
137
|
+
const matchResults = hostSegs[0].match(workspaceIDRegex);
|
|
138
|
+
if (matchResults) {
|
|
139
|
+
// URL has a workspace prefix
|
|
140
|
+
// port prefixes are excluded
|
|
141
|
+
return matchResults[0];
|
|
142
|
+
}
|
|
134
143
|
}
|
|
135
144
|
|
|
136
145
|
const pathSegs = this.url.pathname.split("/")
|
|
@@ -141,7 +150,7 @@ export class GitpodHostUrl {
|
|
|
141
150
|
return undefined;
|
|
142
151
|
}
|
|
143
152
|
|
|
144
|
-
get blobServe(): boolean
|
|
153
|
+
get blobServe(): boolean {
|
|
145
154
|
const hostSegments = this.url.host.split(".");
|
|
146
155
|
if (hostSegments[0] === 'blobserve') {
|
|
147
156
|
return true;
|
package/src/util/grpc.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
export const defaultGRPCOptions = {
|
|
8
|
+
"grpc.keepalive_timeout_ms": 10000,
|
|
9
|
+
"grpc.keepalive_time_ms": 60000,
|
|
10
|
+
"grpc.http2.min_time_between_pings_ms": 10000,
|
|
11
|
+
"grpc.keepalive_permit_without_calls": 1,
|
|
12
|
+
"grpc-node.max_session_memory": 50,
|
|
13
|
+
"grpc.max_reconnect_backoff_ms": 5000,
|
|
14
|
+
"grpc.max_receive_message_length": 1024 * 1024 * 16,
|
|
15
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
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
|
+
import { opentracing } from "jaeger-client";
|
|
8
|
+
|
|
9
|
+
// Type definitions for jaeger-client which are not exported by @types/jaeger-client
|
|
10
|
+
// Project: https://github.com/uber/jaeger-client-node
|
|
11
|
+
// Definitions by: Julian Steger <https://github.com/julianste>
|
|
12
|
+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
13
|
+
|
|
14
|
+
export interface TracingConfig {
|
|
15
|
+
serviceName?: string;
|
|
16
|
+
disable?: boolean;
|
|
17
|
+
sampler?: SamplerConfig;
|
|
18
|
+
reporter?: ReporterConfig;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface TracingOptions {
|
|
22
|
+
reporter?: Reporter;
|
|
23
|
+
metrics?: MetricsFactory;
|
|
24
|
+
logger?: Logger;
|
|
25
|
+
tags?: any;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ReporterConfig {
|
|
29
|
+
logSpans?: boolean;
|
|
30
|
+
agentHost?: string;
|
|
31
|
+
agentPort?: number;
|
|
32
|
+
flushIntervalMs?: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface SamplerConfig {
|
|
36
|
+
type: string;
|
|
37
|
+
param: number;
|
|
38
|
+
host?: string;
|
|
39
|
+
port?: number;
|
|
40
|
+
refreshIntervalMs?: number;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface Logger {
|
|
44
|
+
info(msg: string): void;
|
|
45
|
+
error(msg: string): void;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface Reporter {
|
|
49
|
+
report(span: opentracing.Span): void;
|
|
50
|
+
close(callback?: () => void): void;
|
|
51
|
+
setProcess(serviceName: string, tags: any): void;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface MetricsFactory {
|
|
55
|
+
createCounter(name: string, tags: any): Counter;
|
|
56
|
+
createTimer(name: string, tags: any): Timer;
|
|
57
|
+
createGauge(name: string, tags: any): Gauge;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Counter tracks the number of times an event has occurred
|
|
61
|
+
export interface Counter {
|
|
62
|
+
// Adds the given value to the counter.
|
|
63
|
+
increment(delta: number): void;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Timer tracks how long an operation took and also computes percentiles.
|
|
67
|
+
export interface Timer {
|
|
68
|
+
// Records the time passed in.
|
|
69
|
+
record(value: number): void;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Gauge returns instantaneous measurements of something as an int64 value
|
|
73
|
+
export interface Gauge {
|
|
74
|
+
// Update the gauge to the value passed in.
|
|
75
|
+
update(value: number): void;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// export function initTracer(
|
|
79
|
+
// tracingConfig: TracingConfig,
|
|
80
|
+
// tracingOptions: TracingOptions,
|
|
81
|
+
// ): opentracing.Tracer;
|
|
82
|
+
|
|
83
|
+
// export function initTracerFromEnv(
|
|
84
|
+
// tracingConfig: TracingConfig,
|
|
85
|
+
// tracingOptions: TracingOptions,
|
|
86
|
+
// ): opentracing.Tracer;
|
|
87
|
+
|
|
88
|
+
export interface SamplingDecision {
|
|
89
|
+
sample: boolean;
|
|
90
|
+
retryable: boolean;
|
|
91
|
+
tags: any;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// added by TypeFox
|
|
95
|
+
export interface Sampler {
|
|
96
|
+
name(): string
|
|
97
|
+
isSampled(operation: string, tags: any): boolean;
|
|
98
|
+
onCreateSpan(span: opentracing.Span): SamplingDecision;
|
|
99
|
+
onSetOperationName(span: opentracing.Span, operationName: string): SamplingDecision;
|
|
100
|
+
onSetTag(span: opentracing.Span, key: string, value: any): SamplingDecision;
|
|
101
|
+
close(callback: () => void): void
|
|
102
|
+
}
|