Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add engine-switching related metrics #962

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions components/prometheus/metrics_accounts.go
Original file line number Diff line number Diff line change
@@ -1,35 +1,16 @@
package prometheus

import (
"time"

"github.com/iotaledger/hive.go/runtime/event"
"github.com/iotaledger/iota-core/components/prometheus/collector"
"github.com/iotaledger/iota-core/pkg/protocol/engine/blocks"
)

const (
accountNamespace = "account"

credits = "credits"
activeSeats = "active_seats"
)

var AccountMetrics = collector.NewCollection(accountNamespace,
collector.WithMetric(collector.NewMetric(credits,
collector.WithType(collector.Gauge),
collector.WithHelp("Credits per Account."),
collector.WithLabels("account"),
collector.WithPruningDelay(10*time.Minute),
collector.WithInitFunc(func() {
deps.Protocol.Events.Engine.BlockGadget.BlockAccepted.Hook(func(block *blocks.Block) {
accountData, exists, _ := deps.Protocol.Engines.Main.Get().Ledger.Account(block.IssuerID(), deps.Protocol.Engines.Main.Get().SyncManager.LatestCommitment().Slot())
if exists {
deps.Collector.Update(accountNamespace, credits, float64(accountData.Credits().Value()), accountData.ID().String())
}
}, event.WithWorkerPool(Component.WorkerPool))
}),
)),
collector.WithMetric(collector.NewMetric(activeSeats,
collector.WithType(collector.Gauge),
collector.WithHelp("Seats seen as active by the node."),
Expand Down
33 changes: 33 additions & 0 deletions components/prometheus/metrics_commitments.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/iotaledger/hive.go/runtime/event"
"github.com/iotaledger/iota-core/components/prometheus/collector"
"github.com/iotaledger/iota-core/pkg/protocol"
"github.com/iotaledger/iota-core/pkg/protocol/engine"
"github.com/iotaledger/iota-core/pkg/protocol/engine/notarization"
iotago "github.com/iotaledger/iota.go/v4"
)
Expand All @@ -20,6 +21,9 @@ const (
acceptedBlocks = "accepted_blocks"
transactions = "accepted_transactions"
validators = "active_validators"
activeChainsCount = "active_chains_count"
seenChainsCount = "seen_chains_count"
spawnedEnginesCount = "spawned_engines_count"
)

var CommitmentsMetrics = collector.NewCollection(commitmentsNamespace,
Expand Down Expand Up @@ -54,6 +58,35 @@ var CommitmentsMetrics = collector.NewCollection(commitmentsNamespace,
})
}),
)),
collector.WithMetric(collector.NewMetric(spawnedEnginesCount,
collector.WithType(collector.Counter),
collector.WithHelp("Number spawned engines since the node started."),
collector.WithInitFunc(func() {
deps.Protocol.Chains.WithInitializedEngines(func(_ *protocol.Chain, _ *engine.Engine) (shutdown func()) {
Component.WorkerPool.Submit(func() { deps.Collector.Increment(commitmentsNamespace, spawnedEnginesCount) })

return nil
})
}),
)),
collector.WithMetric(collector.NewMetric(seenChainsCount,
collector.WithType(collector.Counter),
collector.WithHelp("Number chains seen since the node started."),
collector.WithInitFunc(func() {
deps.Protocol.Chains.WithElements(func(_ *protocol.Chain) (teardown func()) {
Component.WorkerPool.Submit(func() { deps.Collector.Increment(commitmentsNamespace, seenChainsCount) })

return nil
})
}),
)),
collector.WithMetric(collector.NewMetric(activeChainsCount,
collector.WithType(collector.Gauge),
collector.WithHelp("Number currently active chains."),
collector.WithCollectFunc(func() (metricValue float64, labelValues []string) {
return float64(deps.Protocol.Chains.Size()), nil
}),
)),
collector.WithMetric(collector.NewMetric(acceptedBlocks,
collector.WithType(collector.Gauge),
collector.WithHelp("Number of accepted blocks by the node per slot."),
Expand Down
10 changes: 6 additions & 4 deletions components/prometheus/metrics_conflicts.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ var ConflictMetrics = collector.NewCollection(conflictNamespace,
collector.WithType(collector.Counter),
collector.WithHelp("Number of resolved (accepted) conflicts"),
collector.WithInitFunc(func() {
//nolint:revive
deps.Protocol.Events.Engine.SpendDAG.SpenderAccepted.Hook(func(spendID iotago.TransactionID) {
deps.Protocol.Events.Engine.SpendDAG.SpenderAccepted.Hook(func(_ iotago.TransactionID) {
deps.Collector.Increment(conflictNamespace, resolvedConflictCount)
}, event.WithWorkerPool(Component.WorkerPool))

deps.Protocol.Events.Engine.SpendDAG.SpenderRejected.Hook(func(_ iotago.TransactionID) {
deps.Collector.Increment(conflictNamespace, resolvedConflictCount)
}, event.WithWorkerPool(Component.WorkerPool))
}),
Expand All @@ -47,8 +50,7 @@ var ConflictMetrics = collector.NewCollection(conflictNamespace,
collector.WithType(collector.Counter),
collector.WithHelp("Number of created conflicts"),
collector.WithInitFunc(func() {
//nolint:revive
deps.Protocol.Events.Engine.SpendDAG.SpenderCreated.Hook(func(spendID iotago.TransactionID) {
deps.Protocol.Events.Engine.SpendDAG.SpenderCreated.Hook(func(_ iotago.TransactionID) {
deps.Collector.Increment(conflictNamespace, allConflictCounts)
}, event.WithWorkerPool(Component.WorkerPool))
}),
Expand Down
1 change: 0 additions & 1 deletion components/prometheus/metrics_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
const (
infoNamespace = "info"

appName = "app"
nodeOS = "node_os"
syncStatus = "sync_status"
memUsage = "memory_usage_bytes"
Expand Down
20 changes: 9 additions & 11 deletions components/prometheus/metrics_slots.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@ import (
)

const (
slotNamespace = "slots"
slotLabelName = "slot"
metricEvictionOffset = 6
totalBlocks = "total_blocks"
acceptedBlocksInSlot = "accepted_blocks"
invalidBlocks = "invalid_blocks"
subjectivelyInvalidBlocks = "subjectively_invalid_blocks"
acceptedAttachments = "accepted_attachments"
createdConflicts = "created_conflicts"
acceptedConflicts = "accepted_conflicts"
rejectedConflicts = "rejected_conflicts"
slotNamespace = "slots"
slotLabelName = "slot"
totalBlocks = "total_blocks"
acceptedBlocksInSlot = "accepted_blocks"
invalidBlocks = "invalid_blocks"
acceptedAttachments = "accepted_attachments"
createdConflicts = "created_conflicts"
acceptedConflicts = "accepted_conflicts"
rejectedConflicts = "rejected_conflicts"
)

var SlotMetrics = collector.NewCollection(slotNamespace,
Expand Down
Loading
Loading