Skip to content

Commit ffbb260

Browse files
committed
feat: custom gauge metric for tx_submit_count
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent 942df85 commit ffbb260

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

internal/api/api.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ func Start(cfg *config.Config) error {
4242
metrics.SetMetricPath("/")
4343
// Use metrics middleware without exposing path in main app router
4444
metrics.UseWithoutExposingEndpoint(router)
45+
46+
// Custom metric
47+
submittedMetric := &ginmetrics.Metric{
48+
// This is a Gauge because input-output-hk's is a gauge
49+
Type: ginmetrics.Gauge,
50+
Name: "tx_submit_count",
51+
Description: "transactions submitted",
52+
Labels: nil,
53+
}
54+
// Add to global monitor object
55+
_ = ginmetrics.GetMonitor().AddMetric(submittedMetric)
56+
4557
// Start metrics listener
4658
go func() {
4759
// TODO: return error if we cannot initialize metrics
@@ -99,6 +111,8 @@ func handleSubmitTx(c *gin.Context) {
99111
// Return transaction ID
100112
c.String(202, txIdHex)
101113
doneChan <- true
114+
// Increment custom metric
115+
_ = ginmetrics.GetMonitor().GetMetric("tx_submit_count").Inc(nil)
102116
return nil
103117
},
104118
RejectTxFunc: func(reason interface{}) error {

0 commit comments

Comments
 (0)