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
05ec0bc0
Unverified
Commit
05ec0bc0
authored
Oct 13, 2023
by
protolambda
Committed by
GitHub
Oct 13, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7519 from Sabnock01/sabnock/issue-6741
chore: op-service metrics cleanup
parents
b88fd77a
837a5de7
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
73 additions
and
174 deletions
+73
-174
cmd.go
op-batcher/cmd/doc/cmd.go
+0
-54
main.go
op-batcher/cmd/main.go
+3
-2
cmd.go
op-node/cmd/doc/cmd.go
+0
-54
main.go
op-node/cmd/main.go
+2
-2
metrics.go
op-node/metrics/metrics.go
+4
-4
cmd.go
op-proposer/cmd/doc/cmd.go
+0
-54
main.go
op-proposer/cmd/main.go
+3
-2
caching.go
op-service/metrics/caching.go
+1
-2
cmd.go
op-service/metrics/doc/cmd.go
+60
-0
No files found.
op-batcher/cmd/doc/cmd.go
deleted
100644 → 0
View file @
b88fd77a
package
doc
import
(
"encoding/json"
"fmt"
"os"
"strings"
"github.com/ethereum-optimism/optimism/op-batcher/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-batcher/cmd/main.go
View file @
05ec0bc0
...
@@ -7,10 +7,11 @@ import (
...
@@ -7,10 +7,11 @@ import (
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v2"
"github.com/ethereum-optimism/optimism/op-batcher/batcher"
"github.com/ethereum-optimism/optimism/op-batcher/batcher"
"github.com/ethereum-optimism/optimism/op-batcher/cmd/doc"
"github.com/ethereum-optimism/optimism/op-batcher/flags"
"github.com/ethereum-optimism/optimism/op-batcher/flags"
"github.com/ethereum-optimism/optimism/op-batcher/metrics"
"github.com/ethereum-optimism/optimism/op-service/cliapp"
"github.com/ethereum-optimism/optimism/op-service/cliapp"
oplog
"github.com/ethereum-optimism/optimism/op-service/log"
oplog
"github.com/ethereum-optimism/optimism/op-service/log"
"github.com/ethereum-optimism/optimism/op-service/metrics/doc"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
)
)
...
@@ -33,7 +34,7 @@ func main() {
...
@@ -33,7 +34,7 @@ func main() {
app
.
Commands
=
[]
*
cli
.
Command
{
app
.
Commands
=
[]
*
cli
.
Command
{
{
{
Name
:
"doc"
,
Name
:
"doc"
,
Subcommands
:
doc
.
Subcommands
,
Subcommands
:
doc
.
NewSubcommands
(
metrics
.
NewMetrics
(
"default"
))
,
},
},
}
}
...
...
op-node/cmd/doc/cmd.go
deleted
100644 → 0
View file @
b88fd77a
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 @
05ec0bc0
...
@@ -11,7 +11,6 @@ import (
...
@@ -11,7 +11,6 @@ import (
opnode
"github.com/ethereum-optimism/optimism/op-node"
opnode
"github.com/ethereum-optimism/optimism/op-node"
"github.com/ethereum-optimism/optimism/op-node/chaincfg"
"github.com/ethereum-optimism/optimism/op-node/chaincfg"
"github.com/ethereum-optimism/optimism/op-node/cmd/doc"
"github.com/ethereum-optimism/optimism/op-node/cmd/genesis"
"github.com/ethereum-optimism/optimism/op-node/cmd/genesis"
"github.com/ethereum-optimism/optimism/op-node/cmd/p2p"
"github.com/ethereum-optimism/optimism/op-node/cmd/p2p"
"github.com/ethereum-optimism/optimism/op-node/flags"
"github.com/ethereum-optimism/optimism/op-node/flags"
...
@@ -21,6 +20,7 @@ import (
...
@@ -21,6 +20,7 @@ import (
opservice
"github.com/ethereum-optimism/optimism/op-service"
opservice
"github.com/ethereum-optimism/optimism/op-service"
"github.com/ethereum-optimism/optimism/op-service/cliapp"
"github.com/ethereum-optimism/optimism/op-service/cliapp"
oplog
"github.com/ethereum-optimism/optimism/op-service/log"
oplog
"github.com/ethereum-optimism/optimism/op-service/log"
"github.com/ethereum-optimism/optimism/op-service/metrics/doc"
)
)
var
(
var
(
...
@@ -66,7 +66,7 @@ func main() {
...
@@ -66,7 +66,7 @@ func main() {
},
},
{
{
Name
:
"doc"
,
Name
:
"doc"
,
Subcommands
:
doc
.
Subcommands
,
Subcommands
:
doc
.
NewSubcommands
(
metrics
.
NewMetrics
(
"default"
))
,
},
},
}
}
...
...
op-node/metrics/metrics.go
View file @
05ec0bc0
...
@@ -82,8 +82,8 @@ type Metrics struct {
...
@@ -82,8 +82,8 @@ type Metrics struct {
metrics
.
RPCMetrics
metrics
.
RPCMetrics
L1SourceCache
*
CacheMetrics
L1SourceCache
*
metrics
.
CacheMetrics
L2SourceCache
*
CacheMetrics
L2SourceCache
*
metrics
.
CacheMetrics
DerivationIdle
prometheus
.
Gauge
DerivationIdle
prometheus
.
Gauge
...
@@ -177,8 +177,8 @@ func NewMetrics(procName string) *Metrics {
...
@@ -177,8 +177,8 @@ func NewMetrics(procName string) *Metrics {
RPCMetrics
:
metrics
.
MakeRPCMetrics
(
ns
,
factory
),
RPCMetrics
:
metrics
.
MakeRPCMetrics
(
ns
,
factory
),
L1SourceCache
:
NewCacheMetrics
(
factory
,
ns
,
"l1_source_cache"
,
"L1 Source cache"
),
L1SourceCache
:
metrics
.
NewCacheMetrics
(
factory
,
ns
,
"l1_source_cache"
,
"L1 Source cache"
),
L2SourceCache
:
NewCacheMetrics
(
factory
,
ns
,
"l2_source_cache"
,
"L2 Source cache"
),
L2SourceCache
:
metrics
.
NewCacheMetrics
(
factory
,
ns
,
"l2_source_cache"
,
"L2 Source cache"
),
DerivationIdle
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
DerivationIdle
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Namespace
:
ns
,
...
...
op-proposer/cmd/doc/cmd.go
deleted
100644 → 0
View file @
b88fd77a
package
doc
import
(
"encoding/json"
"fmt"
"os"
"strings"
"github.com/ethereum-optimism/optimism/op-proposer/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-proposer/cmd/main.go
View file @
05ec0bc0
...
@@ -6,11 +6,12 @@ import (
...
@@ -6,11 +6,12 @@ import (
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v2"
"github.com/ethereum-optimism/optimism/op-proposer/cmd/doc"
"github.com/ethereum-optimism/optimism/op-proposer/flags"
"github.com/ethereum-optimism/optimism/op-proposer/flags"
"github.com/ethereum-optimism/optimism/op-proposer/metrics"
"github.com/ethereum-optimism/optimism/op-proposer/proposer"
"github.com/ethereum-optimism/optimism/op-proposer/proposer"
"github.com/ethereum-optimism/optimism/op-service/cliapp"
"github.com/ethereum-optimism/optimism/op-service/cliapp"
oplog
"github.com/ethereum-optimism/optimism/op-service/log"
oplog
"github.com/ethereum-optimism/optimism/op-service/log"
"github.com/ethereum-optimism/optimism/op-service/metrics/doc"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
)
)
...
@@ -33,7 +34,7 @@ func main() {
...
@@ -33,7 +34,7 @@ func main() {
app
.
Commands
=
[]
*
cli
.
Command
{
app
.
Commands
=
[]
*
cli
.
Command
{
{
{
Name
:
"doc"
,
Name
:
"doc"
,
Subcommands
:
doc
.
Subcommands
,
Subcommands
:
doc
.
NewSubcommands
(
metrics
.
NewMetrics
(
"default"
))
,
},
},
}
}
...
...
op-
nod
e/metrics/caching.go
→
op-
servic
e/metrics/caching.go
View file @
05ec0bc0
package
metrics
package
metrics
import
(
import
(
"github.com/ethereum-optimism/optimism/op-service/metrics"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus"
)
)
...
@@ -34,7 +33,7 @@ func (m *CacheMetrics) CacheGet(typeLabel string, hit bool) {
...
@@ -34,7 +33,7 @@ func (m *CacheMetrics) CacheGet(typeLabel string, hit bool) {
}
}
}
}
func
NewCacheMetrics
(
factory
metrics
.
Factory
,
ns
string
,
name
string
,
displayName
string
)
*
CacheMetrics
{
func
NewCacheMetrics
(
factory
Factory
,
ns
string
,
name
string
,
displayName
string
)
*
CacheMetrics
{
return
&
CacheMetrics
{
return
&
CacheMetrics
{
SizeVec
:
factory
.
NewGaugeVec
(
prometheus
.
GaugeOpts
{
SizeVec
:
factory
.
NewGaugeVec
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Namespace
:
ns
,
...
...
op-service/metrics/doc/cmd.go
0 → 100644
View file @
05ec0bc0
package
doc
import
(
"encoding/json"
"fmt"
"os"
"strings"
"github.com/olekukonko/tablewriter"
"github.com/urfave/cli/v2"
"github.com/ethereum-optimism/optimism/op-service/metrics"
)
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"
,
Flags
:
[]
cli
.
Flag
{
&
cli
.
StringFlag
{
Name
:
"format"
,
Value
:
"markdown"
,
Usage
:
"Output format (json|markdown)"
,
},
},
Action
:
func
(
ctx
*
cli
.
Context
)
error
{
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
},
},
}
}
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