@@ -25,6 +25,10 @@ import {GoogleError} from './googleError';
2525import { BundleOptions } from './bundlingCalls/bundleExecutor' ;
2626import { toLowerCamelCase } from './util' ;
2727import { checkTracingEnabled , checkLoggingEnabled } from './observability/util' ;
28+ import {
29+ getSettingsDefaultDomain ,
30+ setSettingsDefaultDomain ,
31+ } from './observability/contextUtil' ;
2832import { Status } from './status' ;
2933import { RequestType } from './apitypes' ;
3034
@@ -253,7 +257,12 @@ export class CallSettings {
253257 */
254258 merge ( options ?: CallOptions | null ) {
255259 if ( ! options ) {
256- return new CallSettings ( this ) ;
260+ const merged = new CallSettings ( this ) ;
261+ const defaultDomain = getSettingsDefaultDomain ( this ) ;
262+ if ( defaultDomain ) {
263+ setSettingsDefaultDomain ( merged , defaultDomain ) ;
264+ }
265+ return merged ;
257266 }
258267 let timeout = this . timeout ;
259268 let retry = this . retry ;
@@ -364,7 +373,7 @@ export class CallSettings {
364373 signal = options . signal ;
365374 }
366375
367- return new CallSettings ( {
376+ const merged = new CallSettings ( {
368377 timeout,
369378 retry,
370379 bundleOptions : this . bundleOptions ,
@@ -380,6 +389,17 @@ export class CallSettings {
380389 resumableUpload,
381390 signal,
382391 } ) ;
392+ const defaultDomain =
393+ ( options instanceof CallSettings
394+ ? getSettingsDefaultDomain ( options )
395+ : undefined ) ??
396+ ( ! ( 'apiName' in options ) || options . apiName === this . apiName
397+ ? getSettingsDefaultDomain ( this )
398+ : undefined ) ;
399+ if ( defaultDomain ) {
400+ setSettingsDefaultDomain ( merged , defaultDomain ) ;
401+ }
402+ return merged ;
383403 }
384404}
385405
@@ -869,8 +889,8 @@ export interface ClientConfig {
869889 * @param {boolean } [enableTelemetryTracing] - Flag to enable telemetry tracing
870890 * when passed in client options (or overridden by `GOOGLE_SDK_NODE_ENABLE_TRACING`).
871891 * @param {unknown } [_legacyTelemetryInfo] - Unused legacy parameter kept for backward compatibility.
872- * @param {boolean } [enableTelemetryLogging] - Flag to enable telemetry logging
873- * when passed in client options (or when `GOOGLE_SDK_NODE_LOGGING` matches the service namespace) .
892+ * @param {boolean } [enableTelemetryLogging] - Flag to enable or disable telemetry
893+ * logging for this client, taking precedence over `GOOGLE_SDK_NODE_LOGGING` when set .
874894 * @return {Object } A mapping from method name to CallSettings, or null if the
875895 * service is not found in the config.
876896 */
@@ -905,15 +925,21 @@ export function constructSettings(
905925 env . GOOGLE_SDK_NODE_EXPERIMENTAL_LOGGING ?. trim ( ) . toLowerCase ( ) ;
906926 const isExperimentalLoggingEnabled =
907927 experimentalLogging === 'true' || experimentalLogging === '1' ;
908- const isLoggingEnvEnabled = checkLoggingEnabled (
909- new CallSettings ( { apiName : serviceName } ) ,
910- ) ;
911-
928+ const isLoggingEnvEnabled =
929+ isExperimentalLoggingEnabled && enableTelemetryLogging === undefined
930+ ? checkLoggingEnabled ( new CallSettings ( { apiName : serviceName } ) )
931+ : false ;
932+ const resolvedLogging =
933+ enableTelemetryLogging !== undefined
934+ ? enableTelemetryLogging
935+ : isLoggingEnvEnabled
936+ ? true
937+ : undefined ;
912938 const loggingRequested =
913- isExperimentalLoggingEnabled &&
914- ( isLoggingEnvEnabled || Boolean ( enableTelemetryLogging ) ) ;
939+ isExperimentalLoggingEnabled && Boolean ( resolvedLogging ) ;
915940
916941 otherArgs = otherArgs || { } ;
942+
917943 // eslint-disable-next-line @typescript-eslint/no-explicit-any
918944 const defaults : any = { } ;
919945
@@ -982,9 +1008,7 @@ export function constructSettings(
9821008 apiName,
9831009 enableTelemetryTracing : isEnvSet ? isEnvEnabled : enableTelemetryTracing ,
9841010 enableTelemetryLogging : isExperimentalLoggingEnabled
985- ? isLoggingEnvEnabled
986- ? true
987- : enableTelemetryLogging
1011+ ? resolvedLogging
9881012 : enableTelemetryLogging !== undefined
9891013 ? false
9901014 : undefined ,
0 commit comments