Fix Spanner metrics (#8541)

* Fix metric for Get

This was incorrectly being reported as List

* Measure transactions
This commit is contained in:
Seth Vargo 2020-03-13 07:35:56 -04:00 committed by GitHub
parent 365ae4290a
commit 737fdc34e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -64,6 +64,9 @@ var (
// metricPut is the key for the metric for measuring a Put call.
metricPut = []string{"spanner", "put"}
// metricTxn is the key for the metric for measuring a Transaction call.
metricTxn = []string{"spanner", "txn"}
)
// Backend implements physical.Backend and describes the steps necessary to
@ -193,7 +196,7 @@ func (b *Backend) Put(ctx context.Context, entry *physical.Entry) error {
// Get fetches an entry. If there is no entry, this function returns nil.
func (b *Backend) Get(ctx context.Context, key string) (*physical.Entry, error) {
defer metrics.MeasureSince(metricList, time.Now())
defer metrics.MeasureSince(metricGet, time.Now())
// Pooling
b.permitPool.Acquire()
@ -293,6 +296,8 @@ func (b *Backend) List(ctx context.Context, prefix string) ([]string, error) {
// Transaction runs multiple entries via a single transaction.
func (b *Backend) Transaction(ctx context.Context, txns []*physical.TxnEntry) error {
defer metrics.MeasureSince(metricTxn, time.Now())
// Quit early if we can
if len(txns) == 0 {
return nil