@@ -330,7 +330,7 @@ func Run(options ...RunOption) {
330
330
shutdown = make (chan ShutdownReason , 1 )
331
331
)
332
332
wg .Add (1 )
333
- go startContentInit (ctx , cfg , & wg , cstate )
333
+ go startContentInit (ctx , cfg , & wg , cstate , supervisorMetrics )
334
334
wg .Add (1 )
335
335
go startAPIEndpoint (ctx , cfg , & wg , apiServices , tunneledPortsService , metricsReporter , apiEndpointOpts ... )
336
336
wg .Add (1 )
@@ -1354,7 +1354,7 @@ func startSSHServer(ctx context.Context, cfg *Config, wg *sync.WaitGroup, childP
1354
1354
}()
1355
1355
}
1356
1356
1357
- func startContentInit (ctx context.Context , cfg * Config , wg * sync.WaitGroup , cst ContentState ) {
1357
+ func startContentInit (ctx context.Context , cfg * Config , wg * sync.WaitGroup , cst ContentState , metrics * metrics. SupervisorMetrics ) {
1358
1358
defer wg .Done ()
1359
1359
defer log .Info ("supervisor: workspace content available" )
1360
1360
@@ -1434,6 +1434,8 @@ func startContentInit(ctx context.Context, cfg *Config, wg *sync.WaitGroup, cst
1434
1434
return
1435
1435
}
1436
1436
1437
+ recordInitializerMetrics ("/workspace" , metrics )
1438
+
1437
1439
err = os .Remove (fn )
1438
1440
if os .IsNotExist (err ) {
1439
1441
// file is gone - we're good
@@ -1448,6 +1450,27 @@ func startContentInit(ctx context.Context, cfg *Config, wg *sync.WaitGroup, cst
1448
1450
cst .MarkContentReady (src )
1449
1451
}
1450
1452
1453
+ func recordInitializerMetrics (path string , metrics * metrics.SupervisorMetrics ) {
1454
+ readyFile := filepath .Join (path , ".gitpod/ready" )
1455
+
1456
+ content , err := os .ReadFile (readyFile )
1457
+ if err != nil {
1458
+ log .WithError (err ).Errorf ("could not find ready file at %v" , readyFile )
1459
+ return
1460
+ }
1461
+
1462
+ var ready csapi.WorkspaceReadyMessage
1463
+ err = json .Unmarshal (content , & ready )
1464
+ if err != nil {
1465
+ log .WithError (err ).Error ("could not unmarshal ready" )
1466
+ return
1467
+ }
1468
+
1469
+ for _ , m := range ready .Metrics {
1470
+ metrics .InitializerHistogram .WithLabelValues (m .Type ).Observe (float64 (m .Size ) / m .Duration .Seconds ())
1471
+ }
1472
+ }
1473
+
1451
1474
func socketActivationForDocker (ctx context.Context , wg * sync.WaitGroup , term * terminal.Mux ) {
1452
1475
defer wg .Done ()
1453
1476
0 commit comments