@@ -74,6 +74,11 @@ func (m metricsStore) InTx(f func(database.Store) error, options *database.TxOpt
74
74
options = database .DefaultTXOptions ()
75
75
}
76
76
77
+ if options .TxIdentifier == "" {
78
+ // empty strings are hard to deal with in grafana
79
+ options .TxIdentifier = "unlabeled"
80
+ }
81
+
77
82
start := time .Now ()
78
83
err := m .Store .InTx (f , options )
79
84
dur := time .Since (start )
@@ -82,13 +87,13 @@ func (m metricsStore) InTx(f func(database.Store) error, options *database.TxOpt
82
87
// So IDs should be used sparingly to prevent too much bloat.
83
88
m .txDuration .With (prometheus.Labels {
84
89
"success" : strconv .FormatBool (err == nil ),
85
- "tx_id" : options .TxIdentifier , // Can be empty string for unlabeled
90
+ "tx_id" : options .TxIdentifier ,
86
91
}).Observe (dur .Seconds ())
87
92
88
93
m .txRetries .With (prometheus.Labels {
89
94
"success" : strconv .FormatBool (err == nil ),
90
95
"retries" : strconv .FormatInt (int64 (options .ExecutionCount ()- 1 ), 10 ),
91
- "tx_id" : options .TxIdentifier , // Can be empty string for unlabeled
96
+ "tx_id" : options .TxIdentifier ,
92
97
}).Inc ()
93
98
94
99
// Log all serializable transactions that are retried.
0 commit comments