Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
8c7efbb0
Commit
8c7efbb0
authored
Jul 14, 2023
by
Felipe Andrade
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
metric with error details
parent
98ca6d4e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
+14
-0
metrics.go
op-ufm/pkg/metrics/metrics.go
+13
-0
roundtrip.go
op-ufm/pkg/provider/roundtrip.go
+1
-0
No files found.
op-ufm/pkg/metrics/metrics.go
View file @
8c7efbb0
package
metrics
import
(
fmt
"fmt"
"regexp"
"strings"
"time"
"github.com/ethereum/go-ethereum/log"
...
...
@@ -77,6 +80,8 @@ var (
})
)
var
nonAlphanumericRegex
=
regexp
.
MustCompile
(
`[^a-zA-Z ]+`
)
func
RecordError
(
provider
string
,
errorLabel
string
)
{
if
Debug
{
log
.
Debug
(
"metric inc"
,
"m"
,
"errors_total"
,
...
...
@@ -85,6 +90,14 @@ func RecordError(provider string, errorLabel string) {
errorsTotal
.
WithLabelValues
(
provider
,
errorLabel
)
.
Inc
()
}
// RecordErrorDetails concats the error message to the label removing non-alpha chars
func
RecordErrorDetails
(
provider
string
,
label
string
,
err
error
)
{
errClean
:=
nonAlphanumericRegex
.
ReplaceAllString
(
err
.
Error
(),
""
)
errClean
=
strings
.
ReplaceAll
(
errClean
,
" "
,
"_"
)
label
=
fmt
.
Sprintf
(
"%s.%s"
,
label
)
RecordError
(
provider
,
label
)
}
func
RecordRPCLatency
(
provider
string
,
client
string
,
method
string
,
latency
time
.
Duration
)
{
if
Debug
{
log
.
Debug
(
"metric set"
,
"m"
,
"rpc_latency"
,
...
...
op-ufm/pkg/provider/roundtrip.go
View file @
8c7efbb0
...
...
@@ -70,6 +70,7 @@ func (p *Provider) RoundTrip(ctx context.Context) {
}
}
else
{
log
.
Error
(
"cant send transaction"
,
"provider"
,
p
.
name
,
"err"
,
err
)
metrics
.
RecordErrorDetails
(
p
.
name
,
"ethclient.SendTransaction"
,
err
)
return
}
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment