-
Notifications
You must be signed in to change notification settings - Fork 616
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
refactor(core)!: move telemetry into internal folder #6763
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d17c826
refactor(core)move telemetry into internal folder, move metric.go in …
DimitrisJim 72d4205
add changelog entry.
DimitrisJim 1260f26
chore: msg_server.go -> packet.go
DimitrisJim f3066ef
Merge branch 'main' into jim/internal-telemetry-core
DimitrisJim f43d742
Merge branch 'main' into jim/internal-telemetry-core
DimitrisJim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
DimitrisJim marked this conversation as resolved.
Show resolved
Hide resolved
|
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add doc strings to all these public functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That might be nice. In case someone is wondering if they should use them or not, a bit of explanation on how and when they are supposed to be used.
Potentially a small text or readme even on how we use telemetry?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mentioned in other PR that completely indifferent to docu strings considering they are internal use only. A small description on telemetry usage would be nice though I am still not entirely sure who consumes these atm.