diff --git a/core/packages/gax/src/gax.ts b/core/packages/gax/src/gax.ts index d106516b48e..640a884f462 100644 --- a/core/packages/gax/src/gax.ts +++ b/core/packages/gax/src/gax.ts @@ -863,7 +863,10 @@ 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', + ); }); });