Skip to content

Commit

Permalink
Fix golangci-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
MakisChristou committed Dec 18, 2024
1 parent 7ceaf29 commit 5c167fb
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions api/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ var (
}
metricHTTPReqCounter = metrics.LazyLoadCounterVec("api_request_count", []string{"name", "code", "method"})
metricHTTPReqDuration = metrics.LazyLoadHistogramVec("api_duration_ms", []string{"name", "code", "method"}, metrics.BucketHTTPReqs)
metricActiveWebsocketCount = metrics.LazyLoadGaugeVec("api_active_websocket_count", []string{"subject"})
metricTxCallVMErrors = metrics.LazyLoadCounterVec("api_tx_call_vm_errors", []string{"error"})
metricWebsocketDuration = metrics.LazyLoadHistogramVec("api_websocket_duration", []string{"name", "code"}, websocketDurations)
metricActiveWebsocketGauge = metrics.LazyLoadGaugeVec("api_active_websocket_gauge", []string{"name"})
Expand All @@ -46,7 +45,7 @@ func newMetricsResponseWriter(w http.ResponseWriter) *metricsResponseWriter {
type callTxResponseWriter struct {
http.ResponseWriter
statusCode int
vmError string
VMError string
}

func newCallTxResponseWriter(w http.ResponseWriter) *callTxResponseWriter {
Expand All @@ -60,12 +59,12 @@ func (m *metricsResponseWriter) WriteHeader(code int) {

func (c *callTxResponseWriter) Write(b []byte) (int, error) {
var resp struct {
VmError string `json:"vmError"`
VMError string `json:"VMError"`
}

if err := json.Unmarshal(b, &resp); err == nil {
if resp.VmError != "" {
c.vmError = resp.VmError
if resp.VMError != "" {
c.VMError = resp.VMError
}
}

Expand Down Expand Up @@ -107,9 +106,9 @@ func metricsMiddleware(next http.Handler) http.Handler {
next.ServeHTTP(ctxWriter, r)

// Record VM error if present
if ctxWriter.vmError != "" {
if ctxWriter.VMError != "" {
metricTxCallVMErrors().AddWithLabel(1, map[string]string{
"error": ctxWriter.vmError,
"error": ctxWriter.VMError,
})
}
return
Expand Down

0 comments on commit 5c167fb

Please sign in to comment.