Skip to content
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

Add telemetry to our modules #441

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ localnet bin="wardend":
{{bin}} config set app minimum-gas-prices 0uward
{{bin}} config set app api.enable true
{{bin}} config set app api.enabled-unsafe-cors true
{{bin}} config set app telemetry.enabled true
{{bin}} config set config consensus.timeout_commit 1s -s
replace 's/cors_allowed_origins = \[\]/cors_allowed_origins = ["*"]/' ~/.warden/config/config.toml
{{bin}} keys add val > /dev/null
Expand Down
7 changes: 7 additions & 0 deletions warden/x/act/keeper/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/baseapp"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/warden-protocol/wardenprotocol/shield"
"github.com/warden-protocol/wardenprotocol/shield/object"
Expand Down Expand Up @@ -61,6 +62,8 @@ func (k Keeper) executeAction(ctx context.Context, act *types.Action) error {
return fmt.Errorf("unpacking Action.Msg: %w", err)
}

defer telemetry.MeasureSince(telemetry.Now(), sdk.MsgTypeURL(msg))

handler := k.router.Handler(msg)
if handler == nil {
return fmt.Errorf("no handler registered for %s", sdk.MsgTypeURL(msg))
Expand Down Expand Up @@ -149,8 +152,10 @@ func (k Keeper) AddAction(ctx context.Context, creator string, msg sdk.Msg, time
return nil, err
}

parsingTs := telemetry.Now()
ctxWithMsg := cosmoshield.NewContext(ctx, msg)
preprocessedExpr, mentions, err := k.preprocessRule(ctxWithMsg, rule)
telemetry.MeasureSince(parsingTs, "rule_preprocessing", sdk.MsgTypeURL(msg))
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -183,6 +188,8 @@ func (k Keeper) AddAction(ctx context.Context, creator string, msg sdk.Msg, time
return nil, err
}

telemetry.IncrCounter(1, "action", "count")

// try executing the action immediately
if err := k.TryExecuteAction(ctx, act); err != nil {
return nil, err
Expand Down
3 changes: 3 additions & 0 deletions warden/x/act/keeper/msg_server_approve_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/warden-protocol/wardenprotocol/warden/x/act/types/v1beta1"
)
Expand Down Expand Up @@ -40,5 +41,7 @@ func (k msgServer) ApproveAction(goCtx context.Context, msg *types.MsgApproveAct
return nil, err
}

telemetry.IncrCounter(1, "approve_action", "msg", "count")

return &types.MsgApproveActionResponse{Status: act.Status.String()}, nil
}
3 changes: 3 additions & 0 deletions warden/x/act/keeper/msg_server_new_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/warden-protocol/wardenprotocol/warden/x/act/types/v1beta1"
)
Expand All @@ -27,6 +28,8 @@ func (k msgServer) NewAction(ctx context.Context, msg *types.MsgNewAction) (*typ
}); err != nil {
return nil, err
}
telemetry.IncrCounter(1, "action", "count")

return &types.MsgNewActionResponse{
Id: act.Id,
}, nil
Expand Down
3 changes: 3 additions & 0 deletions warden/x/act/keeper/msg_server_new_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"context"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/warden-protocol/wardenprotocol/shield"
types "github.com/warden-protocol/wardenprotocol/warden/x/act/types/v1beta1"
Expand Down Expand Up @@ -38,6 +39,8 @@ func (k msgServer) NewRule(goCtx context.Context, msg *types.MsgNewRule) (*types
return nil, err
}

telemetry.IncrCounter(1, "new_rule", "msg", "count")

return &types.MsgNewRuleResponse{
Id: id,
}, nil
Expand Down
3 changes: 3 additions & 0 deletions warden/x/act/keeper/msg_server_revoke_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/warden-protocol/wardenprotocol/warden/x/act/types/v1beta1"
)
Expand Down Expand Up @@ -32,5 +33,7 @@ func (k msgServer) RevokeAction(goCtx context.Context, msg *types.MsgRevokeActio
return nil, err
}

telemetry.IncrCounter(1, "revoke_action", "msg", "count")

return &types.MsgRevokeActionResponse{}, nil
}
3 changes: 3 additions & 0 deletions warden/x/act/keeper/msg_server_update_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
"context"
"github.com/cosmos/cosmos-sdk/telemetry"

errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -19,5 +20,7 @@ func (k msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParam
return nil, err
}

telemetry.IncrCounter(1, "intent", "update_params", "msg", "count")

return &types.MsgUpdateParamsResponse{}, nil
}
3 changes: 3 additions & 0 deletions warden/x/act/keeper/msg_server_update_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/warden-protocol/wardenprotocol/shield"
Expand Down Expand Up @@ -43,5 +44,7 @@ func (k msgServer) UpdateRule(ctx context.Context, msg *types.MsgUpdateRule) (*t
return nil, err
}

telemetry.IncrCounter(1, "update_rule", "msg", "count")

return &types.MsgUpdateRuleResponse{}, nil
}
3 changes: 3 additions & 0 deletions warden/x/ibctransfer/keeper/ibctransfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
storetypes "cosmossdk.io/store/types"
"fmt"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper"
Expand Down Expand Up @@ -47,6 +48,8 @@ func (k Keeper) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types.
gmpKeeper := *k.GmpKeeper
gmpParams := gmpKeeper.GetParams(ctx)

telemetry.IncrCounter(1, "ibc_transfer_attempt", "msg", "count")

if msg.Receiver == gmpParams.GmpAddress {
bridgeMsg := &gmptypes.MsgBridge{}
// safe byte conversion for invalid UTF-8
Expand Down
3 changes: 3 additions & 0 deletions warden/x/warden/keeper/msg_server_add_keychain_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/warden-protocol/wardenprotocol/warden/x/warden/types/v1beta2"
)
Expand Down Expand Up @@ -43,5 +44,7 @@ func (k msgServer) AddKeychainWriter(goCtx context.Context, msg *types.MsgAddKey
return nil, err
}

telemetry.IncrCounter(1, "add_keychain_writer", "msg", "count")

return &types.MsgAddKeychainWriterResponse{}, nil
}
3 changes: 3 additions & 0 deletions warden/x/warden/keeper/msg_server_add_space_owner.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"context"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/warden-protocol/wardenprotocol/warden/x/warden/types/v1beta2"
)
Expand Down Expand Up @@ -35,5 +36,7 @@ func (k msgServer) AddSpaceOwner(ctx context.Context, msg *types.MsgAddSpaceOwne
return nil, err
}

telemetry.IncrCounter(1, "add_space_owner", "msg", "count")

return &types.MsgAddSpaceOwnerResponse{}, nil
}
4 changes: 4 additions & 0 deletions warden/x/warden/keeper/msg_server_fulfil_key_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/ed25519"
"fmt"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"

types "github.com/warden-protocol/wardenprotocol/warden/x/warden/types/v1beta2"
Expand Down Expand Up @@ -79,6 +80,7 @@ func (k msgServer) FulfilKeyRequest(goCtx context.Context, msg *types.MsgFulfilK
}); err != nil {
return nil, err
}
telemetry.IncrCounter(1, "update_key_request", "msg", "count")

case types.KeyRequestStatus_KEY_REQUEST_STATUS_REJECTED:
req.Status = types.KeyRequestStatus_KEY_REQUEST_STATUS_REJECTED
Expand All @@ -94,6 +96,8 @@ func (k msgServer) FulfilKeyRequest(goCtx context.Context, msg *types.MsgFulfilK
return nil, err
}

telemetry.IncrCounter(1, "update_key_request", "msg", "count")

default:
return nil, fmt.Errorf("invalid status field, should be either fulfilled/rejected")
}
Expand Down
3 changes: 3 additions & 0 deletions warden/x/warden/keeper/msg_server_fulfil_sign_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/ed25519"
"fmt"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/warden-protocol/wardenprotocol/warden/x/warden/types/v1beta2"
)
Expand Down Expand Up @@ -69,6 +70,7 @@ func (k msgServer) FulfilSignRequest(goCtx context.Context, msg *types.MsgFulfil
return nil, err
}

telemetry.IncrCounter(1, "fulfill_signature_request", "msg", "count")
case types.SignRequestStatus_SIGN_REQUEST_STATUS_REJECTED:
req.Status = types.SignRequestStatus_SIGN_REQUEST_STATUS_REJECTED
req.Result = &types.SignRequest_RejectReason{
Expand All @@ -84,6 +86,7 @@ func (k msgServer) FulfilSignRequest(goCtx context.Context, msg *types.MsgFulfil
return nil, err
}

telemetry.IncrCounter(1, "reject_signature_request", "msg", "count")
default:
return nil, fmt.Errorf("invalid status field, should be either fulfilled/rejected")
}
Expand Down
3 changes: 3 additions & 0 deletions warden/x/warden/keeper/msg_server_new_key_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"context"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/warden-protocol/wardenprotocol/warden/x/warden/types/v1beta2"
)
Expand Down Expand Up @@ -61,6 +62,8 @@ func (k msgServer) NewKeyRequest(ctx context.Context, msg *types.MsgNewKeyReques
return nil, err
}

telemetry.IncrCounter(1, "new_key_request", "msg", "count")

return &types.MsgNewKeyRequestResponse{
Id: id,
}, nil
Expand Down
3 changes: 3 additions & 0 deletions warden/x/warden/keeper/msg_server_new_keychain.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"context"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/warden-protocol/wardenprotocol/warden/x/warden/types/v1beta2"
)
Expand Down Expand Up @@ -30,6 +31,8 @@ func (k msgServer) NewKeychain(goCtx context.Context, msg *types.MsgNewKeychain)
return nil, err
}

telemetry.IncrCounter(1, "new_keychain", "msg", "count")

return &types.MsgNewKeychainResponse{
Id: id,
}, nil
Expand Down
3 changes: 3 additions & 0 deletions warden/x/warden/keeper/msg_server_new_sign_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"context"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"

types "github.com/warden-protocol/wardenprotocol/warden/x/warden/types/v1beta2"
Expand Down Expand Up @@ -64,5 +65,7 @@ func (k msgServer) NewSignRequest(ctx context.Context, msg *types.MsgNewSignRequ
return nil, err
}

telemetry.IncrCounter(1, "new_signature_request", "msg", "count")

return &types.MsgNewSignRequestResponse{Id: id}, nil
}
3 changes: 3 additions & 0 deletions warden/x/warden/keeper/msg_server_new_space.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"context"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/warden-protocol/wardenprotocol/warden/x/warden/types/v1beta2"
)
Expand Down Expand Up @@ -40,6 +41,8 @@ func (k msgServer) NewSpace(goCtx context.Context, msg *types.MsgNewSpace) (*typ
return nil, err
}

telemetry.IncrCounter(1, "new_space", "msg", "count")

return &types.MsgNewSpaceResponse{
Id: id,
}, nil
Expand Down
3 changes: 3 additions & 0 deletions warden/x/warden/keeper/msg_server_remove_space_owner.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/warden-protocol/wardenprotocol/warden/x/warden/types/v1beta2"
)
Expand Down Expand Up @@ -37,5 +38,7 @@ func (k msgServer) RemoveSpaceOwner(ctx context.Context, msg *types.MsgRemoveSpa
return nil, err
}

telemetry.IncrCounter(1, "remove_space_owner", "msg", "count")

return &types.MsgRemoveSpaceOwnerResponse{}, nil
}
3 changes: 3 additions & 0 deletions warden/x/warden/keeper/msg_server_update_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"context"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/warden-protocol/wardenprotocol/warden/x/warden/types/v1beta2"
)
Expand Down Expand Up @@ -31,5 +32,7 @@ func (k msgServer) UpdateKey(ctx context.Context, msg *types.MsgUpdateKey) (*typ
return nil, err
}

telemetry.IncrCounter(1, "update_key", "msg", "count")

return &types.MsgUpdateKeyResponse{}, nil
}
3 changes: 3 additions & 0 deletions warden/x/warden/keeper/msg_server_update_keychain.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/warden-protocol/wardenprotocol/warden/x/warden/types/v1beta2"
)
Expand Down Expand Up @@ -37,5 +38,7 @@ func (k msgServer) UpdateKeychain(goCtx context.Context, msg *types.MsgUpdateKey
return nil, err
}

telemetry.IncrCounter(1, "update_keychain", "msg", "count")

return &types.MsgUpdateKeychainResponse{}, nil
}
3 changes: 3 additions & 0 deletions warden/x/warden/keeper/msg_server_update_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
"context"
"github.com/cosmos/cosmos-sdk/telemetry"

errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -19,5 +20,7 @@ func (k msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParam
return nil, err
}

telemetry.IncrCounter(1, "warden", "update_params", "msg", "count")

return &types.MsgUpdateParamsResponse{}, nil
}
3 changes: 3 additions & 0 deletions warden/x/warden/keeper/msg_server_update_space.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"context"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/warden-protocol/wardenprotocol/warden/x/warden/types/v1beta2"
)
Expand Down Expand Up @@ -44,6 +45,8 @@ func (k msgServer) UpdateSpace(ctx context.Context, msg *types.MsgUpdateSpace) (
return nil, err
}

telemetry.IncrCounter(1, "update_space", "msg", "count")

return &types.MsgUpdateSpaceResponse{}, nil
}

Expand Down
Loading