Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/install/installer/pkg/components/ide-metrics/configmap.go
2501 views
1
// Copyright (c) 2022 Gitpod GmbH. All rights reserved.
2
// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
5
package ide_metrics
6
7
import (
8
"fmt"
9
"strconv"
10
11
"github.com/gitpod-io/gitpod/ide-metrics-api/config"
12
"github.com/gitpod-io/gitpod/installer/pkg/common"
13
"github.com/prometheus/client_golang/prometheus"
14
15
corev1 "k8s.io/api/core/v1"
16
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
17
"k8s.io/apimachinery/pkg/runtime"
18
)
19
20
func configmap(ctx *common.RenderContext) ([]runtime.Object, error) {
21
var statusCodes []string
22
for statusCode := 100; statusCode < 600; statusCode++ {
23
statusCodes = append(statusCodes, strconv.Itoa(statusCode))
24
}
25
statusCodes = append(statusCodes, "unknown")
26
27
counterMetrics := []config.CounterMetricsConfiguration{
28
// we could also create a generator later similar to https://github.com/grpc/grpc-go/tree/master/cmd/protoc-gen-go-grpc if there is abuse
29
{
30
Name: "grpc_server_handled_total",
31
Help: "Total number of RPCs completed on the server, regardless of success or failure.",
32
Labels: []config.LabelAllowList{
33
{
34
Name: "grpc_method",
35
AllowValues: []string{"*"},
36
},
37
{
38
Name: "grpc_service",
39
AllowValues: []string{"*"},
40
},
41
{
42
Name: "grpc_type",
43
AllowValues: []string{"*"},
44
},
45
{
46
Name: "grpc_code",
47
AllowValues: []string{"*"},
48
},
49
},
50
},
51
{
52
Name: "grpc_server_msg_received_total",
53
Help: "Total number of RPC stream messages received on the server.",
54
Labels: []config.LabelAllowList{
55
{
56
Name: "grpc_method",
57
AllowValues: []string{"*"},
58
},
59
{
60
Name: "grpc_service",
61
AllowValues: []string{"*"},
62
},
63
{
64
Name: "grpc_type",
65
AllowValues: []string{"*"},
66
},
67
},
68
},
69
{
70
Name: "grpc_server_msg_sent_total",
71
Help: "Total number of gRPC stream messages sent by the server.",
72
Labels: []config.LabelAllowList{
73
{
74
Name: "grpc_method",
75
AllowValues: []string{"*"},
76
},
77
{
78
Name: "grpc_service",
79
AllowValues: []string{"*"},
80
},
81
{
82
Name: "grpc_type",
83
AllowValues: []string{"*"},
84
},
85
},
86
},
87
{
88
Name: "grpc_server_started_total",
89
Help: "Total number of RPCs started on the server.",
90
Labels: []config.LabelAllowList{
91
{
92
Name: "grpc_method",
93
AllowValues: []string{"*"},
94
},
95
{
96
Name: "grpc_service",
97
AllowValues: []string{"*"},
98
},
99
{
100
Name: "grpc_type",
101
AllowValues: []string{"*"},
102
},
103
},
104
},
105
{
106
Name: "gitpod_supervisor_frontend_error_total",
107
Help: "Total count of supervisor frontend client errors",
108
Labels: []config.LabelAllowList{
109
{
110
Name: "resource",
111
AllowValues: []string{
112
"vscode-web-workbench",
113
"unknown",
114
},
115
DefaultValue: "unknown",
116
},
117
{
118
Name: "error",
119
AllowValues: []string{
120
"LoadError", // js script style of errors
121
"Unknown",
122
},
123
DefaultValue: "Unknown",
124
},
125
},
126
},
127
{
128
Name: "gitpod_vscode_web_load_total",
129
Help: "Total count of attempts to load VS Code Web workbench",
130
Labels: []config.LabelAllowList{
131
{
132
Name: "status",
133
AllowValues: []string{"loading", "failed"},
134
},
135
},
136
},
137
{
138
Name: "gitpod_supervisor_frontend_client_total",
139
Help: "Total count of supervisor frontend client",
140
},
141
{
142
Name: "gitpod_vscode_extension_gallery_operation_total",
143
Help: "Total count of extension operations",
144
Labels: []config.LabelAllowList{
145
{
146
Name: "operation",
147
AllowValues: []string{"install", "update", "uninstall", "unknown"},
148
DefaultValue: "unknown",
149
},
150
{
151
Name: "status",
152
AllowValues: []string{"success", "failure", "unknown"},
153
DefaultValue: "unknown",
154
},
155
{
156
Name: "galleryHost",
157
AllowValues: []string{"*"},
158
},
159
// TODO(ak) errorCode - we should analyze error codes collect in analytics and categotize them here
160
},
161
},
162
{
163
Name: "gitpod_vscode_extension_gallery_query_total",
164
Help: "Total count of extension gallery queries",
165
Labels: []config.LabelAllowList{
166
{
167
Name: "status",
168
AllowValues: []string{"success", "failure", "unknown"},
169
DefaultValue: "unknown",
170
},
171
{
172
Name: "statusCode",
173
AllowValues: statusCodes,
174
DefaultValue: "unknown",
175
},
176
{
177
Name: "errorCode",
178
AllowValues: []string{"canceled", "timeout", "failed", "unknown"},
179
DefaultValue: "unknown",
180
},
181
{
182
Name: "galleryHost",
183
AllowValues: []string{"*"},
184
},
185
},
186
}, {
187
Name: "grpc_client_started_total",
188
Help: "Total number of RPCs started on the client.",
189
Labels: []config.LabelAllowList{
190
{
191
Name: "grpc_method",
192
AllowValues: []string{"*"},
193
},
194
{
195
Name: "grpc_service",
196
AllowValues: []string{"*"},
197
},
198
{
199
Name: "grpc_type",
200
AllowValues: []string{"*"},
201
},
202
},
203
Client: &config.ClientAllowList{
204
Name: "metric_client",
205
AllowValues: []string{"dashboard", "vscode-desktop-extension", "supervisor", "unknown"},
206
DefaultValue: "unknown",
207
},
208
}, {
209
Name: "grpc_client_handled_total",
210
Help: "Total number of RPCs completed by the client, regardless of success or failure.",
211
Labels: []config.LabelAllowList{
212
{
213
Name: "grpc_method",
214
AllowValues: []string{"*"},
215
},
216
{
217
Name: "grpc_service",
218
AllowValues: []string{"*"},
219
},
220
{
221
Name: "grpc_type",
222
AllowValues: []string{"*"},
223
},
224
{
225
Name: "grpc_code",
226
AllowValues: []string{"*"},
227
},
228
},
229
Client: &config.ClientAllowList{
230
Name: "metric_client",
231
AllowValues: []string{"dashboard", "vscode-desktop-extension", "supervisor", "unknown"},
232
DefaultValue: "unknown",
233
},
234
},
235
{
236
Name: "supervisor_client_handled_total",
237
Help: "Total number of supervisor outgoing services completed by the client, regardless of success or failure.",
238
Labels: []config.LabelAllowList{
239
{
240
Name: "method",
241
AllowValues: []string{"*"},
242
},
243
{
244
Name: "server",
245
AllowValues: []string{"*"},
246
},
247
{
248
Name: "err_code",
249
AllowValues: []string{"*"},
250
},
251
},
252
},
253
{
254
Name: "vscode_desktop_local_ssh_config_total",
255
Help: "Total number of vscode desktop extension config local ssh configuration",
256
Labels: []config.LabelAllowList{
257
{
258
Name: "status",
259
AllowValues: []string{"success", "failure"},
260
},
261
{
262
Name: "failure_code",
263
AllowValues: []string{"*"},
264
DefaultValue: "Unknown",
265
},
266
},
267
Client: &config.ClientAllowList{
268
Name: "metric_client",
269
AllowValues: []string{"vscode-desktop-extension"},
270
DefaultValue: "unknown",
271
},
272
},
273
{
274
Name: "vscode_desktop_ping_extension_server_total",
275
Help: "Total number of vscode desktop extension local ssh extension ipc server ping",
276
Labels: []config.LabelAllowList{
277
{
278
Name: "status",
279
AllowValues: []string{"success", "failure"},
280
},
281
},
282
Client: &config.ClientAllowList{
283
Name: "metric_client",
284
AllowValues: []string{"vscode-desktop-extension"},
285
DefaultValue: "unknown",
286
},
287
},
288
{
289
Name: "vscode_desktop_local_ssh_total",
290
Help: "Total number of vscode desktop local ssh proxy connection",
291
Labels: []config.LabelAllowList{
292
{
293
Name: "phase",
294
AllowValues: []string{"connecting", "connected", "failed"},
295
},
296
{
297
Name: "failure_code",
298
AllowValues: []string{"*"},
299
DefaultValue: "Unknown",
300
},
301
},
302
Client: &config.ClientAllowList{
303
Name: "metric_client",
304
AllowValues: []string{"vscode-desktop-extension"},
305
DefaultValue: "unknown",
306
},
307
},
308
{
309
Name: "websocket_client_total",
310
Help: "Total number of WebSocket connections by the client",
311
Labels: []config.LabelAllowList{
312
{
313
Name: "origin",
314
AllowValues: []string{"unknown", "workspace", "gitpod", "localhost"},
315
DefaultValue: "unknown",
316
},
317
{
318
Name: "instance_phase",
319
AllowValues: []string{"undefined", "unknown", "preparing", "building", "pending", "creating", "initializing", "running", "interrupted", "stopping", "stopped"},
320
DefaultValue: "undefined",
321
},
322
{
323
Name: "status",
324
AllowValues: []string{"unknown", "new", "open", "error", "close"},
325
DefaultValue: "unknown",
326
},
327
{
328
Name: "code",
329
AllowValues: []string{"*"},
330
DefaultValue: "unknown",
331
},
332
{
333
Name: "was_clean",
334
AllowValues: []string{"unknown", "0", "1"},
335
DefaultValue: "unknown",
336
},
337
},
338
},
339
{
340
Name: "supervisor_ssh_tunnel_opened_total",
341
Help: "Total number of SSH tunnels opened by the supervisor",
342
Labels: []config.LabelAllowList{},
343
},
344
{
345
Name: "supervisor_ssh_tunnel_closed_total",
346
Help: "Total number of SSH tunnels closed by the supervisor",
347
Labels: []config.LabelAllowList{
348
{
349
Name: "code",
350
AllowValues: []string{"*"},
351
DefaultValue: "unknown",
352
},
353
},
354
},
355
}
356
357
histogramMetrics := []config.HistogramMetricsConfiguration{
358
{
359
Name: "gitpod_vscode_extension_gallery_operation_duration_seconds",
360
Help: "Duration of extension operations in seconds",
361
Labels: []config.LabelAllowList{
362
{
363
Name: "operation",
364
AllowValues: []string{"install", "update", "uninstall", "unknown"},
365
DefaultValue: "unknown",
366
},
367
{
368
Name: "galleryHost",
369
AllowValues: []string{"*"},
370
},
371
},
372
Buckets: []float64{0.1, 0.5, 1, 5, 10, 15, 30},
373
}, {
374
Name: "gitpod_vscode_extension_gallery_query_duration_seconds",
375
Help: "Duration of extension gallery query in seconds",
376
Labels: []config.LabelAllowList{
377
{
378
Name: "galleryHost",
379
AllowValues: []string{"*"},
380
},
381
},
382
Buckets: []float64{0.1, 0.5, 1, 5, 10, 15, 30},
383
},
384
}
385
386
aggregatedHistogramMetrics := []config.HistogramMetricsConfiguration{
387
// we could also create a generator later similar to https://github.com/grpc/grpc-go/tree/master/cmd/protoc-gen-go-grpc if there is abuse
388
{
389
Name: "grpc_server_handling_seconds",
390
Help: "Histogram of response latency (seconds) of gRPC that had been application-level handled by the server.",
391
Labels: []config.LabelAllowList{
392
{
393
Name: "grpc_method",
394
AllowValues: []string{"*"},
395
},
396
{
397
Name: "grpc_service",
398
AllowValues: []string{"*"},
399
},
400
{
401
Name: "grpc_type",
402
AllowValues: []string{"*"},
403
},
404
},
405
Buckets: []float64{.005, .025, .05, .1, .5, 1, 2.5, 5, 30, 60, 120, 240, 600},
406
},
407
{
408
Name: "supervisor_ide_ready_duration_total",
409
Help: "the IDE startup time",
410
Buckets: []float64{0.1, 0.5, 1, 1.5, 2, 2.5, 5, 10},
411
Labels: []config.LabelAllowList{
412
{
413
Name: "kind",
414
AllowValues: []string{"web", "desktop"},
415
},
416
},
417
},
418
{
419
Name: "supervisor_initializer_bytes_second",
420
Help: "initializer speed in bytes per second",
421
Buckets: prometheus.ExponentialBuckets(1024*1024, 2, 12),
422
Labels: []config.LabelAllowList{
423
{
424
Name: "kind",
425
AllowValues: []string{"*"},
426
},
427
},
428
}, {
429
Name: "grpc_client_handling_seconds",
430
Help: "Histogram of response latency (seconds) of the gRPC until it is finished by the application.",
431
Labels: []config.LabelAllowList{
432
{
433
Name: "grpc_type",
434
AllowValues: []string{"*"},
435
},
436
{
437
Name: "grpc_service",
438
AllowValues: []string{"*"},
439
},
440
{
441
Name: "grpc_method",
442
AllowValues: []string{"*"},
443
},
444
},
445
Buckets: []float64{0.1, 0.2, 0.5, 1, 2, 5, 10},
446
Client: &config.ClientAllowList{
447
Name: "metric_client",
448
AllowValues: []string{"dashboard", "vscode-desktop-extension", "supervisor", "unknown"},
449
DefaultValue: "unknown",
450
},
451
}, {
452
Name: "supervisor_client_handling_seconds",
453
Help: "Histogram of response latency (seconds) of the supervisor outgoing services until it is finished by the application.",
454
Labels: []config.LabelAllowList{
455
{
456
Name: "method",
457
AllowValues: []string{"*"},
458
},
459
{
460
Name: "server",
461
AllowValues: []string{"*"},
462
},
463
{
464
Name: "err_code",
465
AllowValues: []string{"*"},
466
},
467
},
468
Buckets: []float64{0.1, 0.2, 0.5, 1, 2, 5, 10},
469
},
470
}
471
472
errorReporting := config.ErrorReportingConfiguration{
473
AllowComponents: []string{
474
"supervisor-frontend",
475
// "vscode-workbench",
476
// "vscode-server",
477
// "vscode-web",
478
"gitpod-cli",
479
"gitpod-web",
480
"gitpod-remote-ssh",
481
"vscode-desktop-extension",
482
"dashboard",
483
},
484
}
485
486
cfg := config.ServiceConfiguration{
487
Server: config.MetricsServerConfiguration{
488
Port: ContainerPort,
489
// RateLimits: , // TODO(pd) ratelimit
490
CounterMetrics: counterMetrics,
491
HistogramMetrics: histogramMetrics,
492
AggregatedHistogramMetrics: aggregatedHistogramMetrics,
493
ErrorReporting: errorReporting,
494
},
495
Prometheus: struct {
496
Addr string `json:"addr"`
497
}{Addr: common.LocalhostPrometheusAddr()},
498
}
499
500
fc, err := common.ToJSONString(cfg)
501
if err != nil {
502
return nil, fmt.Errorf("failed to marshal ide-metrics config: %w", err)
503
}
504
505
res := []runtime.Object{
506
&corev1.ConfigMap{
507
TypeMeta: common.TypeMetaConfigmap,
508
ObjectMeta: metav1.ObjectMeta{
509
Name: Component,
510
Namespace: ctx.Namespace,
511
Labels: common.CustomizeLabel(ctx, Component, common.TypeMetaConfigmap),
512
Annotations: common.CustomizeAnnotation(ctx, Component, common.TypeMetaConfigmap),
513
},
514
Data: map[string]string{
515
"config.json": string(fc),
516
},
517
},
518
}
519
return res, nil
520
}
521
522