This repository has been archived by the owner on Jun 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #105 from primevprotocol/evmclientmetrics
feat: add metrics for evmclient
- Loading branch information
Showing
3 changed files
with
97 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package evmclient | ||
|
||
import "github.com/prometheus/client_golang/prometheus" | ||
|
||
const ( | ||
defaultMetricsNamespace = "mev_commit" | ||
) | ||
|
||
type metrics struct { | ||
AttemptedTxCount prometheus.Counter | ||
SentTxCount prometheus.Counter | ||
SuccessfulTxCount prometheus.Counter | ||
CancelledTxCount prometheus.Counter | ||
FailedTxCount prometheus.Counter | ||
NotFoundDuringCancelCount prometheus.Counter | ||
} | ||
|
||
func newMetrics() *metrics { | ||
m := &metrics{ | ||
AttemptedTxCount: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: defaultMetricsNamespace, | ||
Name: "attempted_tx_count", | ||
Help: "Number of attempted transactions", | ||
}), | ||
SentTxCount: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: defaultMetricsNamespace, | ||
Name: "sent_tx_count", | ||
Help: "Number of sent transactions", | ||
}), | ||
SuccessfulTxCount: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: defaultMetricsNamespace, | ||
Name: "successful_tx_count", | ||
Help: "Number of successful transactions", | ||
}), | ||
CancelledTxCount: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: defaultMetricsNamespace, | ||
Name: "cancelled_tx_count", | ||
Help: "Number of cancelled transactions", | ||
}), | ||
FailedTxCount: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: defaultMetricsNamespace, | ||
Name: "failed_tx_count", | ||
Help: "Number of failed transactions", | ||
}), | ||
NotFoundDuringCancelCount: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: defaultMetricsNamespace, | ||
Name: "not_found_during_cancel_count", | ||
Help: "Number of transactions not found during cancel", | ||
}), | ||
} | ||
|
||
return m | ||
} | ||
|
||
func (m *metrics) collectors() []prometheus.Collector { | ||
return []prometheus.Collector{ | ||
m.AttemptedTxCount, | ||
m.SentTxCount, | ||
m.SuccessfulTxCount, | ||
m.CancelledTxCount, | ||
m.FailedTxCount, | ||
m.NotFoundDuringCancelCount, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters