Skip to content
Open
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
3 changes: 1 addition & 2 deletions sei-wasmd/x/wasm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,6 @@ func (k Keeper) QuerySmartSafe(ctx sdk.Context, contractAddr sdk.AccAddress, req
func (k Keeper) QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error) {
start := time.Now()
defer func() { recordContractQuerySmartDuration(ctx.Context(), start) }()
recordContractQuerySmartInvocation(contractAddr.String())

// checks and increase query stack size
ctx, err := checkAndIncreaseQueryStackSize(ctx, k.maxQueryStackSize)
Expand Down Expand Up @@ -690,7 +689,7 @@ func (k Keeper) QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req []b
return nil, sdkerrors.Wrap(types.ErrQueryFailed, qErr.Error())
}

recordContractQuerySmartGasUsed(ctx.Context(), contractAddr.String(), gasUsed)
recordContractQuerySmartGasUsed(ctx.Context(), gasUsed)
return queryResult, nil
}

Expand Down
36 changes: 1 addition & 35 deletions sei-wasmd/x/wasm/keeper/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import (
"context"
"time"

"github.com/armon/go-metrics"
"github.com/prometheus/client_golang/prometheus"
"github.com/sei-protocol/sei-chain/sei-cosmos/telemetry"
wasmvmtypes "github.com/sei-protocol/sei-chain/sei-wasmvm/types"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/metric"
Expand Down Expand Up @@ -88,62 +86,30 @@ func must[V any](v V, err error) V {

func recordContractInstantiateDuration(ctx context.Context, start time.Time) {
wasmKeeperMetrics.contractInstantiateDuration.Record(ctx, time.Since(start).Seconds())
// TODO(PLT-910): remove once wasm_contract_instantiate_duration verified
telemetry.MeasureSince(start, "wasm", "contract", "instantiate")
}

func recordContractExecuteDuration(ctx context.Context, start time.Time) {
wasmKeeperMetrics.contractExecuteDuration.Record(ctx, time.Since(start).Seconds())
// TODO(PLT-910): remove once wasm_contract_execute_duration verified
telemetry.MeasureSince(start, "wasm", "contract", "execute")
}

func recordContractMigrateDuration(ctx context.Context, start time.Time) {
wasmKeeperMetrics.contractMigrateDuration.Record(ctx, time.Since(start).Seconds())
// TODO(PLT-910): remove once wasm_contract_migrate_duration verified
telemetry.MeasureSince(start, "wasm", "contract", "migrate")
}

func recordContractSudoDuration(ctx context.Context, start time.Time) {
wasmKeeperMetrics.contractSudoDuration.Record(ctx, time.Since(start).Seconds())
// TODO(PLT-910): remove once wasm_contract_sudo_duration verified
telemetry.MeasureSince(start, "wasm", "contract", "sudo")
}

func recordContractQuerySmartDuration(ctx context.Context, start time.Time) {
wasmKeeperMetrics.contractQuerySmartDuration.Record(ctx, time.Since(start).Seconds())
// TODO(PLT-910): remove once wasm_contract_query_smart_duration verified
telemetry.MeasureSince(start, "wasm", "contract", "query-smart")
}

func recordContractQueryRawDuration(ctx context.Context, start time.Time) {
wasmKeeperMetrics.contractQueryRawDuration.Record(ctx, time.Since(start).Seconds())
// TODO(PLT-910): remove once wasm_contract_query_raw_duration verified
telemetry.MeasureSince(start, "wasm", "contract", "query-raw")
}

func recordContractQuerySmartInvocation(contractAddress string) {
// No OTel counter here: it would be redundant with wasm_contract_query_smart_duration's
// count, which is recorded unconditionally on every QuerySmart call just like this one.
// TODO(PLT-910): remove once wasm_contract_query_smart_duration verified
telemetry.IncrCounterWithLabels(
[]string{"wasm", "contract", "query-smart", "invocation"},
1,
[]metrics.Label{telemetry.NewLabel("contract_address", contractAddress)},
)
}

func recordContractQuerySmartGasUsed(ctx context.Context, contractAddress string, gasUsed uint64) {
// contract_address omitted on the OTel histogram: unlike the legacy Prometheus sink, the
// OTel SDK has no series expiration, so a per-contract label here would retain one series
// per distinct contract address queried for the process lifetime.
func recordContractQuerySmartGasUsed(ctx context.Context, gasUsed uint64) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[suggestion] The deleted comment carried a load-bearing constraint, not just legacy context: "the OTel SDK has no series expiration, so a per-contract label here would retain one series per distinct contract address queried for the process lifetime." That is exactly the cardinality problem this PR (CON-336/337) closes, and with the comment gone nothing stops the next change from re-adding a contract_address attribute to this histogram. Consider keeping a one-line version of the rationale on recordContractQuerySmartGasUsed (or on the contractQuerySmartGasUsed histogram definition), dropping only the reference to the removed Prometheus sink.

wasmKeeperMetrics.contractQuerySmartGasUsed.Record(ctx, int64(gasUsed)) //nolint:gosec
// TODO(PLT-910): remove once wasm_contract_query_smart_gas_used verified
telemetry.SetGaugeWithLabels(
[]string{"wasm", "contract", "query-smart", "gas-used"},
float32(gasUsed),
[]metrics.Label{telemetry.NewLabel("contract_address", contractAddress)},
)
}

const (
Expand Down
7 changes: 0 additions & 7 deletions sei-wasmd/x/wasm/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package keeper

import (
"context"
"time"

"github.com/armon/go-metrics"
sdk "github.com/sei-protocol/sei-chain/sei-cosmos/types"
sdkerrors "github.com/sei-protocol/sei-chain/sei-cosmos/types/errors"

Expand Down Expand Up @@ -85,11 +83,6 @@ func (m msgServer) ExecuteContract(goCtx context.Context, msg *types.MsgExecuteC
if err != nil {
return nil, sdkerrors.Wrap(err, "contract")
}
defer metrics.MeasureSinceWithLabels(
[]string{"wasmd", "execute", "contract", "latency"},
time.Now(),
[]metrics.Label{{Name: "contract", Value: contractAddr.String()}},
)

ctx.EventManager().EmitEvent(sdk.NewEvent(
sdk.EventTypeMessage,
Expand Down
Loading