Skip to content

Commit

Permalink
Add rpc stats
Browse files Browse the repository at this point in the history
  • Loading branch information
prevostc committed May 1, 2023
1 parent 16cd772 commit 8988f45
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/utils/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -747,5 +747,53 @@ export async function db_migrate() {
`);
}

await db_query(`
create table if not exists rpc (
rpc_id serial PRIMARY KEY,
-- the chain this rpc is for
chain chain_enum not null,
-- the rpc unique external key
rpc_key varchar UNIQUE NOT NULL,
-- rpc url where secrets are template variables
rpc_template_url varchar not null
);
`);

await db_query(`
create table if not exists rpc_call_ts (
datetime timestamptz not null,
rpc_id integer not null references rpc(rpc_id),
-- performance fields
waiting_for_lock_ms integer not null,
call_duration_ms integer not null,
-- why was this call made
reason varchar not null, -- include mode (historical, recent), importer (ppfs snapshot, investments, etc)
-- what was inside this call
json_rpc_batch_size smallint not null, -- set to zero if not a batch call
eth_getlogs_count smallint not null,
eth_call_count smallint not null,
eth_call_count smallint not null,
-- result
call_made boolean,
got_response boolean,
success_response boolean
all_success_in_batch boolean
);
SELECT create_hypertable(
relation => 'rpc_call_ts',
time_column_name => 'datetime',
chunk_time_interval => INTERVAL '1 days',
if_not_exists => true
);
`);

logger.info({ msg: "Migrate done" });
}

0 comments on commit 8988f45

Please sign in to comment.