Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tnachen committed Feb 4, 2020
1 parent 79513fc commit 4348cba
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions docs/architecture/adr-013-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Extending `AppModuleBasic` to support registering of metrics would enable develo
type AppModuleBasic interface {
Name() string
RegisterCodec(*codec.Codec)
+ RegisterMetrics(namespace string, labelsAndValues ...string) *Metrics
RegisterMetrics(namespace string, labelsAndValues ...string) *Metrics

// genesis
DefaultGenesis() json.RawMessage
Expand All @@ -38,17 +38,19 @@ func (bm BasicManager) RegisterMetrics(appName) MetricsProvider {
}
```

Each module will could define its own `PrometheusMetrics` function:
Each module can define its own `CreateMetrics` function:

```go
type Metrics struct {
Size metrics.Guage

Transactions metrics.Counter
}

func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics {
labels := []string{}
for i := 0; i < len(labelsAndValues); i += 2 {
labels = append(labels, labelsAndValues[i])
func CreateMetrics(namespace string, labelsAndValues ...string) *Metrics {
labels := make([]string, len(labelsAndValues/2))
for i := 0; i < len(labelsAndValues); i += 2 {
labels[i/2] = labelsAndValues[i]
}
return &Metrics{
Size: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
Expand Down

0 comments on commit 4348cba

Please sign in to comment.