Skip to content

Commit c2daa4b

Browse files
committed
Populate all telemetry system configuration fields
Added helper methods to populate osArch, runtimeVendor, localeName, charSetEncoding, and processName to match JDBC implementation: - osArch: from os.arch() - runtimeVendor: 'Node.js Foundation' - localeName: from LANG env var (format: en_US) - charSetEncoding: UTF-8 (Node.js default) - processName: from process.title or script name
1 parent 43e404d commit c2daa4b

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

lib/DBSQLClient.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ export default class DBSQLClient extends EventEmitter implements IDBSQLClient, I
205205
nodeVersion: process.version,
206206
platform: process.platform,
207207
osVersion: os.release(),
208+
osArch: os.arch(),
209+
runtimeVendor: 'Node.js Foundation',
210+
localeName: this.getLocaleName(),
211+
charSetEncoding: 'UTF-8',
212+
processName: this.getProcessName(),
208213

209214
// Feature flags
210215
cloudFetchEnabled: this.config.useCloudFetch ?? false,
@@ -219,6 +224,55 @@ export default class DBSQLClient extends EventEmitter implements IDBSQLClient, I
219224
};
220225
}
221226

227+
/**
228+
* Get locale name in format language_country (e.g., en_US).
229+
* Matches JDBC format: user.language + '_' + user.country
230+
*/
231+
private getLocaleName(): string {
232+
try {
233+
// Try to get from environment variables
234+
const lang = process.env.LANG || process.env.LC_ALL || process.env.LC_MESSAGES || '';
235+
if (lang) {
236+
// LANG format is typically "en_US.UTF-8", extract "en_US"
237+
const match = lang.match(/^([a-z]{2}_[A-Z]{2})/);
238+
if (match) {
239+
return match[1];
240+
}
241+
}
242+
// Fallback to en_US
243+
return 'en_US';
244+
} catch {
245+
return 'en_US';
246+
}
247+
}
248+
249+
/**
250+
* Get process name, similar to JDBC's ProcessNameUtil.
251+
* Returns the script name or process title.
252+
*/
253+
private getProcessName(): string {
254+
try {
255+
// Try process.title first (can be set by application)
256+
if (process.title && process.title !== 'node') {
257+
return process.title;
258+
}
259+
// Try to get the main script name from argv[1]
260+
if (process.argv && process.argv.length > 1) {
261+
const scriptPath = process.argv[1];
262+
// Extract filename without path
263+
const filename = scriptPath.split('/').pop()?.split('\\').pop() || '';
264+
// Remove extension
265+
const nameWithoutExt = filename.replace(/\.[^.]*$/, '');
266+
if (nameWithoutExt) {
267+
return nameWithoutExt;
268+
}
269+
}
270+
return 'node';
271+
} catch {
272+
return 'node';
273+
}
274+
}
275+
222276
/**
223277
* Initialize telemetry components if enabled.
224278
* CRITICAL: All errors swallowed and logged at LogLevel.debug ONLY.

lib/telemetry/DatabricksTelemetryExporter.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ interface DatabricksTelemetryLog {
4848
os_arch?: string;
4949
driver_name?: string;
5050
client_app_name?: string;
51+
locale_name?: string;
52+
char_set_encoding?: string;
53+
process_name?: string;
5154
};
5255
driver_connection_params?: any;
5356
operation_latency_ms?: number;

0 commit comments

Comments
 (0)