Skip to content

Commit

Permalink
send egress stats
Browse files Browse the repository at this point in the history
  • Loading branch information
frostbyte73 committed Jan 9, 2024
1 parent d6b560b commit 702269d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
9 changes: 9 additions & 0 deletions pkg/service/ioclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,12 @@ func (c *IOClient) UpdateEgress(ctx context.Context, info *livekit.EgressInfo, o

return &emptypb.Empty{}, nil
}

func (c *IOClient) UpdateMetrics(ctx context.Context, req *rpc.UpdateMetricsRequest, opts ...psrpc.RequestOption) (*emptypb.Empty, error) {
_, err := c.IOInfoClient.UpdateMetrics(ctx, req, opts...)
if err != nil {
logger.Errorw("failed to update metrics", err)
return nil, err
}
return &emptypb.Empty{}, nil
}
10 changes: 8 additions & 2 deletions pkg/service/service_rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,17 @@ func (s *Service) processEnded(p *Process, err error) {
p.info.Error = "internal error"
}
_, _ = s.ioClient.UpdateEgress(p.ctx, p.info)
s.Stop(false)
if p.info.Error == "internal error" {
s.Stop(false)
}
}

avgCPU, maxCPU := s.CloseEgressStats(p.info.EgressId)
logger.Infow("egress stats", "egressID", p.req.EgressId, "avgCPU", avgCPU, "maxCPU", maxCPU)
_, _ = s.ioClient.UpdateMetrics(p.ctx, &rpc.UpdateMetricsRequest{
Info: p.info,
AvgCpuUsage: float32(avgCPU),
MaxCpuUsage: float32(maxCPU),
})

s.EgressEnded(p.req)
p.closed.Break()
Expand Down

0 comments on commit 702269d

Please sign in to comment.