Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(daemon) add time saved metric to Go daemon #5148

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cli/internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ type Server struct {
repoRoot turbopath.AbsoluteSystemPath
closerMu sync.Mutex
closer *closer
timeSavedMu sync.Mutex
timesSaved map[string]uint64
}

// GRPCServer is the interface that the turbo server needs to the underlying
Expand Down Expand Up @@ -82,6 +84,7 @@ func New(serverName string, logger hclog.Logger, repoRoot turbopath.AbsoluteSyst
started: time.Now(),
logFilePath: logFilePath,
repoRoot: repoRoot,
timesSaved: map[string]uint64{},
}
server.watcher.AddClient(cookieJar)
server.watcher.AddClient(globWatcher)
Expand Down Expand Up @@ -137,6 +140,9 @@ func (s *Server) Register(grpcServer GRPCServer) {

// NotifyOutputsWritten implements the NotifyOutputsWritten rpc from turbo.proto
func (s *Server) NotifyOutputsWritten(ctx context.Context, req *turbodprotocol.NotifyOutputsWrittenRequest) (*turbodprotocol.NotifyOutputsWrittenResponse, error) {
s.timeSavedMu.Lock()
s.timesSaved[req.Hash] = req.TimeSaved
s.timeSavedMu.Unlock()
outputs := fs.TaskOutputs{
Inclusions: req.OutputGlobs,
Exclusions: req.OutputExclusionGlobs,
Expand All @@ -151,13 +157,17 @@ func (s *Server) NotifyOutputsWritten(ctx context.Context, req *turbodprotocol.N

// GetChangedOutputs implements the GetChangedOutputs rpc from turbo.proto
func (s *Server) GetChangedOutputs(ctx context.Context, req *turbodprotocol.GetChangedOutputsRequest) (*turbodprotocol.GetChangedOutputsResponse, error) {
s.timeSavedMu.Lock()
timeSaved := s.timesSaved[req.Hash]
s.timeSavedMu.Unlock()

changedGlobs, err := s.globWatcher.GetChangedGlobs(req.Hash, req.OutputGlobs)
if err != nil {
return nil, err
}
return &turbodprotocol.GetChangedOutputsResponse{
ChangedOutputGlobs: changedGlobs,
TimeSaved: timeSaved,
}, nil
}

Expand Down