forked from ava-labs/avalanchego
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add additional consensus metrics (ava-labs#1877)
Co-authored-by: Stephen Buttolph <[email protected]>
- Loading branch information
1 parent
32040ca
commit 9cb5b46
Showing
10 changed files
with
160 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (C) 2019-2022, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
package metrics | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/prometheus/client_golang/prometheus" | ||
) | ||
|
||
var _ Timestamp = ×tamp{} | ||
|
||
// Timestamp reports the last accepted block time, | ||
// to track it in unix seconds. | ||
type Timestamp interface { | ||
Accepted(ts time.Time) | ||
} | ||
|
||
type timestamp struct { | ||
// lastAcceptedTimestamp keeps track of the last accepted timestamp | ||
lastAcceptedTimestamp prometheus.Gauge | ||
} | ||
|
||
func NewTimestamp(namespace string, reg prometheus.Registerer) (Timestamp, error) { | ||
t := ×tamp{ | ||
lastAcceptedTimestamp: prometheus.NewGauge(prometheus.GaugeOpts{ | ||
Namespace: namespace, | ||
Name: "last_accepted_timestamp", | ||
Help: "Last accepted block timestamp in unix seconds", | ||
}), | ||
} | ||
return t, reg.Register(t.lastAcceptedTimestamp) | ||
} | ||
|
||
func (t *timestamp) Accepted(ts time.Time) { | ||
t.lastAcceptedTimestamp.Set(float64(ts.Unix())) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.