Skip to content

Commit

Permalink
feat(cosmic-swingset): add metrics for each action type
Browse files Browse the repository at this point in the history
closes: #10883
refs: #10882
  • Loading branch information
siarhei-agoric committed Jan 28, 2025
1 parent f047c93 commit f755c9f
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion packages/cosmic-swingset/src/launch-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ export async function launch({
}
const { kernelStorage, hostStorage } =
swingStore ||
openSwingStore(/** @type {string} */ (kernelStateDBDir), {
openSwingStore(/** @type {string} */(kernelStateDBDir), {
traceFile: swingStoreTraceFile,
exportCallback: swingStoreExportSyncCallback,
keepSnapshots,
Expand All @@ -413,6 +413,35 @@ export async function launch({

// Not to be confused with the gas model, this meter is for OpenTelemetry.
const metricMeter = metricsProvider.getMeter('ag-chain-cosmos');

// Define the action types and their corresponding metric names
const actionMetrics = {
CORE_EVAL: metricMeter.createCounter('action_core_eval_total', {
description: 'Total number of CORE_EVAL actions',
}),
DELIVER_INBOUND: metricMeter.createCounter('action_deliver_inbound_total', {
description: 'Total number of DELIVER_INBOUND actions',
}),
IBC_EVENT: metricMeter.createCounter('action_ibc_event_total', {
description: 'Total number of IBC_EVENT actions',
}),
INSTALL_BUNDLE: metricMeter.createCounter('action_install_bundle_total', {
description: 'Total number of INSTALL_BUNDLE actions',
}),
PLEASE_PROVISION: metricMeter.createCounter('action_please_provision_total', {
description: 'Total number of PLEASE_PROVISION actions',
}),
VBANK_BALANCE_UPDATE: metricMeter.createCounter('action_vbank_balance_update_total', {
description: 'Total number of VBANK_BALANCE_UPDATE actions',
}),
WALLET_ACTION: metricMeter.createCounter('action_wallet_total', {
description: 'Total number of WALLET_ACTION actions',
}),
WALLET_SPEND_ACTION: metricMeter.createCounter('action_wallet_spend_total', {
description: 'Total number of WALLET_SPEND_ACTION actions',
}),
};

const slogCallbacks = makeSlogCallbacks({
metricMeter,
});
Expand Down Expand Up @@ -640,6 +669,12 @@ export async function launch({
async function performAction(action, inboundNum) {
// blockManagerConsole.error('Performing action', action);
let p;

// Increment the corresponding metric for the action type
if (actionMetrics[action.type]) {
actionMetrics[action.type].add(1);
}

switch (action.type) {
case ActionType.DELIVER_INBOUND: {
p = deliverInbound(
Expand Down

0 comments on commit f755c9f

Please sign in to comment.