Skip to content

Commit

Permalink
Don't assume AWS SDK sets ContentLength for get object
Browse files Browse the repository at this point in the history
  • Loading branch information
hifi committed Jan 5, 2024
1 parent e71e685 commit 07fc79c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions s3/replica_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,9 @@ func (c *ReplicaClient) SnapshotReader(ctx context.Context, generation string, i
return nil, err
}
internal.OperationTotalCounterVec.WithLabelValues(ReplicaClientType, "GET").Inc()
internal.OperationBytesCounterVec.WithLabelValues(ReplicaClientType, "GET").Add(float64(*out.ContentLength))
if out.ContentLength != nil {
internal.OperationBytesCounterVec.WithLabelValues(ReplicaClientType, "GET").Add(float64(*out.ContentLength))
}

return out.Body, nil
}
Expand Down Expand Up @@ -386,7 +388,9 @@ func (c *ReplicaClient) WALSegmentReader(ctx context.Context, pos litestream.Pos
return nil, err
}
internal.OperationTotalCounterVec.WithLabelValues(ReplicaClientType, "GET").Inc()
internal.OperationBytesCounterVec.WithLabelValues(ReplicaClientType, "GET").Add(float64(*out.ContentLength))
if out.ContentLength != nil {
internal.OperationBytesCounterVec.WithLabelValues(ReplicaClientType, "GET").Add(float64(*out.ContentLength))
}

return out.Body, nil
}
Expand Down

0 comments on commit 07fc79c

Please sign in to comment.