Skip to content

Commit 6fd36a8

Browse files
inlinedtaeold
andauthored
Count the number of regions deployed to (#3948)
* Count the number of regions deployed to * Add test Co-authored-by: Daniel Lee <danielylee@google.com>
1 parent a65e5f0 commit 6fd36a8

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/deploy/functions/release/reporter.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ export async function logAndTrackDeployStats(summary: Summary): Promise<void> {
5959
let totalAborts = 0;
6060
const reports: Array<Promise<void>> = [];
6161

62+
const regions = new Set<string>();
6263
for (const result of summary.results) {
6364
const tag = triggerTag(result.endpoint);
65+
regions.add(result.endpoint.region);
6466
totalTime += result.durationMs;
6567
if (!result.error) {
6668
totalSuccesses++;
@@ -74,6 +76,9 @@ export async function logAndTrackDeployStats(summary: Summary): Promise<void> {
7476
}
7577
}
7678

79+
const regionCountTag = regions.size < 5 ? regions.size.toString() : ">=5";
80+
reports.push(track.track("functions_region_count", regionCountTag, 1));
81+
7782
const gcfv1 = summary.results.find((r) => r.endpoint.platform === "gcfv1");
7883
const gcfv2 = summary.results.find((r) => r.endpoint.platform === "gcfv2");
7984
const tag = gcfv1 && gcfv2 ? "v1+v2" : gcfv1 ? "v1" : "v2";

src/test/deploy/functions/release/reporter.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ describe("reporter", () => {
132132

133133
await reporter.logAndTrackDeployStats(summary);
134134

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

0 commit comments

Comments
 (0)