Skip to content

fix: handle loggedEvents adjustments consistently on error scenarios #5816

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

Draft
wants to merge 1 commit into
base: chore.upload-embedded-dt-diff-to-s3
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,25 @@
c.stats.comparisonTime.RecordDuration()()

differingResponse, sampleDiff := c.differingEvents(embeddedResponse, legacyResponse)
if len(differingResponse) == 0 && sampleDiff == "" {
noOfDifferences := int64(len(differingResponse))
if noOfDifferences == 0 && sampleDiff == "" {

Check warning on line 37 in processor/internal/transformer/destination_transformer/logger.go

View check run for this annotation

Codecov / codecov/patch

processor/internal/transformer/destination_transformer/logger.go#L36-L37

Added lines #L36 - L37 were not covered by tests
return
}

c.loggedEvents.Add(noOfDifferences)

Check warning on line 42 in processor/internal/transformer/destination_transformer/logger.go

View check run for this annotation

Codecov / codecov/patch

processor/internal/transformer/destination_transformer/logger.go#L41-L42

Added lines #L41 - L42 were not covered by tests
objName := path.Join("embedded-dt-samples", config.GetKubeNamespace(), uuid.New().String())
differingResponseJSON, err := jsonrs.Marshal(differingResponse)
if err != nil {
c.loggedEvents.Add(-noOfDifferences)

Check warning on line 46 in processor/internal/transformer/destination_transformer/logger.go

View check run for this annotation

Codecov / codecov/patch

processor/internal/transformer/destination_transformer/logger.go#L46

Added line #L46 was not covered by tests
c.log.Errorn("DestinationTransformer sanity check failed (cannot encode differingResponse)", obskit.Error(err))
return
}

// upload sample diff and differing response to s3
file, err := c.samplingFileManager.UploadReader(ctx, objName, bytes.NewReader(append([]byte(sampleDiff), differingResponseJSON...)))
if err != nil {
c.loggedEvents.Add(-noOfDifferences)

Check warning on line 54 in processor/internal/transformer/destination_transformer/logger.go

View check run for this annotation

Codecov / codecov/patch

processor/internal/transformer/destination_transformer/logger.go#L54

Added line #L54 was not covered by tests
c.log.Errorn("Error uploading DestinationTransformer sanity check diff file", obskit.Error(err))
return
}
Expand All @@ -55,7 +60,6 @@
logger.NewStringField("location", file.Location),
logger.NewStringField("objectName", file.ObjectName),
)
c.loggedEvents.Add(int64(len(differingResponse)))
}

func (c *Client) differingEvents(
Expand Down
Loading