Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

Commit

Permalink
Update queued_duration metric name and small changes to metric naming
Browse files Browse the repository at this point in the history
  • Loading branch information
alaczko-atlassian authored and itsjackgardner committed Feb 2, 2021
1 parent 53fc745 commit be1fa11
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async function main() {

await routes(server, client, runner);

stats.increment('.startup');
stats.increment('startup');

// TODO: lookup all admins in user service to add them to the redis cache

Expand Down
8 changes: 4 additions & 4 deletions src/lib/Runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,16 @@ export class Runner {
lockId,
});

stats.increment('.pull_request.merge.success');
const end = Date.now();
stats.increment('pull_request.merge.success');
const queuedDate = await this.getLandRequestQueuedDate(landRequest.id);
if (queuedDate) {
const start = queuedDate.getTime();
const end = Date.now();
stats.timing('.pull_request.queued_duration', end - start);
stats.timing('pull_request.queued_duration_ms', end - start);
}
return landRequest.setStatus('success');
} catch (err) {
stats.increment('.pull_request.merge.fail');
stats.increment('pull_request.merge.fail');
return landRequest.setStatus('fail', 'Unable to merge pull request');
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/lib/utils/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if (!MICROS_ENV || !MICROS_ENVTYPE || !config.metrics) {
client = new StatsD.StatsD({
host,
port,
prefix,
prefix: prefix ? `${prefix}.` : prefix,
globalTags: {
micros_env: MICROS_ENV,
micros_envtype: MICROS_ENVTYPE,
Expand Down
4 changes: 2 additions & 2 deletions src/routes/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ export function apiRoutes(runner: Runner, client: BitbucketClient, config: Confi
try {
Logger.info('Requesting current state', { namespace: 'routes:api:current-state' });
const state = await runner.getState(req.user!);
stats.increment('.get_state.success');
stats.increment('get_state.success');
res.header('Access-Control-Allow-Origin', '*').json(state);
} catch {
Logger.error('Error getting current state', { namespace: 'routes:api:current-state' });
stats.increment('.get_state.fail');
stats.increment('get_state.fail');
res.sendStatus(500);
}
}),
Expand Down
8 changes: 4 additions & 4 deletions src/routes/bitbucket/proxy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function proxyRoutes(runner: Runner, client: BitbucketClient) {
});

if (!pullRequestId || !aaid || !commit) {
stats.increment('.pull_request.queue.fail');
stats.increment('pull_request.queue.fail');

res.sendStatus(404);
return;
Expand All @@ -107,7 +107,7 @@ export function proxyRoutes(runner: Runner, client: BitbucketClient) {
landRequest,
});

stats.increment('.pull_request.queue.success');
stats.increment('pull_request.queue.success');

res.sendStatus(200);
runner.next();
Expand All @@ -125,7 +125,7 @@ export function proxyRoutes(runner: Runner, client: BitbucketClient) {
});

if (!pullRequestId || !aaid || !commit) {
stats.increment('.pull_request.queue_when_able.fail');
stats.increment('pull_request.queue_when_able.fail');

res.sendStatus(400);
return;
Expand All @@ -148,7 +148,7 @@ export function proxyRoutes(runner: Runner, client: BitbucketClient) {
landRequest,
});

stats.increment('.pull_request.queue_when_able.success');
stats.increment('pull_request.queue_when_able.success');

res.sendStatus(200);
}),
Expand Down

0 comments on commit be1fa11

Please sign in to comment.