Skip to content

Commit

Permalink
chore: fix warnings from env-schema array types
Browse files Browse the repository at this point in the history
  • Loading branch information
zone117x committed Nov 22, 2024
1 parent ba59407 commit d021baa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/api/routes/prom-metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export const SignerPromMetricsRoutes: FastifyPluginAsync<
labelNames: ['signer', 'period', 'state'] as const,
registers: [signerRegistry],
async collect() {
const blockRanges = ENV.SIGNER_PROMETHEUS_METRICS_BLOCK_PERIODS.split(',').map(Number);
const dbResults = await db.sqlTransaction(async sql => {
const blockRanges = ENV.SIGNER_PROMETHEUS_METRICS_BLOCK_PERIODS;
return await db.getRecentSignerMetrics({ sql, blockRanges });
});
this.reset();
Expand Down
6 changes: 3 additions & 3 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ const schema = Type.Object({
/** Port in which to serve the profiler */
PROFILER_PORT: Type.Number({ default: 9119 }),

SIGNER_PROMETHEUS_METRICS_BLOCK_PERIODS: Type.Array(Type.Integer(), {
default: [5, 10, 25, 100, 1000],
separator: ',',
SIGNER_PROMETHEUS_METRICS_BLOCK_PERIODS: Type.String({
pattern: '^\\d+(,\\d+)*$',
default: '5,10,25,100,1000',
}),

STACKS_NODE_RPC_HOST: Type.String(),
Expand Down
8 changes: 3 additions & 5 deletions tests/db/endpoints.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,8 @@ describe('Endpoint tests', () => {
process.env[bucketsEnvName] = buckets.join(',');
ENV.reload();

const dbMetricsResult = await db.getRecentSignerMetrics({
sql: db.sql,
blockRanges: ENV[bucketsEnvName],
});
const blockRanges = ENV[bucketsEnvName].split(',').map(Number);
const dbMetricsResult = await db.getRecentSignerMetrics({ sql: db.sql, blockRanges });
expect(dbMetricsResult).toEqual(
expect.arrayContaining([
{
Expand Down Expand Up @@ -128,7 +126,7 @@ signer_state_count{signer="0x03fc7cb917698b6137060f434988f7688520972dfb944f9b03c
const receivedLines = responseTest.text.split('\n');
expect(receivedLines).toEqual(expect.arrayContaining(expectedLines.split('\n')));

process.env[bucketsEnvName] = orig.join(',');
process.env[bucketsEnvName] = orig;
ENV.reload();
});

Expand Down

0 comments on commit d021baa

Please sign in to comment.