Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rename metric to match IOHK #62

Merged
merged 1 commit into from
Oct 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func Start(cfg *config.Config) error {
failureMetric := &ginmetrics.Metric{
// This is a Gauge because input-output-hk's is a gauge
Type: ginmetrics.Gauge,
Name: "tx_failure_count",
Name: "tx_submit_fail_count",
Description: "transactions failed",
Labels: nil,
}
Expand Down Expand Up @@ -138,7 +138,7 @@ func handleSubmitTx(c *gin.Context) {
// Log the error, return an error to the user, and increment failed count
logger.Errorf("invalid request body, should be application/cbor")
c.Data(415, "application/json", []byte("invalid request body, should be application/cbor"))
_ = ginmetrics.GetMonitor().GetMetric("tx_failure_count").Inc(nil)
_ = ginmetrics.GetMonitor().GetMetric("tx_submit_fail_count").Inc(nil)
return
}
// Read raw transaction bytes from the request body and store in a byte array
Expand All @@ -147,7 +147,7 @@ func handleSubmitTx(c *gin.Context) {
// Log the error, return an error to the user, and increment failed count
logger.Errorf("failed to read request body: %s", err)
c.Data(500, "application/json", []byte("failed to read request body"))
_ = ginmetrics.GetMonitor().GetMetric("tx_failure_count").Inc(nil)
_ = ginmetrics.GetMonitor().GetMetric("tx_submit_fail_count").Inc(nil)
return
}
// Close request body after read
Expand All @@ -159,7 +159,7 @@ func handleSubmitTx(c *gin.Context) {
if err := cbor.Unmarshal(txRawBytes, &txUnwrap); err != nil {
logger.Errorf("failed to unwrap transaction CBOR: %s", err)
c.Data(400, "application/json", []byte(fmt.Sprintf("failed to unwrap transaction CBOR: %s", err)))
_ = ginmetrics.GetMonitor().GetMetric("tx_failure_count").Inc(nil)
_ = ginmetrics.GetMonitor().GetMetric("tx_submit_fail_count").Inc(nil)
return
}
// index 0 is the transaction body
Expand Down Expand Up @@ -188,21 +188,21 @@ func handleSubmitTx(c *gin.Context) {
if err != nil {
logger.Errorf("failure creating Ouroboros connection: %s", err)
c.Data(500, "application/json", []byte("failure communicating with node"))
_ = ginmetrics.GetMonitor().GetMetric("tx_failure_count").Inc(nil)
_ = ginmetrics.GetMonitor().GetMetric("tx_submit_fail_count").Inc(nil)
return
}
if cfg.Node.Address != "" && cfg.Node.Port > 0 {
if err := oConn.Dial("tcp", fmt.Sprintf("%s:%d", cfg.Node.Address, cfg.Node.Port)); err != nil {
logger.Errorf("failure connecting to node via TCP: %s", err)
c.Data(500, "application/json", []byte("failure communicating with node"))
_ = ginmetrics.GetMonitor().GetMetric("tx_failure_count").Inc(nil)
_ = ginmetrics.GetMonitor().GetMetric("tx_submit_fail_count").Inc(nil)
return
}
} else {
if err := oConn.Dial("unix", cfg.Node.SocketPath); err != nil {
logger.Errorf("failure connecting to node via UNIX socket: %s", err)
c.Data(500, "application/json", []byte("failure communicating with node"))
_ = ginmetrics.GetMonitor().GetMetric("tx_failure_count").Inc(nil)
_ = ginmetrics.GetMonitor().GetMetric("tx_submit_fail_count").Inc(nil)
return
}
}
Expand All @@ -212,7 +212,7 @@ func handleSubmitTx(c *gin.Context) {
if ok {
logger.Errorf("failure communicating with node: %s", err)
c.Data(500, "application/json", []byte("failure communicating with node"))
_ = ginmetrics.GetMonitor().GetMetric("tx_failure_count").Inc(nil)
_ = ginmetrics.GetMonitor().GetMetric("tx_submit_fail_count").Inc(nil)
doneChan <- true
}
}()
Expand All @@ -235,7 +235,7 @@ func handleSubmitTx(c *gin.Context) {
}
doneChan <- true
// Increment custom metric
_ = ginmetrics.GetMonitor().GetMetric("tx_failure_count").Inc(nil)
_ = ginmetrics.GetMonitor().GetMetric("tx_submit_fail_count").Inc(nil)
return nil
},
}
Expand Down