Skip to content

lib/gobuild: fix swapped put_s3_object and put_s3_found metrics - #26

Closed
RaphaelFakhri wants to merge 1 commit into
tailscale:mainfrom
RaphaelFakhri:fix/s3-put-metrics
Closed

RaphaelFakhri wants to merge 1 commit into
tailscale:mainfrom
RaphaelFakhri:fix/s3-put-metrics

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

Description

maybePutObject incremented put_s3_found when PutCond reported that it wrote the object, and put_s3_object when it did not. The counters were reversed.

This change increments put_s3_object for uploaded objects and put_s3_found for objects that were already present.

Testing

TestPutMetrics runs S3Cache.Put against an in-memory S3 endpoint. It writes a new object and checks that put_s3_object is 1 and put_s3_found is 0. It then writes a second action for the same output and checks that put_s3_found is 1.

go test ./lib/gobuild

Before the change, the test fails on the first check. After the change, it passes. go vet and gofmt -l report nothing.

Fixes #25

PutCond reports true when it wrote the object, but maybePutObject counted
that case as an object that was already present, and the reverse. Count
written objects in put_s3_object and pre-existing ones in put_s3_found.

Fixes #25

Signed-off-by: Raphael Fakhri <153192858+RaphaelFakhri@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

put_s3_object and put_s3_found metrics are swapped

1 participant