@databricks/sql 1.14.0 → 1.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +12 -0
  2. package/dist/DBSQLClient.d.ts +99 -0
  3. package/dist/DBSQLClient.js +445 -0
  4. package/dist/DBSQLClient.js.map +1 -1
  5. package/dist/DBSQLOperation.d.ts +32 -1
  6. package/dist/DBSQLOperation.js +138 -29
  7. package/dist/DBSQLOperation.js.map +1 -1
  8. package/dist/DBSQLSession.d.ts +1 -0
  9. package/dist/DBSQLSession.js +39 -12
  10. package/dist/DBSQLSession.js.map +1 -1
  11. package/dist/connection/auth/DatabricksOAuth/OAuthManager.js +10 -6
  12. package/dist/connection/auth/DatabricksOAuth/OAuthManager.js.map +1 -1
  13. package/dist/contracts/IClientContext.d.ts +29 -0
  14. package/dist/contracts/IDBSQLClient.d.ts +84 -0
  15. package/dist/index.d.ts +2 -0
  16. package/dist/index.js +7 -3
  17. package/dist/index.js.map +1 -1
  18. package/dist/result/CloudFetchResultHandler.d.ts +8 -1
  19. package/dist/result/CloudFetchResultHandler.js +28 -2
  20. package/dist/result/CloudFetchResultHandler.js.map +1 -1
  21. package/dist/result/RowSetProvider.d.ts +8 -1
  22. package/dist/result/RowSetProvider.js +110 -1
  23. package/dist/result/RowSetProvider.js.map +1 -1
  24. package/dist/telemetry/DatabricksTelemetryExporter.js +67 -33
  25. package/dist/telemetry/DatabricksTelemetryExporter.js.map +1 -1
  26. package/dist/telemetry/FeatureFlagCache.js +10 -4
  27. package/dist/telemetry/FeatureFlagCache.js.map +1 -1
  28. package/dist/telemetry/MetricsAggregator.d.ts +38 -0
  29. package/dist/telemetry/MetricsAggregator.js +249 -14
  30. package/dist/telemetry/MetricsAggregator.js.map +1 -1
  31. package/dist/telemetry/TelemetryClient.d.ts +94 -14
  32. package/dist/telemetry/TelemetryClient.js +252 -20
  33. package/dist/telemetry/TelemetryClient.js.map +1 -1
  34. package/dist/telemetry/TelemetryClientProvider.d.ts +28 -33
  35. package/dist/telemetry/TelemetryClientProvider.js +58 -52
  36. package/dist/telemetry/TelemetryClientProvider.js.map +1 -1
  37. package/dist/telemetry/TelemetryEventEmitter.d.ts +52 -26
  38. package/dist/telemetry/TelemetryEventEmitter.js +88 -109
  39. package/dist/telemetry/TelemetryEventEmitter.js.map +1 -1
  40. package/dist/telemetry/{urlUtils.d.ts → telemetryTypeMappers.d.ts} +8 -5
  41. package/dist/telemetry/telemetryTypeMappers.js +72 -0
  42. package/dist/telemetry/telemetryTypeMappers.js.map +1 -0
  43. package/dist/telemetry/telemetryUtils.d.ts +14 -0
  44. package/dist/telemetry/telemetryUtils.js +52 -1
  45. package/dist/telemetry/telemetryUtils.js.map +1 -1
  46. package/dist/telemetry/types.d.ts +33 -1
  47. package/dist/telemetry/types.js +5 -2
  48. package/dist/telemetry/types.js.map +1 -1
  49. package/dist/version.d.ts +1 -1
  50. package/dist/version.js +1 -1
  51. package/package.json +2 -2
  52. package/dist/telemetry/urlUtils.js +0 -35
  53. package/dist/telemetry/urlUtils.js.map +0 -1
@@ -45,6 +45,90 @@ export type ConnectionOptions = {
45
45
  socketTimeout?: number;
46
46
  proxy?: ProxyOptions;
47
47
  enableMetricViewMetadata?: boolean;
48
+ /**
49
+ * Extra HTTP headers attached to driver-owned out-of-band requests
50
+ * (telemetry POSTs and feature-flag GETs). Not applied to the primary
51
+ * Thrift transport or to OAuth/OIDC token requests.
52
+ *
53
+ * When `path` contains `?o=<workspaceId>` (SPOG account-level routing),
54
+ * the driver automatically injects an `x-databricks-org-id` header unless
55
+ * one is already present in this map.
56
+ */
57
+ customHeaders?: Record<string, string>;
58
+ /**
59
+ * Whether the driver emits telemetry events (connection / statement /
60
+ * cloud-fetch / error). Defaults to `true`.
61
+ *
62
+ * Activation is gated by **two** conditions:
63
+ * 1. This flag is `true` **and**
64
+ * 2. The remote feature flag for the workspace allows telemetry.
65
+ *
66
+ * Setting this to `false` is a hard, unconditional opt-out. Setting to
67
+ * `true` only requests telemetry; the workspace must also allow it.
68
+ *
69
+ * The environment variable `DATABRICKS_TELEMETRY_DISABLED` set to one of
70
+ * `1`, `true`, `yes`, or `on` (case-insensitive) overrides this flag and
71
+ * disables telemetry entirely.
72
+ */
73
+ telemetryEnabled?: boolean;
74
+ /**
75
+ * Maximum number of metrics to batch before flushing to the telemetry
76
+ * endpoint. Default 100.
77
+ */
78
+ telemetryBatchSize?: number;
79
+ /**
80
+ * How often to flush buffered telemetry metrics, in milliseconds.
81
+ * The flush timer is `unref()`'d so it cannot keep the Node.js process
82
+ * alive on its own. Default 5000ms.
83
+ */
84
+ telemetryFlushIntervalMs?: number;
85
+ /**
86
+ * Maximum retry attempts for a telemetry export *after* the initial call.
87
+ * Default 3.
88
+ */
89
+ telemetryMaxRetries?: number;
90
+ /**
91
+ * When `true`, telemetry is sent to the authenticated `/telemetry-ext`
92
+ * endpoint with workspace + session + statement IDs and a system
93
+ * configuration block. When `false`, only error names are emitted via the
94
+ * unauthenticated endpoint. Default `true`.
95
+ *
96
+ * Privacy-relevant: setting `false` minimizes the data surface at the
97
+ * cost of losing most observability.
98
+ */
99
+ telemetryAuthenticatedExport?: boolean;
100
+ /**
101
+ * Number of consecutive telemetry export failures before the per-host
102
+ * circuit breaker trips and pauses exports. Default 5.
103
+ */
104
+ telemetryCircuitBreakerThreshold?: number;
105
+ /**
106
+ * How long the circuit breaker stays open before re-probing the
107
+ * telemetry endpoint, in milliseconds. Default 60000ms (1 minute).
108
+ */
109
+ telemetryCircuitBreakerTimeout?: number;
110
+ /**
111
+ * Maximum wall-clock time `client.close()` will wait for the final
112
+ * telemetry flush HTTP POST. Bounds shutdown latency so callers
113
+ * doing `await client.close(); process.exit(0)` are not held up by a
114
+ * misbehaving telemetry endpoint. Default 2000ms.
115
+ */
116
+ telemetryCloseTimeoutMs?: number;
117
+ /**
118
+ * Hard cap on the per-statement aggregation map size. When the cap is
119
+ * reached, the oldest entry is evicted (its buffered errors are emitted
120
+ * as standalone metrics first so the first-failure signal survives).
121
+ * Default 5000.
122
+ */
123
+ telemetryMaxStatementMetrics?: number;
124
+ /**
125
+ * Maximum number of telemetry metrics buffered in memory before the
126
+ * oldest non-error entry is dropped. Raise this when
127
+ * `getTelemetryStats().droppedMetrics` increases between observations,
128
+ * which indicates the buffer is filling faster than the flush interval
129
+ * can drain it. Default 500.
130
+ */
131
+ telemetryMaxPendingMetrics?: number;
48
132
  } & AuthOptions;
49
133
  export interface OpenSessionRequest {
50
134
  initialCatalog?: string;
package/dist/index.d.ts CHANGED
@@ -14,6 +14,8 @@ import { LogLevel } from './contracts/IDBSQLLogger';
14
14
  export type { default as ITokenProvider } from './connection/auth/tokenProvider/ITokenProvider';
15
15
  export { CircuitBreakerOpenError, CIRCUIT_BREAKER_OPEN_CODE } from './telemetry/CircuitBreaker';
16
16
  export { TelemetryTerminalError } from './telemetry/DatabricksTelemetryExporter';
17
+ export { TelemetryEventType, DEFAULT_TELEMETRY_CONFIG } from './telemetry/types';
18
+ export type { TelemetryEvent, TelemetryMetric, TelemetryConfiguration, StatementMetrics, DriverConfiguration, } from './telemetry/types';
17
19
  export declare const auth: {
18
20
  PlainHttpAuthentication: typeof PlainHttpAuthentication;
19
21
  Token: typeof Token;
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.LogLevel = exports.DBSQLLogger = exports.DBSQLParameterType = exports.DBSQLParameter = exports.DBSQLSession = exports.DBSQLClient = exports.utils = exports.thrift = exports.connections = exports.TProtocolExceptionType = exports.TProtocolException = exports.TApplicationExceptionType = exports.TApplicationException = exports.TException = exports.auth = exports.TelemetryTerminalError = exports.CIRCUIT_BREAKER_OPEN_CODE = exports.CircuitBreakerOpenError = void 0;
6
+ exports.LogLevel = exports.DBSQLLogger = exports.DBSQLParameterType = exports.DBSQLParameter = exports.DBSQLSession = exports.DBSQLClient = exports.utils = exports.thrift = exports.connections = exports.TProtocolExceptionType = exports.TProtocolException = exports.TApplicationExceptionType = exports.TApplicationException = exports.TException = exports.auth = exports.DEFAULT_TELEMETRY_CONFIG = exports.TelemetryEventType = exports.TelemetryTerminalError = exports.CIRCUIT_BREAKER_OPEN_CODE = exports.CircuitBreakerOpenError = void 0;
7
7
  // Don't move this import - it should be placed before any other
8
8
  require("./polyfills");
9
9
  const thrift_1 = require("thrift");
@@ -24,13 +24,17 @@ const HttpConnection_1 = __importDefault(require("./connection/connections/HttpC
24
24
  const utils_1 = require("./utils");
25
25
  const IDBSQLLogger_1 = require("./contracts/IDBSQLLogger");
26
26
  Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function () { return IDBSQLLogger_1.LogLevel; } });
27
- // Re-export telemetry error classes so consumers can instanceof-check rather
28
- // than string-matching error messages.
29
27
  var CircuitBreaker_1 = require("./telemetry/CircuitBreaker");
30
28
  Object.defineProperty(exports, "CircuitBreakerOpenError", { enumerable: true, get: function () { return CircuitBreaker_1.CircuitBreakerOpenError; } });
31
29
  Object.defineProperty(exports, "CIRCUIT_BREAKER_OPEN_CODE", { enumerable: true, get: function () { return CircuitBreaker_1.CIRCUIT_BREAKER_OPEN_CODE; } });
32
30
  var DatabricksTelemetryExporter_1 = require("./telemetry/DatabricksTelemetryExporter");
33
31
  Object.defineProperty(exports, "TelemetryTerminalError", { enumerable: true, get: function () { return DatabricksTelemetryExporter_1.TelemetryTerminalError; } });
32
+ // Telemetry event/metric/config shapes for consumers that want to inspect
33
+ // telemetry payloads or pre-validate config. The emitter, aggregator, and
34
+ // per-host client are deliberately not re-exported — they are internal.
35
+ var types_1 = require("./telemetry/types");
36
+ Object.defineProperty(exports, "TelemetryEventType", { enumerable: true, get: function () { return types_1.TelemetryEventType; } });
37
+ Object.defineProperty(exports, "DEFAULT_TELEMETRY_CONFIG", { enumerable: true, get: function () { return types_1.DEFAULT_TELEMETRY_CONFIG; } });
34
38
  exports.auth = {
35
39
  PlainHttpAuthentication: PlainHttpAuthentication_1.default,
36
40
  // Token provider classes for custom authentication
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAgE;AAChE,uBAAqB;AAErB,mCAAgC;AAChC,wEAAgD;AAChD,oFAA4D;AAC5D,gEAAwC;AAoD/B,sBApDF,qBAAW,CAoDE;AAnDpB,kEAA0C;AAmDpB,uBAnDf,sBAAY,CAmDe;AAlDlC,qDAAsE;AAkDlC,+FAlD3B,+BAAc,OAkD2B;AAAE,mGAlD3B,mCAAkB,OAkD2B;AAjDtE,gEAAwC;AAiDgC,sBAjDjE,qBAAW,CAiDiE;AAhDnF,wGAAgF;AAChF,mEAMyC;AACzC,6FAAqE;AACrE,mCAAyC;AACzC,2DAAoD;AAsCiC,yFAtC5E,uBAAQ,OAsC4E;AAjC7F,6EAA6E;AAC7E,uCAAuC;AACvC,6DAAgG;AAAvF,yHAAA,uBAAuB,OAAA;AAAE,2HAAA,yBAAyB,OAAA;AAC3D,uFAAiF;AAAxE,qIAAA,sBAAsB,OAAA;AAElB,QAAA,IAAI,GAAG;IAClB,uBAAuB,EAAvB,iCAAuB;IACvB,mDAAmD;IACnD,KAAK,EAAL,qBAAK;IACL,mBAAmB,EAAnB,mCAAmB;IACnB,qBAAqB,EAArB,qCAAqB;IACrB,mBAAmB,EAAnB,mCAAmB;IACnB,kBAAkB,EAAlB,kCAAkB;CACnB,CAAC;AAEF,MAAM,EAAE,UAAU,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,GAChH,eAAM,CAAC;AAEA,gCAAU;AAAE,sDAAqB;AAAE,8DAAyB;AAAE,gDAAkB;AAAE,wDAAsB;AAEpG,QAAA,WAAW,GAAG;IACzB,cAAc,EAAd,wBAAc;CACf,CAAC;AAEW,QAAA,MAAM,GAAG;IACp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DAAsB;AAEpG,QAAA,WAAW,GAAG;IACzB,cAAc,EAAd,wBAAc;CACf,CAAC;AAEW,QAAA,MAAM,GAAG;IACpB,WAAW,EAAX,qBAAW;IACX,iBAAiB,EAAjB,2BAAiB;CAClB,CAAC;AAEW,QAAA,KAAK,GAAG;IACnB,cAAc,EAAd,sBAAc;CACf,CAAC"}
@@ -6,12 +6,19 @@ export default class CloudFetchResultHandler implements IResultsProvider<ArrowBa
6
6
  private readonly context;
7
7
  private readonly source;
8
8
  private readonly isLZ4Compressed;
9
+ private readonly statementId?;
9
10
  private pendingLinks;
10
11
  private downloadTasks;
11
- constructor(context: IClientContext, source: IResultsProvider<TRowSet | undefined>, { lz4Compressed }: TGetResultSetMetadataResp);
12
+ private chunkIndex;
13
+ constructor(context: IClientContext, source: IResultsProvider<TRowSet | undefined>, metadata: TGetResultSetMetadataResp, statementId?: string);
12
14
  hasMore(): Promise<boolean>;
13
15
  fetchNext(options: ResultsProviderFetchNextOptions): Promise<ArrowBatch>;
14
16
  private logDownloadMetrics;
15
17
  private downloadLink;
16
18
  private fetch;
19
+ /**
20
+ * Emit cloudfetch.chunk telemetry event.
21
+ * CRITICAL: All exceptions swallowed and logged at LogLevel.debug ONLY.
22
+ */
23
+ private emitCloudFetchChunk;
17
24
  }
@@ -30,13 +30,17 @@ const node_fetch_1 = __importStar(require("node-fetch"));
30
30
  const HiveDriverError_1 = __importDefault(require("../errors/HiveDriverError"));
31
31
  const utils_1 = require("../utils");
32
32
  const IDBSQLLogger_1 = require("../contracts/IDBSQLLogger");
33
+ const telemetryUtils_1 = require("../telemetry/telemetryUtils");
33
34
  class CloudFetchResultHandler {
34
- constructor(context, source, { lz4Compressed }) {
35
+ constructor(context, source, metadata, statementId) {
36
+ var _a;
35
37
  this.pendingLinks = [];
36
38
  this.downloadTasks = [];
39
+ this.chunkIndex = 0;
37
40
  this.context = context;
38
41
  this.source = source;
39
- this.isLZ4Compressed = lz4Compressed !== null && lz4Compressed !== void 0 ? lz4Compressed : false;
42
+ this.isLZ4Compressed = (_a = metadata.lz4Compressed) !== null && _a !== void 0 ? _a : false;
43
+ this.statementId = statementId;
40
44
  if (this.isLZ4Compressed && !(0, utils_1.LZ4)()) {
41
45
  throw new HiveDriverError_1.default('Cannot handle LZ4 compressed result: module `lz4` not installed');
42
46
  }
@@ -97,6 +101,9 @@ class CloudFetchResultHandler {
97
101
  const result = await response.arrayBuffer();
98
102
  const downloadTimeMs = Date.now() - startTime;
99
103
  this.logDownloadMetrics(link.fileLink, result.byteLength, downloadTimeMs);
104
+ // Emit cloudfetch.chunk telemetry event
105
+ this.emitCloudFetchChunk(this.chunkIndex, downloadTimeMs, result.byteLength);
106
+ this.chunkIndex += 1;
100
107
  return {
101
108
  batches: [Buffer.from(result)],
102
109
  rowCount: link.rowCount.toNumber(true),
@@ -113,6 +120,25 @@ class CloudFetchResultHandler {
113
120
  });
114
121
  return result.response;
115
122
  }
123
+ /**
124
+ * Emit cloudfetch.chunk telemetry event.
125
+ * CRITICAL: All exceptions swallowed and logged at LogLevel.debug ONLY.
126
+ */
127
+ emitCloudFetchChunk(chunkIndex, latencyMs, bytes) {
128
+ const { statementId } = this;
129
+ if (!statementId) {
130
+ return;
131
+ }
132
+ (0, telemetryUtils_1.safeEmit)(this.context, (emitter) => {
133
+ emitter.emitCloudFetchChunk({
134
+ statementId,
135
+ chunkIndex,
136
+ latencyMs,
137
+ bytes,
138
+ compressed: this.isLZ4Compressed,
139
+ });
140
+ });
141
+ }
116
142
  }
117
143
  exports.default = CloudFetchResultHandler;
118
144
  //# sourceMappingURL=CloudFetchResultHandler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CloudFetchResultHandler.js","sourceRoot":"","sources":["../../lib/result/CloudFetchResultHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAAsE;AAEtE,gFAAwD;AAIxD,oCAA+B;AAC/B,4DAAqD;AAErD,MAAqB,uBAAuB;IAW1C,YACE,OAAuB,E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AE,aAAa,CAAC,CAAC;YAChD,OAAO,IAAA,oBAAK,EAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED;;;OAGG;IACK,mBAAmB,CAAC,UAAkB,EAAE,SAAiB,EAAE,KAAa;QAC9E,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;QAC7B,IAAI,CAAC,WAAW,EAAE;YAChB,OAAO;SACR;QACD,IAAA,yBAAQ,EAAC,IAAI,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE;YACjC,OAAO,CAAC,mBAAmB,CAAC;gBAC1B,WAAW;gBACX,UAAU;gBACV,SAAS;gBACT,KAAK;gBACL,UAAU,EAAE,IAAI,CAAC,eAAe;aACjC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAnJD,0CAmJC"}
@@ -8,13 +8,20 @@ export declare enum FetchType {
8
8
  export default class RowSetProvider implements IResultsProvider<TRowSet | undefined> {
9
9
  private readonly context;
10
10
  private readonly operationHandle;
11
+ private readonly statementId?;
12
+ private chunkIndex;
11
13
  private fetchOrientation;
12
14
  private prefetchedResults;
13
15
  private readonly returnOnlyPrefetchedResults;
14
16
  private hasMoreRowsFlag?;
15
17
  private get hasMoreRows();
16
- constructor(context: IClientContext, operationHandle: TOperationHandle, prefetchedResults: Array<TFetchResultsResp | undefined>, returnOnlyPrefetchedResults: boolean);
18
+ constructor(context: IClientContext, operationHandle: TOperationHandle, prefetchedResults: Array<TFetchResultsResp | undefined>, returnOnlyPrefetchedResults: boolean, statementId?: string);
17
19
  private processFetchResponse;
18
20
  fetchNext({ limit }: ResultsProviderFetchNextOptions): Promise<TRowSet | undefined>;
21
+ /**
22
+ * Emit a chunk telemetry event for one FetchResults page.
23
+ * CRITICAL: All exceptions swallowed and logged at LogLevel.debug ONLY.
24
+ */
25
+ private emitChunkEvent;
19
26
  hasMore(): Promise<boolean>;
20
27
  }
@@ -7,12 +7,66 @@ exports.FetchType = void 0;
7
7
  const node_int64_1 = __importDefault(require("node-int64"));
8
8
  const TCLIService_types_1 = require("../../thrift/TCLIService_types");
9
9
  const Status_1 = __importDefault(require("../dto/Status"));
10
+ const telemetryUtils_1 = require("../telemetry/telemetryUtils");
10
11
  const utils_1 = require("./utils");
11
12
  var FetchType;
12
13
  (function (FetchType) {
13
14
  FetchType[FetchType["Data"] = 0] = "Data";
14
15
  FetchType[FetchType["Logs"] = 1] = "Logs";
15
16
  })(FetchType = exports.FetchType || (exports.FetchType = {}));
17
+ /**
18
+ * Rough byte count for a single `TColumn`. Used only for telemetry — exact
19
+ * wire size isn't worth a deserialization pass. Fixed-width values are
20
+ * estimated by their TypeScript-side footprint; strings count their UTF-16
21
+ * length (close enough proxy for UTF-8 payload in most cases). The `nulls`
22
+ * bitmap buffer is included verbatim.
23
+ *
24
+ * Wire-side payload will be slightly different (Thrift's varint encodings,
25
+ * UTF-8 vs the JS engine's UTF-16) but dashboards aggregating
26
+ * `bytesDownloaded` for non-arrow result sets care about scale, not byte-
27
+ * perfect accuracy.
28
+ */
29
+ function estimateColumnBytes(column) {
30
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
31
+ let bytes = 0;
32
+ if (column.boolVal) {
33
+ bytes += (_b = (_a = column.boolVal.values) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
34
+ bytes += (_d = (_c = column.boolVal.nulls) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0;
35
+ }
36
+ if (column.byteVal) {
37
+ bytes += (_f = (_e = column.byteVal.values) === null || _e === void 0 ? void 0 : _e.length) !== null && _f !== void 0 ? _f : 0;
38
+ bytes += (_h = (_g = column.byteVal.nulls) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 0;
39
+ }
40
+ if (column.i16Val) {
41
+ bytes += ((_k = (_j = column.i16Val.values) === null || _j === void 0 ? void 0 : _j.length) !== null && _k !== void 0 ? _k : 0) * 2;
42
+ bytes += (_m = (_l = column.i16Val.nulls) === null || _l === void 0 ? void 0 : _l.length) !== null && _m !== void 0 ? _m : 0;
43
+ }
44
+ if (column.i32Val) {
45
+ bytes += ((_p = (_o = column.i32Val.values) === null || _o === void 0 ? void 0 : _o.length) !== null && _p !== void 0 ? _p : 0) * 4;
46
+ bytes += (_r = (_q = column.i32Val.nulls) === null || _q === void 0 ? void 0 : _q.length) !== null && _r !== void 0 ? _r : 0;
47
+ }
48
+ if (column.i64Val) {
49
+ bytes += ((_t = (_s = column.i64Val.values) === null || _s === void 0 ? void 0 : _s.length) !== null && _t !== void 0 ? _t : 0) * 8;
50
+ bytes += (_v = (_u = column.i64Val.nulls) === null || _u === void 0 ? void 0 : _u.length) !== null && _v !== void 0 ? _v : 0;
51
+ }
52
+ if (column.doubleVal) {
53
+ bytes += ((_x = (_w = column.doubleVal.values) === null || _w === void 0 ? void 0 : _w.length) !== null && _x !== void 0 ? _x : 0) * 8;
54
+ bytes += (_z = (_y = column.doubleVal.nulls) === null || _y === void 0 ? void 0 : _y.length) !== null && _z !== void 0 ? _z : 0;
55
+ }
56
+ if (column.stringVal) {
57
+ for (const value of (_0 = column.stringVal.values) !== null && _0 !== void 0 ? _0 : []) {
58
+ bytes += (_1 = value === null || value === void 0 ? void 0 : value.length) !== null && _1 !== void 0 ? _1 : 0;
59
+ }
60
+ bytes += (_3 = (_2 = column.stringVal.nulls) === null || _2 === void 0 ? void 0 : _2.length) !== null && _3 !== void 0 ? _3 : 0;
61
+ }
62
+ if (column.binaryVal) {
63
+ for (const value of (_4 = column.binaryVal.values) !== null && _4 !== void 0 ? _4 : []) {
64
+ bytes += (_5 = value === null || value === void 0 ? void 0 : value.length) !== null && _5 !== void 0 ? _5 : 0;
65
+ }
66
+ bytes += (_7 = (_6 = column.binaryVal.nulls) === null || _6 === void 0 ? void 0 : _6.length) !== null && _7 !== void 0 ? _7 : 0;
67
+ }
68
+ return bytes;
69
+ }
16
70
  function checkIfOperationHasMoreRows(response) {
17
71
  var _a, _b, _c;
18
72
  if (response.hasMoreRows) {
@@ -32,12 +86,14 @@ class RowSetProvider {
32
86
  // may change between this getter calls
33
87
  return (_a = this.hasMoreRowsFlag) !== null && _a !== void 0 ? _a : this.operationHandle.hasResultSet;
34
88
  }
35
- constructor(context, operationHandle, prefetchedResults, returnOnlyPrefetchedResults) {
89
+ constructor(context, operationHandle, prefetchedResults, returnOnlyPrefetchedResults, statementId) {
90
+ this.chunkIndex = 0;
36
91
  this.fetchOrientation = TCLIService_types_1.TFetchOrientation.FETCH_FIRST;
37
92
  this.prefetchedResults = [];
38
93
  this.hasMoreRowsFlag = undefined;
39
94
  this.context = context;
40
95
  this.operationHandle = operationHandle;
96
+ this.statementId = statementId;
41
97
  prefetchedResults.forEach((item) => {
42
98
  if (item) {
43
99
  this.prefetchedResults.push(item);
@@ -65,14 +121,67 @@ class RowSetProvider {
65
121
  return undefined;
66
122
  }
67
123
  const driver = await this.context.getDriver();
124
+ const startTime = Date.now();
68
125
  const response = await driver.fetchResults({
69
126
  operationHandle: this.operationHandle,
70
127
  orientation: this.fetchOrientation,
71
128
  maxRows: new node_int64_1.default(limit),
72
129
  fetchType: FetchType.Data,
73
130
  });
131
+ const latencyMs = Date.now() - startTime;
132
+ this.emitChunkEvent(latencyMs, response);
74
133
  return this.processFetchResponse(response);
75
134
  }
135
+ /**
136
+ * Emit a chunk telemetry event for one FetchResults page.
137
+ * CRITICAL: All exceptions swallowed and logged at LogLevel.debug ONLY.
138
+ */
139
+ emitChunkEvent(latencyMs, response) {
140
+ const { statementId } = this;
141
+ if (!statementId) {
142
+ return;
143
+ }
144
+ (0, telemetryUtils_1.safeEmit)(this.context, (emitter) => {
145
+ var _a, _b;
146
+ // Aggregate byte counts across all wire shapes a `TFetchResultsResp`
147
+ // can carry. URL-based result sets (`resultLinks`) bypass this site
148
+ // entirely — they emit from `CloudFetchResultHandler.emitCloudFetchChunk`
149
+ // with the post-download byte count from the cloud-storage GET.
150
+ //
151
+ // Shapes counted here:
152
+ // - `arrowBatches[i].batch` — Arrow inline payload
153
+ // - `binaryColumns` — packed columnar binary blob
154
+ // - `columns[i].*Val.values` — COLUMN_BASED_SET, sum across columns
155
+ // - `rows[i]` — legacy row-based set (rare; estimate)
156
+ let bytes = 0;
157
+ const { results } = response;
158
+ if (results) {
159
+ const { arrowBatches } = results;
160
+ if (arrowBatches) {
161
+ for (const batch of arrowBatches) {
162
+ bytes += (_b = (_a = batch.batch) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
163
+ }
164
+ }
165
+ const { binaryColumns } = results;
166
+ if (binaryColumns) {
167
+ bytes += binaryColumns.length;
168
+ }
169
+ const { columns } = results;
170
+ if (columns) {
171
+ for (const column of columns) {
172
+ bytes += estimateColumnBytes(column);
173
+ }
174
+ }
175
+ }
176
+ emitter.emitCloudFetchChunk({
177
+ statementId,
178
+ chunkIndex: this.chunkIndex,
179
+ latencyMs,
180
+ bytes,
181
+ });
182
+ this.chunkIndex += 1;
183
+ });
184
+ }
76
185
  async hasMore() {
77
186
  // If there are prefetched results available - return `true` regardless of
78
187
  // the actual state of `hasMoreRows` flag (because we actually have some data)
@@ -1 +1 @@
1
- {"version":3,"file":"RowSetProvider.js","sourceRoot":"","sources":["../../lib/result/RowSetProvider.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA+B;AAC/B,sEAAiH;AACjH,2DAAmC;AAGnC,mCAAyC;AAEzC,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,yCAAQ,CAAA;IACR,yCAAQ,CAAA;AACV,CAAC,EAHW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAGpB;AAED,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M,GAAG,CAAC,EAAE;YACrC,OAAO,IAAI,CAAC;SACb;QACD,yEAAyE;QACzE,IAAI,IAAI,CAAC,2BAA2B,EAAE;YACpC,OAAO,KAAK,CAAC;SACd;QAED,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF;AAlJD,iCAkJC"}
@@ -82,7 +82,16 @@ class DatabricksTelemetryExporter {
82
82
  this.authMissingWarned = false;
83
83
  this.circuitBreaker = circuitBreakerRegistry.getCircuitBreaker(host);
84
84
  const config = this.context.getConfig();
85
- this.authenticatedUserAgent = (0, buildUserAgentString_1.default)(config.userAgentEntry);
85
+ // Telemetry-default-on means anything in `userAgentEntry` ships to the
86
+ // telemetry endpoint on every POST. `buildUserAgentString` redacts
87
+ // Databricks token *prefixes* (dapi, dose, …) but not the broader secret
88
+ // shapes — JWTs, OAuth `client_secret`, JSON-encoded credentials, URL
89
+ // userinfo — that customers occasionally stuff into the user-agent.
90
+ // Run the full SECRET_PATTERNS sweep before the UA is built so the
91
+ // header value never carries an unredacted secret. The user's primary
92
+ // Thrift connection is unaffected.
93
+ const redactedEntry = config.userAgentEntry === undefined ? undefined : (0, telemetryUtils_1.redactSensitive)(config.userAgentEntry, 256);
94
+ this.authenticatedUserAgent = (0, buildUserAgentString_1.default)(redactedEntry);
86
95
  this.unauthenticatedUserAgent = (0, buildUserAgentString_1.default)(undefined);
87
96
  }
88
97
  /**
@@ -175,7 +184,7 @@ class DatabricksTelemetryExporter {
175
184
  }
176
185
  }
177
186
  async exportInternal(metrics) {
178
- var _a;
187
+ var _a, _b;
179
188
  const config = this.context.getConfig();
180
189
  const logger = this.context.getLogger();
181
190
  const authenticatedExport = (_a = config.telemetryAuthenticatedExport) !== null && _a !== void 0 ? _a : types_1.DEFAULT_TELEMETRY_CONFIG.authenticatedExport;
@@ -189,6 +198,7 @@ class DatabricksTelemetryExporter {
189
198
  let headers = {
190
199
  'Content-Type': 'application/json',
191
200
  'User-Agent': userAgent,
201
+ ...((_b = config.customHeaders) !== null && _b !== void 0 ? _b : {}),
192
202
  };
193
203
  if (authenticatedExport) {
194
204
  headers = { ...headers, ...(await this.getAuthHeaders()) };
@@ -226,32 +236,46 @@ class DatabricksTelemetryExporter {
226
236
  logger.log(IDBSQLLogger_1.LogLevel.debug, `Successfully exported ${metrics.length} telemetry metrics`);
227
237
  }
228
238
  async getAuthHeaders() {
229
- var _a;
230
- if (!this.authProvider) {
239
+ var _a, _b, _c, _d;
240
+ // Prefer the explicitly-injected auth provider; fall back to the context
241
+ // (used when a shared TelemetryClient resolves auth through its FIFO of
242
+ // registered DBSQLClients).
243
+ const authProvider = (_a = this.authProvider) !== null && _a !== void 0 ? _a : (_c = (_b = this.context).getAuthProvider) === null || _c === void 0 ? void 0 : _c.call(_b);
244
+ if (!authProvider) {
231
245
  return {};
232
246
  }
233
247
  const logger = this.context.getLogger();
234
248
  try {
235
- return (0, telemetryUtils_1.normalizeHeaders)(await this.authProvider.authenticate());
249
+ return (0, telemetryUtils_1.normalizeHeaders)(await authProvider.authenticate());
236
250
  }
237
251
  catch (error) {
238
- logger.log(IDBSQLLogger_1.LogLevel.debug, `Telemetry: auth provider threw: ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error}`);
252
+ logger.log(IDBSQLLogger_1.LogLevel.debug, `Telemetry: auth provider threw: ${(_d = error === null || error === void 0 ? void 0 : error.message) !== null && _d !== void 0 ? _d : error}`);
239
253
  return {};
240
254
  }
241
255
  }
242
256
  async sendRequest(url, init) {
243
257
  const connectionProvider = await this.context.getConnectionProvider();
244
258
  const agent = await connectionProvider.getAgent();
245
- const retryPolicy = await connectionProvider.getRetryPolicy();
259
+ // Do NOT route through `connectionProvider.getRetryPolicy()` here. That
260
+ // policy is bounded by the customer's `retriesTimeout` (15 min default)
261
+ // and `retryMaxAttempts` (5), so each call to `sendRequest` could spend
262
+ // up to ~15 min retrying on its own. Stacked under the exporter's outer
263
+ // `exportWithRetry` loop (`telemetryMaxRetries` default 3) the worst-case
264
+ // wall-clock per batch reaches ~45 min — during which `flushInFlight`
265
+ // blocks subsequent flushes and `addPendingMetric` silently drops past
266
+ // the buffer cap.
267
+ //
268
+ // Telemetry must be a polite background citizen: the outer loop is the
269
+ // single source of retry, and a single attempt here is the right shape.
270
+ // Connection-level errors that the customer retry policy would have
271
+ // bridged (transient socket errors, 5xx) are still classified by
272
+ // `ExceptionClassifier` and retried by `exportWithRetry` instead.
246
273
  const requestConfig = { agent, ...init };
247
- const result = await retryPolicy.invokeWithRetry(() => {
248
- const request = new node_fetch_1.Request(url, requestConfig);
249
- return (0, node_fetch_1.default)(request).then((response) => ({ request, response }));
250
- });
251
- return result.response;
274
+ const request = new node_fetch_1.Request(url, requestConfig);
275
+ return (0, node_fetch_1.default)(request);
252
276
  }
253
277
  toTelemetryLog(metric, authenticatedExport, userAgent) {
254
- var _a, _b;
278
+ var _a, _b, _c;
255
279
  // Unauthenticated export must not ship correlation IDs, fingerprint
256
280
  // data, or raw error detail — an on-path observer could otherwise link
257
281
  // sessions → workspaces → user activity without any auth.
@@ -272,22 +296,27 @@ class DatabricksTelemetryExporter {
272
296
  },
273
297
  },
274
298
  };
275
- if (metric.metricType === 'connection' && metric.driverConfig && includeCorrelation) {
276
- // system_configuration is a high-entropy client fingerprint (OS, arch,
277
- // locale, process, runtime). Only ship on the authenticated path.
278
- log.entry.sql_driver_log.system_configuration = {
279
- driver_version: metric.driverConfig.driverVersion,
280
- driver_name: metric.driverConfig.driverName,
281
- runtime_name: 'Node.js',
282
- runtime_version: metric.driverConfig.nodeVersion,
283
- runtime_vendor: metric.driverConfig.runtimeVendor,
284
- os_name: metric.driverConfig.platform,
285
- os_version: metric.driverConfig.osVersion,
286
- os_arch: metric.driverConfig.osArch,
287
- locale_name: metric.driverConfig.localeName,
288
- char_set_encoding: metric.driverConfig.charSetEncoding,
289
- process_name: (0, telemetryUtils_1.sanitizeProcessName)(metric.driverConfig.processName) || undefined,
290
- };
299
+ if (metric.metricType === 'connection') {
300
+ if (metric.latencyMs !== undefined) {
301
+ log.entry.sql_driver_log.operation_latency_ms = metric.latencyMs;
302
+ }
303
+ if (metric.driverConfig && includeCorrelation) {
304
+ // system_configuration is a high-entropy client fingerprint (OS, arch,
305
+ // locale, process, runtime). Only ship on the authenticated path.
306
+ log.entry.sql_driver_log.system_configuration = {
307
+ driver_version: metric.driverConfig.driverVersion,
308
+ driver_name: metric.driverConfig.driverName,
309
+ runtime_name: 'Node.js',
310
+ runtime_version: metric.driverConfig.nodeVersion,
311
+ runtime_vendor: metric.driverConfig.runtimeVendor,
312
+ os_name: metric.driverConfig.platform,
313
+ os_version: metric.driverConfig.osVersion,
314
+ os_arch: metric.driverConfig.osArch,
315
+ locale_name: metric.driverConfig.localeName,
316
+ char_set_encoding: metric.driverConfig.charSetEncoding,
317
+ process_name: (0, telemetryUtils_1.sanitizeProcessName)(metric.driverConfig.processName) || undefined,
318
+ };
319
+ }
291
320
  }
292
321
  else if (metric.metricType === 'statement') {
293
322
  log.entry.sql_driver_log.operation_latency_ms = metric.latencyMs;
@@ -295,20 +324,25 @@ class DatabricksTelemetryExporter {
295
324
  log.entry.sql_driver_log.sql_operation = {
296
325
  execution_result: metric.resultFormat,
297
326
  };
298
- if (metric.chunkCount && metric.chunkCount > 0) {
327
+ if (((_a = metric.chunkCount) !== null && _a !== void 0 ? _a : 0) > 0) {
299
328
  log.entry.sql_driver_log.sql_operation.chunk_details = {
300
329
  total_chunks_present: metric.chunkCount,
301
330
  total_chunks_iterated: metric.chunkCount,
331
+ initial_chunk_latency_millis: metric.chunkInitialLatencyMs,
332
+ slowest_chunk_latency_millis: metric.chunkSlowestLatencyMs,
333
+ sum_chunks_download_time_millis: metric.chunkSumLatencyMs,
302
334
  };
303
335
  }
304
336
  }
305
337
  }
306
338
  else if (metric.metricType === 'error') {
307
- const stackOrMessage = (_b = (_a = metric.errorStack) !== null && _a !== void 0 ? _a : metric.errorMessage) !== null && _b !== void 0 ? _b : '';
339
+ const stackOrMessage = (_c = (_b = metric.errorStack) !== null && _b !== void 0 ? _b : metric.errorMessage) !== null && _c !== void 0 ? _c : '';
340
+ // Primary redaction site is TelemetryEventEmitter.emitError — this
341
+ // second pass is defence-in-depth in case a metric reached the
342
+ // exporter via a path that bypassed the emitter (programmatic injection
343
+ // in tests, future call sites). On the unauth path we ship nothing.
308
344
  log.entry.sql_driver_log.error_info = {
309
345
  error_name: metric.errorName || 'UnknownError',
310
- // Redact common secret shapes and cap length. On the unauth path we
311
- // keep only the error class — no message body.
312
346
  stack_trace: includeCorrelation ? (0, telemetryUtils_1.redactSensitive)(stackOrMessage) : '',
313
347
  };
314
348
  }