Add additional performance spans

This commit is contained in:
Maximilian Paß
2023-02-02 17:51:05 +00:00
parent 689344bd79
commit f2c205a8ed
19 changed files with 92 additions and 51 deletions

View File

@ -8,6 +8,7 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/getsentry/sentry-go"
nomadApi "github.com/hashicorp/nomad/api"
influxdb2 "github.com/influxdata/influxdb-client-go/v2"
"github.com/openHPI/poseidon/internal/nomad"
@ -153,7 +154,7 @@ func (r *NomadJob) ListFileSystem(
return err
}
func (r *NomadJob) UpdateFileSystem(copyRequest *dto.UpdateFileSystemRequest) error {
func (r *NomadJob) UpdateFileSystem(copyRequest *dto.UpdateFileSystemRequest, ctx context.Context) error {
r.ResetTimeout()
var tarBuffer bytes.Buffer
@ -166,10 +167,11 @@ func (r *NomadJob) UpdateFileSystem(copyRequest *dto.UpdateFileSystemRequest) er
updateFileCommand := (&dto.ExecutionRequest{Command: fileDeletionCommand + copyCommand}).FullCommand()
stdOut := bytes.Buffer{}
stdErr := bytes.Buffer{}
span := sentry.StartSpan(ctx, "Execute Update File System")
exitCode, err := r.api.ExecuteCommand(r.id, context.Background(), updateFileCommand, false,
nomad.PrivilegedExecution, // All files should be written and owned by a privileged user #211.
&tarBuffer, &stdOut, &stdErr)
span.Finish()
if err != nil {
return fmt.Errorf(
"%w: nomad error during file copy: %v",