Skip to content

Commit a8ee548

Browse files
authored
chore: add telemetry reporting for packet methods (#7673)
1 parent 05efed9 commit a8ee548

File tree

2 files changed

+53
-7
lines changed

2 files changed

+53
-7
lines changed

modules/core/04-channel/v2/keeper/msg_server.go

+4
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ func (k *Keeper) Acknowledgement(ctx context.Context, msg *types.MsgAcknowledgem
226226
}
227227
}
228228

229+
defer telemetry.ReportAcknowledgePacket(msg.Packet)
230+
229231
return &types.MsgAcknowledgementResponse{Result: types.SUCCESS}, nil
230232
}
231233

@@ -265,5 +267,7 @@ func (k *Keeper) Timeout(ctx context.Context, timeout *types.MsgTimeout) (*types
265267
}
266268
}
267269

270+
defer telemetry.ReportTimeoutPacket(timeout.Packet)
271+
268272
return &types.MsgTimeoutResponse{Result: types.SUCCESS}, nil
269273
}
+49-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,56 @@
11
package telemetry
22

33
import (
4-
channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types"
4+
metrics "github.com/hashicorp/go-metrics"
5+
6+
"github.com/cosmos/cosmos-sdk/telemetry"
7+
8+
"github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types"
9+
ibcmetrics "github.com/cosmos/ibc-go/v9/modules/core/metrics"
510
)
611

7-
// ReportRecvPacket TODO: https://github.com/cosmos/ibc-go/issues/7437
8-
func ReportRecvPacket(packet channeltypesv2.Packet) {}
12+
func ReportRecvPacket(packet types.Packet) {
13+
for _, payload := range packet.Payloads {
14+
telemetry.IncrCounterWithLabels(
15+
[]string{"tx", "msg", "ibc", types.EventTypeRecvPacket},
16+
1,
17+
[]metrics.Label{
18+
telemetry.NewLabel(ibcmetrics.LabelSourcePort, payload.SourcePort),
19+
telemetry.NewLabel(ibcmetrics.LabelSourceChannel, packet.SourceChannel),
20+
telemetry.NewLabel(ibcmetrics.LabelDestinationPort, payload.DestinationPort),
21+
telemetry.NewLabel(ibcmetrics.LabelDestinationChannel, packet.DestinationChannel),
22+
},
23+
)
24+
}
25+
}
926

10-
// ReportTimeoutPacket TODO: https://github.com/cosmos/ibc-go/issues/7437
11-
func ReportTimeoutPacket(packet channeltypesv2.Packet, timeoutType string) {}
27+
func ReportTimeoutPacket(packet types.Packet) {
28+
for _, payload := range packet.Payloads {
29+
telemetry.IncrCounterWithLabels(
30+
[]string{"ibc", "timeout", "packet"},
31+
1,
32+
[]metrics.Label{
33+
telemetry.NewLabel(ibcmetrics.LabelSourcePort, payload.SourcePort),
34+
telemetry.NewLabel(ibcmetrics.LabelSourceChannel, packet.SourceChannel),
35+
telemetry.NewLabel(ibcmetrics.LabelDestinationPort, payload.DestinationPort),
36+
telemetry.NewLabel(ibcmetrics.LabelDestinationChannel, packet.DestinationChannel),
37+
telemetry.NewLabel(ibcmetrics.LabelTimeoutType, "height"),
38+
},
39+
)
40+
}
41+
}
1242

13-
// ReportAcknowledgePacket TODO: https://github.com/cosmos/ibc-go/issues/7437
14-
func ReportAcknowledgePacket(packet channeltypesv2.Packet) {}
43+
func ReportAcknowledgePacket(packet types.Packet) {
44+
for _, payload := range packet.Payloads {
45+
telemetry.IncrCounterWithLabels(
46+
[]string{"tx", "msg", "ibc", types.EventTypeAcknowledgePacket},
47+
1,
48+
[]metrics.Label{
49+
telemetry.NewLabel(ibcmetrics.LabelSourcePort, payload.SourcePort),
50+
telemetry.NewLabel(ibcmetrics.LabelSourceChannel, packet.SourceChannel),
51+
telemetry.NewLabel(ibcmetrics.LabelDestinationPort, payload.DestinationPort),
52+
telemetry.NewLabel(ibcmetrics.LabelDestinationChannel, packet.DestinationChannel),
53+
},
54+
)
55+
}
56+
}

0 commit comments

Comments
 (0)