Skip to content

Commit

Permalink
symbolication: separate extraction from upload timeouts
Browse files Browse the repository at this point in the history
we're seeing sporadic timeouts on internal fleets, splitting
timeouts to give both the extraction and the upload a bit more
headroom
  • Loading branch information
Gandem committed Jul 9, 2024
1 parent a3b76e2 commit c49dda6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions symbolication/datadog_uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const binaryCacheSize = 1000

const sourceMapEndpoint = "/api/v2/srcmap"

const symbolExtractionTimeout = 10 * time.Second
const uploadTimeout = 10 * time.Second

type DatadogUploader struct {
Expand Down Expand Up @@ -117,15 +118,12 @@ func (d *DatadogUploader) HandleExecutable(elfRef *pfelf.Reference, fileID libpf
// if there are many executables.
// Ideally, we should limit the number of concurrent uploads
go func() {
ctx, cancel := context.WithTimeout(context.Background(), uploadTimeout)
defer cancel()

if d.dryRun {
log.Infof("Dry run: would upload symbols %s for executable: %s", inputFilePath, e)
return
}

err = d.handleSymbols(ctx, inputFilePath, e)
err = d.handleSymbols(inputFilePath, e)
if err != nil {
d.uploadCache.Remove(fileID)
log.Errorf("Failed to handle symbols: %v for executable: %s", err, e)
Expand Down Expand Up @@ -184,7 +182,7 @@ func (e *executableMetadata) String() string {
)
}

func (d *DatadogUploader) handleSymbols(ctx context.Context, symbolPath string,
func (d *DatadogUploader) handleSymbols(symbolPath string,
e *executableMetadata) error {
symbolFile, err := os.CreateTemp("", "objcopy-debug")
if err != nil {
Expand All @@ -193,11 +191,15 @@ func (d *DatadogUploader) handleSymbols(ctx context.Context, symbolPath string,
defer os.Remove(symbolFile.Name())
defer symbolFile.Close()

ctx, cancel := context.WithTimeout(context.Background(), symbolExtractionTimeout)
defer cancel()
err = d.copySymbols(ctx, symbolPath, symbolFile.Name())
if err != nil {
return fmt.Errorf("failed to copy symbols: %w", err)
}

ctx, cancel = context.WithTimeout(context.Background(), uploadTimeout)
defer cancel()
err = d.uploadSymbols(ctx, symbolFile, e)
if err != nil {
return fmt.Errorf("failed to upload symbols: %w", err)
Expand Down

0 comments on commit c49dda6

Please sign in to comment.