Skip to content

Commit

Permalink
Count the number of regions deployed to (#3948)
Browse files Browse the repository at this point in the history
* Count the number of regions deployed to

* Add test

Co-authored-by: Daniel Lee <danielylee@google.com>
  • Loading branch information
inlined and taeold committed Dec 15, 2021
1 parent a65e5f0 commit 6fd36a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/deploy/functions/release/reporter.ts
Expand Up @@ -59,8 +59,10 @@ export async function logAndTrackDeployStats(summary: Summary): Promise<void> {
let totalAborts = 0;
const reports: Array<Promise<void>> = [];

const regions = new Set<string>();
for (const result of summary.results) {
const tag = triggerTag(result.endpoint);
regions.add(result.endpoint.region);
totalTime += result.durationMs;
if (!result.error) {
totalSuccesses++;
Expand All @@ -74,6 +76,9 @@ export async function logAndTrackDeployStats(summary: Summary): Promise<void> {
}
}

const regionCountTag = regions.size < 5 ? regions.size.toString() : ">=5";
reports.push(track.track("functions_region_count", regionCountTag, 1));

const gcfv1 = summary.results.find((r) => r.endpoint.platform === "gcfv1");
const gcfv2 = summary.results.find((r) => r.endpoint.platform === "gcfv2");
const tag = gcfv1 && gcfv2 ? "v1+v2" : gcfv1 ? "v1" : "v2";
Expand Down
1 change: 1 addition & 0 deletions src/test/deploy/functions/release/reporter.spec.ts
Expand Up @@ -132,6 +132,7 @@ describe("reporter", () => {

await reporter.logAndTrackDeployStats(summary);

expect(trackStub).to.have.been.calledWith("functions_region_count", "1", 1);
expect(trackStub).to.have.been.calledWith("function_deploy_success", "v1.https", 2_000);
expect(trackStub).to.have.been.calledWith("function_deploy_failure", "v1.https", 1_000);
// Aborts aren't tracked because they would throw off timing metrics
Expand Down

0 comments on commit 6fd36a8

Please sign in to comment.