-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ad7522
commit 30fcb3a
Showing
6 changed files
with
129 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package telemetry | ||
|
||
const ( | ||
LabelSender = "sender" | ||
LabelReceiver = "receiver" | ||
LabelTo = "to" | ||
LabelSuccess = "success" | ||
LabelToken = "token" | ||
) |
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,32 @@ | ||
package telemetry | ||
|
||
import ( | ||
"fmt" | ||
"math" | ||
"math/big" | ||
|
||
"github.com/armon/go-metrics" | ||
"github.com/cosmos/cosmos-sdk/telemetry" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
var maxFloat32, _ = big.NewInt(0).SetString(fmt.Sprintf("%.0f", math.MaxFloat32), 10) | ||
|
||
func SetGaugeLabelsWithToken(keys []string, token string, amount *big.Int, labels ...metrics.Label) { | ||
if amount.Cmp(maxFloat32) == 1 { | ||
return | ||
} | ||
amountFloat32, _ := new(big.Float).SetInt(amount).Float32() | ||
telemetry.SetGaugeWithLabels(append(keys, token), amountFloat32, | ||
append(labels, telemetry.NewLabel(LabelToken, token))) | ||
} | ||
|
||
func SetGaugeLabelsWithCoin(keys []string, coin sdk.Coin, labels ...metrics.Label) { | ||
SetGaugeLabelsWithToken(keys, coin.Denom, coin.Amount.BigInt(), labels...) | ||
} | ||
|
||
func SetGaugeLabelsWithCoins(keys []string, coins sdk.Coins, labels ...metrics.Label) { | ||
for _, coin := range coins { | ||
SetGaugeLabelsWithCoin(keys, coin, labels...) | ||
} | ||
} |
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 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,13 @@ | ||
package types | ||
|
||
const ( | ||
MetricsKeyBridgeCallIn = "bridge_call_in" | ||
MetricsKeyBridgeCallOut = "bridge_call_out" | ||
MetricsKeyOutgoingTx = "outgoing_tx" | ||
) | ||
|
||
const ( | ||
MetricsLabelModule = "module" | ||
MetricsLabelRefund = "refund" | ||
MetricsLabelTxOrigin = "tx_origin" | ||
) |