You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: txn_metrics.go
    path of file: ./repos/cockroach/pkg/kv/kvclient/kvcoord
    
    the code of the file until where you have to start completion: // Copyright 2019 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

package kvcoord

import (
	"time"

	"github.com/cockroachdb/cockroach/pkg/server/telemetry"
	"github.com/cockroachdb/cockroach/pkg/util/metric"
)

// TxnMetrics holds all metrics relating to KV transactions.
type TxnMetrics struct {
	Aborts                    *metric.Counter
	Commits                   *metric.Counter
	Commits1PC                *metric.Counter // Commits which finished in a single phase
	CommitsReadOnly           *metric.Counter // Commits which finished without acquiring locks
	ParallelCommits           *metric.Counter // Commits which entered the STAGING state
	ParallelCommitAutoRetries *metric.Counter // Commits which were retried after entering the STAGING state
	CommitWaits               *metric.Counter // Commits that waited for linearizability

	ClientRefreshSuccess                *metric.Counter
	ClientRefreshFail                   *metric.Counter
	ClientRefreshFailWithCondensedSpans *metric.Counter
	ClientRefreshMemoryLimitExceeded    *metric.Counter
	ClientRefreshAutoRetries            *metric.Counter
	ServerRefreshSuccess                *metric.Counter

	Durations metric.IHistogram

	TxnsWithCondensedIntents      *metric.Counter
	TxnsWithCondensedIntentsGauge *metric.Gauge
	TxnsRejectedByLockSpanBudget  *metric.Counter

	// Restarts is the number of times we had to restart the transaction.
	Restarts metric.I
    
func MakeTxnMetrics(histogramWindow time.Duration) TxnMetrics {
	return TxnMetrics{
		Aborts:                              metric.NewCounter(metaAbortsRates),
		Commits:                             metric.NewCounter(metaCommitsRates),
		Commits1PC:                          metric.NewCounter(metaCommits1PCRates),
		CommitsReadOnly:                     metric.NewCounter(metaCommitsReadOnly),
		ParallelCommits:                     metric.NewCounter(metaParallelCommitsRates),
		ParallelCommitAutoRetries:           metric.NewCounter(metaParallelCommitAutoRetries),
		CommitWaits:                         metric.NewCounter(metaCommitWaitCount),
		ClientRefreshSuccess:                metric.NewCounter(metaClientRefreshSuccess),
		ClientRefreshFail:                   metric.NewCounter(metaClientRefreshFail),
		ClientRefreshFailWithCondensedSpans: metric.NewCounter(metaClientRefreshFailWithCondensedSpans),
		ClientRefreshMemoryLimitExceeded:    metric.NewCounter(metaClientRefreshMemoryLimitExceeded),
		ClientRefreshAutoRetries:            metric.NewCounter(metaClientRefreshAutoRetries),
		ServerRefreshSuccess:                metric.NewCounter(metaServerRefreshSuccess),
		Durations: metric.NewHistogram(metric.HistogramOptions{
			Mode:         metric.HistogramModePreferHdrLatency,
			Metadata:     metaDurationsHistograms,
			Duration:     histogramWindow,
			BucketConfig: metric.IOLatencyBuckets,
		}),
		TxnsWithCondensedIntents:      metric.NewCounter(metaTxnsWithCondensedIntentSpans),
		TxnsWithCondensedIntentsGauge: metric.NewGauge(metaTxnsWithCondensedIntentSpansGauge),
		TxnsRejectedByLockSpanBudget:  metric.NewCounter(metaTxnsRejectedByLockSpanBudget),
		Restarts: metric.NewHistogram(metric.HistogramOptions{
			Metadata:     metaRestartsHistogram,
			Duration:     histogramWindow,
			MaxVal:       100,
			SigFigs:      3,
			BucketConfig: metric.Count1KBuckets,
		}),
		RestartsWriteTooOld:            telemetry.NewCounterWithMetric(metaRestartsWriteTooOld),
		RestartsWriteTooOldMulti:       telemetry.NewCounterWithMetric(metaRestartsWriteTooOldMulti),
		RestartsSerializable:           telemetry.NewCounterWithMetric(metaRestartsSerializable),
		RestartsAsyncWriteFailure:      telemetry.NewCounterWithMetric(metaRestartsAsyncWriteFailure),
		RestartsCommitDeadlineExceeded: telemetry.NewCounterWithMetric(metaRestartsCommitDeadlineExceeded),
		RestartsReadWithinUncertainty:  telemetry.NewCounterWithMetric(metaRestartsReadWithinUncertainty),
		RestartsTxnAborted:             telemetry.NewCounterWithMetric(metaRestartsTxnAborted),
		RestartsTxnPush:                telemetry.NewCounterWithMetric(metaRestartsTxnPush),
		RestartsUnknown:                telemetry.NewCounterWithMetric(metaRestartsUnknown),
		RollbacksFailed:                metric.NewCounter(metaRollbacksFailed),
		AsyncRollbacksFailed:           metric.NewCounter(metaAsyncRollbacksFailed),
	}
}