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
5f117ec1
Unverified
Commit
5f117ec1
authored
Oct 06, 2023
by
Sabnock01
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
generalize metrics defs
parent
0d643f0c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
97 deletions
+51
-97
main.go
op-batcher/cmd/main.go
+2
-1
cmd.go
op-node/cmd/doc/cmd.go
+0
-54
main.go
op-node/cmd/main.go
+2
-2
main.go
op-proposer/cmd/main.go
+2
-1
cmd.go
op-service/metrics/doc/cmd.go
+45
-39
No files found.
op-batcher/cmd/main.go
View file @
5f117ec1
...
...
@@ -8,6 +8,7 @@ import (
"github.com/ethereum-optimism/optimism/op-batcher/batcher"
"github.com/ethereum-optimism/optimism/op-batcher/flags"
"github.com/ethereum-optimism/optimism/op-batcher/metrics"
oplog
"github.com/ethereum-optimism/optimism/op-service/log"
"github.com/ethereum-optimism/optimism/op-service/metrics/doc"
"github.com/ethereum/go-ethereum/log"
...
...
@@ -32,7 +33,7 @@ func main() {
app
.
Commands
=
[]
*
cli
.
Command
{
{
Name
:
"doc"
,
Subcommands
:
doc
.
Subcommands
,
Subcommands
:
doc
.
NewSubcommands
(
metrics
.
NewMetrics
(
"default"
))
,
},
}
...
...
op-node/cmd/doc/cmd.go
deleted
100644 → 0
View file @
0d643f0c
package
doc
import
(
"encoding/json"
"fmt"
"os"
"strings"
"github.com/ethereum-optimism/optimism/op-node/metrics"
"github.com/olekukonko/tablewriter"
"github.com/urfave/cli/v2"
)
var
Subcommands
=
cli
.
Commands
{
{
Name
:
"metrics"
,
Usage
:
"Dumps a list of supported metrics to stdout"
,
Flags
:
[]
cli
.
Flag
{
&
cli
.
StringFlag
{
Name
:
"format"
,
Value
:
"markdown"
,
Usage
:
"Output format (json|markdown)"
,
},
},
Action
:
func
(
ctx
*
cli
.
Context
)
error
{
m
:=
metrics
.
NewMetrics
(
"default"
)
supportedMetrics
:=
m
.
Document
()
format
:=
ctx
.
String
(
"format"
)
if
format
!=
"markdown"
&&
format
!=
"json"
{
return
fmt
.
Errorf
(
"invalid format: %s"
,
format
)
}
if
format
==
"json"
{
enc
:=
json
.
NewEncoder
(
os
.
Stdout
)
return
enc
.
Encode
(
supportedMetrics
)
}
table
:=
tablewriter
.
NewWriter
(
os
.
Stdout
)
table
.
SetBorders
(
tablewriter
.
Border
{
Left
:
true
,
Top
:
false
,
Right
:
true
,
Bottom
:
false
})
table
.
SetCenterSeparator
(
"|"
)
table
.
SetAutoWrapText
(
false
)
table
.
SetHeader
([]
string
{
"Metric"
,
"Description"
,
"Labels"
,
"Type"
})
var
data
[][]
string
for
_
,
metric
:=
range
supportedMetrics
{
labels
:=
strings
.
Join
(
metric
.
Labels
,
","
)
data
=
append
(
data
,
[]
string
{
metric
.
Name
,
metric
.
Help
,
labels
,
metric
.
Type
})
}
table
.
AppendBulk
(
data
)
table
.
Render
()
return
nil
},
},
}
op-node/cmd/main.go
View file @
5f117ec1
...
...
@@ -7,7 +7,7 @@ import (
"strconv"
"github.com/ethereum-optimism/optimism/op-node/chaincfg"
"github.com/ethereum-optimism/optimism/op-
node/cmd
/doc"
"github.com/ethereum-optimism/optimism/op-
service/metrics
/doc"
"github.com/urfave/cli/v2"
...
...
@@ -70,7 +70,7 @@ func main() {
},
{
Name
:
"doc"
,
Subcommands
:
doc
.
Subcommands
,
Subcommands
:
doc
.
NewSubcommands
(
metrics
.
NewMetrics
(
"default"
))
,
},
}
...
...
op-proposer/cmd/main.go
View file @
5f117ec1
...
...
@@ -7,6 +7,7 @@ import (
"github.com/urfave/cli/v2"
"github.com/ethereum-optimism/optimism/op-proposer/flags"
"github.com/ethereum-optimism/optimism/op-proposer/metrics"
"github.com/ethereum-optimism/optimism/op-proposer/proposer"
oplog
"github.com/ethereum-optimism/optimism/op-service/log"
"github.com/ethereum-optimism/optimism/op-service/metrics/doc"
...
...
@@ -32,7 +33,7 @@ func main() {
app
.
Commands
=
[]
*
cli
.
Command
{
{
Name
:
"doc"
,
Subcommands
:
doc
.
Subcommands
,
Subcommands
:
doc
.
NewSubcommands
(
metrics
.
NewMetrics
(
"default"
))
,
},
}
...
...
op-service/metrics/doc/cmd.go
View file @
5f117ec1
...
...
@@ -6,12 +6,18 @@ import (
"os"
"strings"
"github.com/ethereum-optimism/optimism/op-node/metrics"
"github.com/olekukonko/tablewriter"
"github.com/urfave/cli/v2"
"github.com/ethereum-optimism/optimism/op-service/metrics"
)
var
Subcommands
=
cli
.
Commands
{
type
Metrics
interface
{
Document
()
[]
metrics
.
DocumentedMetric
}
func
NewSubcommands
(
m
Metrics
)
cli
.
Commands
{
return
cli
.
Commands
{
{
Name
:
"metrics"
,
Usage
:
"Dumps a list of supported metrics to stdout"
,
...
...
@@ -23,7 +29,6 @@ var Subcommands = cli.Commands{
},
},
Action
:
func
(
ctx
*
cli
.
Context
)
error
{
m
:=
metrics
.
NewMetrics
(
"default"
)
supportedMetrics
:=
m
.
Document
()
format
:=
ctx
.
String
(
"format"
)
...
...
@@ -51,4 +56,5 @@ var Subcommands = cli.Commands{
return
nil
},
},
}
}
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