@@ -277,6 +277,8 @@ func (m *ResourceUsageMonitor) Run(ctx context.Context) {
277277 ctx , cancel := context .WithCancel (ctx )
278278 defer cancel ()
279279
280+ log .Errorf ("XYZ Resource Usage Monitor Run()" )
281+ defer log .Errorf ("XYZ Resource Usage Monitor Run() exit" )
280282 // 1s, 2s, 4s, 8s, 16s, ..., m.maxSamplePeriod, m.maxSamplePeriod, m.maxSamplePeriod, ...
281283 backoffPeriod := min (time .Second , m .maxSamplePeriod )
282284 backoff := time .NewTimer (backoffPeriod )
@@ -297,6 +299,7 @@ func (m *ResourceUsageMonitor) Run(ctx context.Context) {
297299 for {
298300 select {
299301 case <- ctx .Done ():
302+ log .Errorf ("XYZ Resource Usage Monitor ctx done: %v (cause %v)" , ctx .Err (), context .Cause (ctx ))
300303 return
301304 case <- backoff .C :
302305 backoffPeriod = min (backoffPeriod * 2 , m .maxSamplePeriod )
@@ -323,6 +326,7 @@ func (m *ResourceUsageMonitor) Run(ctx context.Context) {
323326
324327 err = AggregateResourceUsage (prevRU , currRU , ss , & aggRU , false )
325328 if err != nil {
329+ log .Errorf ("XYZ Resource Usage Monitor: agg error: %v" , err )
326330 m .errorf ("aggregation error: %v" , err )
327331 resetSamples ()
328332 continue
@@ -333,8 +337,10 @@ func (m *ResourceUsageMonitor) Run(ctx context.Context) {
333337
334338 // Sample size reached.
335339 if numSamplesCollected == ss {
340+ log .Errorf ("XYZ Resource Usage Monitor: %v samples collected!" , numSamplesCollected )
336341 debugStatus , err := m .ruf .DebugStatusForPID (m .pid )
337342 if err != nil {
343+ log .Errorf ("XYZ Resource Usage Monitor: fail to get debug status" )
338344 m .errorf ("failed to get debug status for process[%d]: %v" , m .pid , err )
339345 }
340346 rud := & mpb.ResourceUsageData {
@@ -393,13 +399,17 @@ func (m *ResourceUsageMonitor) errorf(format string, a ...any) {
393399}
394400
395401// SendProtoToServer wraps a proto in a fspb.Message and sends it to the server.
396- func SendProtoToServer (ctx context.Context , pb proto.Message , msgType string , sc service.Context ) error {
402+ func SendProtoToServer (ctx context.Context , pb proto.Message , msgType string , sc service.Context ) ( sErr error ) {
397403 d , err := anypb .New (pb )
398404 if err != nil {
399405 return err
400406 }
407+ log .Errorf ("XYZ SendProtoToServer()" )
408+ defer func () { log .Errorf ("XYZ SendProtoToServer(): exit: %v" , sErr ) }()
409+
401410 ctx , cancel := context .WithTimeout (ctx , 30 * time .Second )
402411 defer cancel ()
412+
403413 return sc .Send (ctx , service.AckMessage {
404414 M : & fspb.Message {
405415 Destination : & fspb.Address {ServiceName : "system" },
0 commit comments