From e6efdba18e8ec76514c37506f81af48f31119399 Mon Sep 17 00:00:00 2001 From: Shivanee Persaud Date: Tue, 8 Sep 2026 14:23:25 -0700 Subject: [PATCH 1/3] feat(gax): attach internalMethodName to otherArgs in constructSettings --- core/packages/gax/src/gax.ts | 4 +++- core/packages/gax/test/unit/gax.ts | 9 +++++++++ core/packages/gax/test/unit/grpc-fallback.ts | 2 ++ core/packages/gax/test/unit/grpc.ts | 8 ++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/core/packages/gax/src/gax.ts b/core/packages/gax/src/gax.ts index d106516b48e..df13059072a 100644 --- a/core/packages/gax/src/gax.ts +++ b/core/packages/gax/src/gax.ts @@ -863,7 +863,9 @@ export function constructSettings( bundleOptions: bundlingConfig ? createBundleOptions(bundlingConfig) : null, - otherArgs, + otherArgs: internalTelemetryInfo || enableTelemetryTracing + ? { ...otherArgs, internalMethodName: methodName } + : otherArgs, apiName, enableTelemetryTracing, }); diff --git a/core/packages/gax/test/unit/gax.ts b/core/packages/gax/test/unit/gax.ts index 51027828120..6a414378ce5 100644 --- a/core/packages/gax/test/unit/gax.ts +++ b/core/packages/gax/test/unit/gax.ts @@ -116,6 +116,7 @@ describe('gax construct settings', () => { assert.strictEqual(settings.otherArgs, otherArgs); assert.strictEqual(settings.enableTelemetryTracing, undefined); assert.strictEqual(settings.otherArgs.internalTelemetryInfo, undefined); + assert.strictEqual(settings.otherArgs.internalMethodName, undefined); settings = defaults.pageStreamingMethod; assert.strictEqual(settings.timeout, 30000); @@ -124,6 +125,7 @@ describe('gax construct settings', () => { assert.strictEqual(settings.otherArgs, otherArgs); assert.strictEqual(settings.enableTelemetryTracing, undefined); assert.strictEqual(settings.otherArgs.internalTelemetryInfo, undefined); + assert.strictEqual(settings.otherArgs.internalMethodName, undefined); }); it('overrides settings', () => { @@ -227,6 +229,7 @@ describe('gax construct settings', () => { settings.otherArgs.internalTelemetryInfo, telemetryInfo, ); + assert.strictEqual(settings.otherArgs.internalMethodName, 'BundlingMethod'); const pageSettings = defaults.pageStreamingMethod; assert.strictEqual(pageSettings.enableTelemetryTracing, true); @@ -234,6 +237,10 @@ describe('gax construct settings', () => { pageSettings.otherArgs.internalTelemetryInfo, telemetryInfo, ); + assert.strictEqual( + pageSettings.otherArgs.internalMethodName, + 'PageStreamingMethod', + ); }); it('creates settings with internalTelemetryInfo when otherArgs is undefined', () => { @@ -258,6 +265,7 @@ describe('gax construct settings', () => { settings.otherArgs.internalTelemetryInfo, telemetryInfo, ); + assert.strictEqual(settings.otherArgs.internalMethodName, 'BundlingMethod'); }); it('creates settings with enableTelemetryTracing set to false', () => { @@ -272,6 +280,7 @@ describe('gax construct settings', () => { const settings = defaults.bundlingMethod; assert.strictEqual(settings.enableTelemetryTracing, false); assert.strictEqual(settings.otherArgs.internalTelemetryInfo, undefined); + assert.strictEqual(settings.otherArgs.internalMethodName, undefined); }); describe('CallSettings telemetry fields', () => { diff --git a/core/packages/gax/test/unit/grpc-fallback.ts b/core/packages/gax/test/unit/grpc-fallback.ts index 457bb02fed1..732c52e298d 100644 --- a/core/packages/gax/test/unit/grpc-fallback.ts +++ b/core/packages/gax/test/unit/grpc-fallback.ts @@ -253,6 +253,7 @@ describe('grpc-fallback', () => { const metadataBuilder = settings.echo.otherArgs.metadataBuilder; const headers = metadataBuilder(); assert(headers['x-goog-api-client'][0].match('grpc-web/')); + assert.strictEqual(settings.echo.otherArgs.internalMethodName, undefined); }); it('constructSettings should accept enableTelemetryTracing and internalTelemetryInfo', () => { @@ -288,6 +289,7 @@ describe('grpc-fallback', () => { settings.echo.otherArgs.internalTelemetryInfo, telemetryInfo, ); + assert.strictEqual(settings.echo.otherArgs.internalMethodName, 'Echo'); }); it('should make a request', async () => { diff --git a/core/packages/gax/test/unit/grpc.ts b/core/packages/gax/test/unit/grpc.ts index a76f1c7aa1a..76f4207053b 100644 --- a/core/packages/gax/test/unit/grpc.ts +++ b/core/packages/gax/test/unit/grpc.ts @@ -155,6 +155,10 @@ describe('grpc', () => { settings.method.otherArgs.internalTelemetryInfo, undefined, ); + assert.strictEqual( + settings.method.otherArgs.internalMethodName, + undefined, + ); }); it('constructs settings with enableTelemetryTracing and internalTelemetryInfo', () => { @@ -178,6 +182,10 @@ describe('grpc', () => { settings.method.otherArgs.internalTelemetryInfo, telemetryInfo, ); + assert.strictEqual( + settings.method.otherArgs.internalMethodName, + 'method', + ); }); }); From 5de2a7016369122406194bdfdbddfc37152a23c4 Mon Sep 17 00:00:00 2001 From: Shivanee Persaud Date: Tue, 8 Sep 2026 14:41:10 -0700 Subject: [PATCH 2/3] refactor(gax): remove internalTelemetryInfo assignment in constructSettings --- core/packages/gax/src/gax.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/core/packages/gax/src/gax.ts b/core/packages/gax/src/gax.ts index df13059072a..8a4fc2cf5c9 100644 --- a/core/packages/gax/src/gax.ts +++ b/core/packages/gax/src/gax.ts @@ -804,9 +804,6 @@ export function constructSettings( enableTelemetryTracing?: boolean, internalTelemetryInfo?: StaticTraceContext, ) { - otherArgs = internalTelemetryInfo - ? {...otherArgs, internalTelemetryInfo} - : otherArgs || {}; // eslint-disable-next-line @typescript-eslint/no-explicit-any const defaults: any = {}; From 4755d017c7e343f15db2b0ed0072eb499c90791d Mon Sep 17 00:00:00 2001 From: Shivanee Persaud Date: Tue, 8 Sep 2026 14:45:39 -0700 Subject: [PATCH 3/3] fix(gax): restore internalTelemetryInfo and format otherArgs in constructSettings --- core/packages/gax/src/gax.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/packages/gax/src/gax.ts b/core/packages/gax/src/gax.ts index 8a4fc2cf5c9..640a884f462 100644 --- a/core/packages/gax/src/gax.ts +++ b/core/packages/gax/src/gax.ts @@ -804,6 +804,9 @@ export function constructSettings( enableTelemetryTracing?: boolean, internalTelemetryInfo?: StaticTraceContext, ) { + otherArgs = internalTelemetryInfo + ? {...otherArgs, internalTelemetryInfo} + : otherArgs || {}; // eslint-disable-next-line @typescript-eslint/no-explicit-any const defaults: any = {}; @@ -860,9 +863,10 @@ export function constructSettings( bundleOptions: bundlingConfig ? createBundleOptions(bundlingConfig) : null, - otherArgs: internalTelemetryInfo || enableTelemetryTracing - ? { ...otherArgs, internalMethodName: methodName } - : otherArgs, + otherArgs: + internalTelemetryInfo || enableTelemetryTracing + ? {...otherArgs, internalMethodName: methodName} + : otherArgs, apiName, enableTelemetryTracing, });