diff --git a/packages/opentelemetry-resource-util/src/detector/gae.ts b/packages/opentelemetry-resource-util/src/detector/gae.ts index 9268990a..ad6ddd23 100644 --- a/packages/opentelemetry-resource-util/src/detector/gae.ts +++ b/packages/opentelemetry-resource-util/src/detector/gae.ts @@ -76,7 +76,9 @@ export async function flexAvailabilityZoneAndRegion(): Promise<{ * true before calling this, or it may throw exceptions. */ export async function standardAvailabilityZone(): Promise { - return await metadata.instance(ZONE_METADATA_ATTR); + const zone = await metadata.instance(ZONE_METADATA_ATTR); + // zone is of the form "projects/233510669999/zones/us15" + return zone.slice(zone.lastIndexOf('/') + 1); } /** diff --git a/packages/opentelemetry-resource-util/test/detector/gae.test.ts b/packages/opentelemetry-resource-util/test/detector/gae.test.ts index 551ae054..4e18d8d3 100644 --- a/packages/opentelemetry-resource-util/test/detector/gae.test.ts +++ b/packages/opentelemetry-resource-util/test/detector/gae.test.ts @@ -88,9 +88,12 @@ describe('App Engine (GAE)', () => { describe('GAE standard zone and region', () => { it('detects zone', async () => { - metadataStub.instance.withArgs('zone').resolves('us-east4-b'); + metadataStub.instance + .withArgs('zone') + .resolves('projects/233510669999/zones/us15'); + const zone = await gae.standardAvailabilityZone(); - assert.strict(zone, 'us-east4-b'); + assert.strictEqual(zone, 'us15'); }); it('detects region', async () => {