From 9077df68a5d822db9c32645784fb5b1e8fc5c8b0 Mon Sep 17 00:00:00 2001 From: Shivanee Persaud Date: Wed, 19 Aug 2026 16:46:36 -0700 Subject: [PATCH] feat(generator): add internalTelemetryInfo configuration when enableTelemetryTracing is enabled --- .../src/$version/$service_client.ts.njk | 18 ++++++++++++++++++ .../esm/src/$version/$service_client.ts.njk | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/src/$version/$service_client.ts.njk b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/src/$version/$service_client.ts.njk index 90553e89770f..3b29f371ec01 100644 --- a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/src/$version/$service_client.ts.njk +++ b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/src/$version/$service_client.ts.njk @@ -197,6 +197,15 @@ export class {{ service.name }}Client { } {%- endif %} + {%- if api.enableTelemetryTracing %} + opts.internalTelemetryInfo = { + gcpClientService: '{{ api.loggingName }}', + gcpClientVersion: '{{ api.naming.version }}', + gcpRepo: 'googleapis/google-cloud-node', + gcpArtifact: '{{ api.publishName }}', + } + {%- endif %} + // Choose either gRPC or proto-over-HTTP implementation of google-gax. this._gaxModule = {% if not api.legacyProtoLoad %}opts.fallback ? gaxInstance.fallback : gaxInstance{% else %}gax{% endif %}; @@ -398,6 +407,15 @@ export class {{ service.name }}Client { , 'x-goog-api-version': '{{ service.apiVersion }}' {%- endif -%}}); + {%- if api.enableTelemetryTracing %} + if (opts.enableTelemetryTracing) { + for (const methodName of Object.keys(this._defaults)) { + this._defaults[methodName].enableTelemetryTracing = opts.enableTelemetryTracing; + this._defaults[methodName].internalTelemetryInfo = opts.internalTelemetryInfo; + } + } + {%- endif %} + // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code // merely providing the destination and request information. diff --git a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/src/$version/$service_client.ts.njk b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/src/$version/$service_client.ts.njk index e505db0eef11..a1a6c2c3deda 100644 --- a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/src/$version/$service_client.ts.njk +++ b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/src/$version/$service_client.ts.njk @@ -203,6 +203,15 @@ export class {{ service.name }}Client { gaxInstance = gax as typeof gax; } {%- endif %} + + {%- if api.enableTelemetryTracing %} + opts.internalTelemetryInfo = { + gcpClientService: '{{ api.loggingName }}', + gcpClientVersion: '{{ api.naming.version }}', + gcpRepo: 'googleapis/google-cloud-node', + gcpArtifact: '{{ api.publishName }}', + } + {%- endif %} // Choose either gRPC or proto-over-HTTP implementation of google-gax. this._gaxModule = {% if not api.legacyProtoLoad %}opts.fallback ? gaxInstance.fallback : gaxInstance{% else %}gax{% endif %}; @@ -409,6 +418,15 @@ export class {{ service.name }}Client { , 'x-goog-api-version': '{{ service.apiVersion }}' {%- endif %}}); + {%- if api.enableTelemetryTracing %} + if (opts.enableTelemetryTracing) { + for (const methodName of Object.keys(this._defaults)) { + this._defaults[methodName].enableTelemetryTracing = opts.enableTelemetryTracing; + this._defaults[methodName].internalTelemetryInfo = opts.internalTelemetryInfo; + } + } + {%- endif %} + // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code // merely providing the destination and request information.