|
1 | 1 | package telemetry
|
2 | 2 |
|
3 | 3 | 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" |
5 | 10 | )
|
6 | 11 |
|
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 | +} |
9 | 26 |
|
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 | +} |
12 | 42 |
|
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