Skip to content

Commit

Permalink
ARC-1705 Emit SLO for branch creation and failure (#1647)
Browse files Browse the repository at this point in the history
Initial checkin

Co-authored-by: Harminder <hsingh5@atlassian.com>
Co-authored-by: joshkay10 <josh.kay@outlook.com>
  • Loading branch information
3 people committed Oct 11, 2022
1 parent 566a5bc commit 0e3dd03
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/config/metric-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,8 @@ export const metricWebhooks = {
webhookLatency: `${server}.webhooks.processing-time.latency`
};

export const metricCreateBranch = {
created: `${server}.create-branch.created`,
failed: `${server}.create-branch.failed`
};

12 changes: 12 additions & 0 deletions src/routes/github/create-branch/github-create-branch-post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { Request, Response } from "express";
import { createUserClient } from "~/src/util/get-github-client-config";
import { sendAnalytics } from "utils/analytics-client";
import { AnalyticsEventTypes, AnalyticsTrackEventsEnum } from "interfaces/common";
import { statsd } from "~/src/config/statsd";
import { metricCreateBranch } from "~/src/config/metric-names";
import { getCloudOrServerFromGitHubAppId } from "~/src/util/get-cloud-or-server";

const errorMessages = {
// TODO: Fix the url later, once you figure out how to get the `installationId`
Expand Down Expand Up @@ -42,10 +45,19 @@ export const GithubCreateBranchPost = async (req: Request, res: Response): Promi
});
res.sendStatus(200);
sendTrackEventAnalytics(AnalyticsTrackEventsEnum.CreateBranchSuccessTrackEventName, jiraHost);
const tags = {
name: newBranchName,
gitHubProduct: getCloudOrServerFromGitHubAppId(gitHubAppConfig.githubAppId)
};
statsd.increment(metricCreateBranch.created, tags);
} catch (err) {
req.log.error({ err }, "Error creating branch");
res.status(err.status).json(errorMessages[err?.status || 500]);
sendTrackEventAnalytics(AnalyticsTrackEventsEnum.CreateBranchErrorTrackEventName, jiraHost);
statsd.increment(metricCreateBranch.failed, {
name: newBranchName
});

}
};

Expand Down

0 comments on commit 0e3dd03

Please sign in to comment.