-
Notifications
You must be signed in to change notification settings - Fork 586
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(core)move telemetry into internal folder, move metric.go in …
…separate folder for core/02-client.
- Loading branch information
1 parent
34fc6e2
commit d17c826
Showing
7 changed files
with
132 additions
and
107 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 was deleted.
Oops, something went wrong.
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,58 @@ | ||
package telemetry | ||
|
||
import ( | ||
metrics "github.com/hashicorp/go-metrics" | ||
|
||
"github.com/cosmos/cosmos-sdk/telemetry" | ||
|
||
ibcmetrics "github.com/cosmos/ibc-go/v8/modules/core/metrics" | ||
) | ||
|
||
func ReportCreateClient(clientType string) { | ||
telemetry.IncrCounterWithLabels( | ||
[]string{"ibc", "client", "create"}, | ||
1, | ||
[]metrics.Label{telemetry.NewLabel(ibcmetrics.LabelClientType, clientType)}, | ||
) | ||
} | ||
|
||
func ReportUpdateClient(foundMisbehaviour bool, clientType, clientID string) { | ||
labels := []metrics.Label{ | ||
telemetry.NewLabel(ibcmetrics.LabelClientType, clientType), | ||
telemetry.NewLabel(ibcmetrics.LabelClientID, clientID), | ||
} | ||
|
||
var updateType string | ||
if foundMisbehaviour { | ||
labels = append(labels, telemetry.NewLabel(ibcmetrics.LabelMsgType, "update")) | ||
updateType = "misbehaviour" | ||
} else { | ||
labels = append(labels, telemetry.NewLabel(ibcmetrics.LabelUpdateType, "msg")) | ||
updateType = "update" | ||
} | ||
|
||
telemetry.IncrCounterWithLabels([]string{"ibc", "client", updateType}, 1, labels) | ||
} | ||
|
||
func ReportUpgradeClient(clientType, clientID string) { | ||
telemetry.IncrCounterWithLabels( | ||
[]string{"ibc", "client", "upgrade"}, | ||
1, | ||
[]metrics.Label{ | ||
telemetry.NewLabel(ibcmetrics.LabelClientType, clientType), | ||
telemetry.NewLabel(ibcmetrics.LabelClientID, clientID), | ||
}, | ||
) | ||
} | ||
|
||
func ReportRecoverClient(clientType, subjectClientID string) { | ||
telemetry.IncrCounterWithLabels( | ||
[]string{"ibc", "client", "update"}, | ||
1, | ||
[]metrics.Label{ | ||
telemetry.NewLabel(ibcmetrics.LabelClientType, clientType), | ||
telemetry.NewLabel(ibcmetrics.LabelClientID, subjectClientID), | ||
telemetry.NewLabel(ibcmetrics.LabelUpdateType, "recovery"), | ||
}, | ||
) | ||
} |
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,44 @@ | ||
package telemetry | ||
|
||
import ( | ||
metrics "github.com/hashicorp/go-metrics" | ||
|
||
"github.com/cosmos/cosmos-sdk/telemetry" | ||
|
||
"github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" | ||
ibcmetrics "github.com/cosmos/ibc-go/v8/modules/core/metrics" | ||
) | ||
|
||
func ReportRecvPacket(packet types.Packet) { | ||
telemetry.IncrCounterWithLabels( | ||
[]string{"tx", "msg", "ibc", types.EventTypeRecvPacket}, | ||
1, | ||
addPacketLabels(packet), | ||
) | ||
} | ||
|
||
func ReportTimeoutPacket(packet types.Packet, timeoutType string) { | ||
labels := append(addPacketLabels(packet), telemetry.NewLabel(ibcmetrics.LabelTimeoutType, timeoutType)) | ||
telemetry.IncrCounterWithLabels( | ||
[]string{"ibc", "timeout", "packet"}, | ||
1, | ||
labels, | ||
) | ||
} | ||
|
||
func ReportAcknowledgePacket(packet types.Packet) { | ||
telemetry.IncrCounterWithLabels( | ||
[]string{"tx", "msg", "ibc", types.EventTypeAcknowledgePacket}, | ||
1, | ||
addPacketLabels(packet), | ||
) | ||
} | ||
|
||
func addPacketLabels(packet types.Packet) []metrics.Label { | ||
return []metrics.Label{ | ||
telemetry.NewLabel(ibcmetrics.LabelSourcePort, packet.SourcePort), | ||
telemetry.NewLabel(ibcmetrics.LabelSourceChannel, packet.SourceChannel), | ||
telemetry.NewLabel(ibcmetrics.LabelDestinationPort, packet.DestinationPort), | ||
telemetry.NewLabel(ibcmetrics.LabelDestinationChannel, packet.DestinationChannel), | ||
} | ||
} |
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
11 changes: 10 additions & 1 deletion
11
modules/core/types/metrics.go → modules/core/metrics/metrics.go
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