@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.
- package/README.md +12 -0
- package/dist/DBSQLClient.d.ts +99 -0
- package/dist/DBSQLClient.js +445 -0
- package/dist/DBSQLClient.js.map +1 -1
- package/dist/DBSQLOperation.d.ts +32 -1
- package/dist/DBSQLOperation.js +138 -29
- package/dist/DBSQLOperation.js.map +1 -1
- package/dist/DBSQLSession.d.ts +1 -0
- package/dist/DBSQLSession.js +39 -12
- package/dist/DBSQLSession.js.map +1 -1
- package/dist/connection/auth/DatabricksOAuth/OAuthManager.js +10 -6
- package/dist/connection/auth/DatabricksOAuth/OAuthManager.js.map +1 -1
- package/dist/contracts/IClientContext.d.ts +29 -0
- package/dist/contracts/IDBSQLClient.d.ts +84 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/result/CloudFetchResultHandler.d.ts +8 -1
- package/dist/result/CloudFetchResultHandler.js +28 -2
- package/dist/result/CloudFetchResultHandler.js.map +1 -1
- package/dist/result/RowSetProvider.d.ts +8 -1
- package/dist/result/RowSetProvider.js +110 -1
- package/dist/result/RowSetProvider.js.map +1 -1
- package/dist/telemetry/DatabricksTelemetryExporter.js +67 -33
- package/dist/telemetry/DatabricksTelemetryExporter.js.map +1 -1
- package/dist/telemetry/FeatureFlagCache.js +10 -4
- package/dist/telemetry/FeatureFlagCache.js.map +1 -1
- package/dist/telemetry/MetricsAggregator.d.ts +38 -0
- package/dist/telemetry/MetricsAggregator.js +249 -14
- package/dist/telemetry/MetricsAggregator.js.map +1 -1
- package/dist/telemetry/TelemetryClient.d.ts +94 -14
- package/dist/telemetry/TelemetryClient.js +252 -20
- package/dist/telemetry/TelemetryClient.js.map +1 -1
- package/dist/telemetry/TelemetryClientProvider.d.ts +28 -33
- package/dist/telemetry/TelemetryClientProvider.js +58 -52
- package/dist/telemetry/TelemetryClientProvider.js.map +1 -1
- package/dist/telemetry/TelemetryEventEmitter.d.ts +52 -26
- package/dist/telemetry/TelemetryEventEmitter.js +88 -109
- package/dist/telemetry/TelemetryEventEmitter.js.map +1 -1
- package/dist/telemetry/{urlUtils.d.ts → telemetryTypeMappers.d.ts} +8 -5
- package/dist/telemetry/telemetryTypeMappers.js +72 -0
- package/dist/telemetry/telemetryTypeMappers.js.map +1 -0
- package/dist/telemetry/telemetryUtils.d.ts +14 -0
- package/dist/telemetry/telemetryUtils.js +52 -1
- package/dist/telemetry/telemetryUtils.js.map +1 -1
- package/dist/telemetry/types.d.ts +33 -1
- package/dist/telemetry/types.js +5 -2
- package/dist/telemetry/types.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/dist/telemetry/urlUtils.js +0 -35
- package/dist/telemetry/urlUtils.js.map +0 -1
package/README.md
CHANGED
|
@@ -51,6 +51,18 @@ client
|
|
|
51
51
|
});
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
+
## Telemetry
|
|
55
|
+
|
|
56
|
+
The driver emits connection, statement, and CloudFetch metrics plus
|
|
57
|
+
redacted error events to help Databricks improve driver reliability. No
|
|
58
|
+
SQL text, parameter values, or row data is ever collected. Emission is
|
|
59
|
+
gated by a server-side feature flag and can be disabled per-connection
|
|
60
|
+
with `telemetryEnabled: false` or globally with the
|
|
61
|
+
`DATABRICKS_TELEMETRY_DISABLED` env var.
|
|
62
|
+
|
|
63
|
+
See [docs/TELEMETRY.md](docs/TELEMETRY.md) for the full event payloads,
|
|
64
|
+
tuning knobs, multi-tenant guidance, and troubleshooting.
|
|
65
|
+
|
|
54
66
|
## Run Tests
|
|
55
67
|
|
|
56
68
|
### Unit tests
|
package/dist/DBSQLClient.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ import IDBSQLSession from './contracts/IDBSQLSession';
|
|
|
9
9
|
import IAuthentication from './connection/contracts/IAuthentication';
|
|
10
10
|
import IDBSQLLogger from './contracts/IDBSQLLogger';
|
|
11
11
|
import IConnectionProvider from './connection/contracts/IConnectionProvider';
|
|
12
|
+
import TelemetryEventEmitter from './telemetry/TelemetryEventEmitter';
|
|
13
|
+
import MetricsAggregator from './telemetry/MetricsAggregator';
|
|
12
14
|
export type ThriftLibrary = Pick<typeof thrift, 'createClient'>;
|
|
13
15
|
export default class DBSQLClient extends EventEmitter implements IDBSQLClient, IClientContext {
|
|
14
16
|
private static defaultLogger?;
|
|
@@ -20,6 +22,12 @@ export default class DBSQLClient extends EventEmitter implements IDBSQLClient, I
|
|
|
20
22
|
private readonly logger;
|
|
21
23
|
private thrift;
|
|
22
24
|
private readonly sessions;
|
|
25
|
+
private host?;
|
|
26
|
+
private httpPath?;
|
|
27
|
+
private authType?;
|
|
28
|
+
private telemetryClient?;
|
|
29
|
+
private telemetryEmitter?;
|
|
30
|
+
private driverConfigShipped;
|
|
23
31
|
private static getDefaultLogger;
|
|
24
32
|
private static getDefaultConfig;
|
|
25
33
|
constructor(options?: ClientOptions);
|
|
@@ -31,6 +39,66 @@ export default class DBSQLClient extends EventEmitter implements IDBSQLClient, I
|
|
|
31
39
|
*/
|
|
32
40
|
private wrapTokenProvider;
|
|
33
41
|
private createConnectionProvider;
|
|
42
|
+
/**
|
|
43
|
+
* Extract the numeric workspace ID for telemetry.
|
|
44
|
+
*
|
|
45
|
+
* Two URL shapes carry the workspace ID today:
|
|
46
|
+
* - Warehouse, query form: `/sql/1.0/warehouses/<id>?o=<wsId>`
|
|
47
|
+
* - All-purpose cluster, path form: `sql/protocolv1/o/<wsId>/<cluster-id>`
|
|
48
|
+
*
|
|
49
|
+
* Host-based extraction was tried previously but produced confidently-wrong
|
|
50
|
+
* values:
|
|
51
|
+
* - AWS `dbc-XXXXX-YYYY.cloud.databricks.com` → `dbc-XXXXX-YYYY`
|
|
52
|
+
* is the deployment shard prefix, not the workspace ID.
|
|
53
|
+
* - Azure `adb-NNNNNNNNNNNNN.NN.azuredatabricks.net` → the workspace ID is
|
|
54
|
+
* the numeric portion after the `adb-` prefix (and before the form-factor
|
|
55
|
+
* digit), not `adb-NNN`.
|
|
56
|
+
*
|
|
57
|
+
* Returns `undefined` when no workspace ID can be derived. Server-side
|
|
58
|
+
* attribution is better off seeing a missing field than a wrong value.
|
|
59
|
+
*/
|
|
60
|
+
private static extractWorkspaceId;
|
|
61
|
+
private static hasMalformedOrgParam;
|
|
62
|
+
/**
|
|
63
|
+
* Build the customHeaders map applied to telemetry POSTs and feature-flag
|
|
64
|
+
* GETs (SPOG / Single Panel of Glass support). When `httpPath` carries a
|
|
65
|
+
* workspace ID — either as a `?o=<wsId>` query (warehouse) or a
|
|
66
|
+
* `/o/<wsId>/<cluster-id>` path segment (all-purpose cluster) — endpoints
|
|
67
|
+
* that don't include the workspace in their URL path need it conveyed via
|
|
68
|
+
* the `x-databricks-org-id` header instead. A user-supplied value in
|
|
69
|
+
* `userHeaders` (case-insensitively keyed) wins over the parsed value.
|
|
70
|
+
*
|
|
71
|
+
* `httpPath` is passed explicitly (rather than read off `this.httpPath`) so
|
|
72
|
+
* the SPOG-routing dependency is visible in the signature — a future
|
|
73
|
+
* refactor that reorders connect() can't silently break injection.
|
|
74
|
+
*/
|
|
75
|
+
private buildCustomHeaders;
|
|
76
|
+
/**
|
|
77
|
+
* Build driver configuration for telemetry reporting.
|
|
78
|
+
* @returns DriverConfiguration object with current driver settings
|
|
79
|
+
*/
|
|
80
|
+
private buildDriverConfiguration;
|
|
81
|
+
/**
|
|
82
|
+
* Map Node.js auth type to telemetry auth enum string.
|
|
83
|
+
* Distinguishes between U2M and M2M OAuth flows.
|
|
84
|
+
*/
|
|
85
|
+
private mapAuthType;
|
|
86
|
+
/**
|
|
87
|
+
* Get locale name in format language_country (e.g., en_US).
|
|
88
|
+
* Matches JDBC format: user.language + '_' + user.country
|
|
89
|
+
*/
|
|
90
|
+
private getLocaleName;
|
|
91
|
+
/**
|
|
92
|
+
* Get process name, similar to JDBC's ProcessNameUtil.
|
|
93
|
+
* Returns the script name or process title.
|
|
94
|
+
*/
|
|
95
|
+
private getProcessName;
|
|
96
|
+
/**
|
|
97
|
+
* Initialize telemetry components if enabled.
|
|
98
|
+
* CRITICAL: All errors swallowed and logged at LogLevel.debug ONLY.
|
|
99
|
+
* Driver NEVER throws exceptions due to telemetry.
|
|
100
|
+
*/
|
|
101
|
+
private initializeTelemetry;
|
|
34
102
|
/**
|
|
35
103
|
* Connects DBSQLClient to endpoint
|
|
36
104
|
* @public
|
|
@@ -51,6 +119,15 @@ export default class DBSQLClient extends EventEmitter implements IDBSQLClient, I
|
|
|
51
119
|
* const session = await client.openSession();
|
|
52
120
|
*/
|
|
53
121
|
openSession(request?: OpenSessionRequest): Promise<IDBSQLSession>;
|
|
122
|
+
/**
|
|
123
|
+
* Closes the client, releasing sessions and telemetry resources.
|
|
124
|
+
*
|
|
125
|
+
* The internal telemetry flush timer uses `setInterval(...).unref()` so it
|
|
126
|
+
* cannot keep the Node.js process alive on its own. As a consequence, any
|
|
127
|
+
* telemetry buffered between flush ticks is lost if the process exits
|
|
128
|
+
* without calling `close()`. Long-lived applications should `await` this
|
|
129
|
+
* method on shutdown so the aggregator drains its remaining metrics.
|
|
130
|
+
*/
|
|
54
131
|
close(): Promise<void>;
|
|
55
132
|
getConfig(): ClientConfig;
|
|
56
133
|
getLogger(): IDBSQLLogger;
|
|
@@ -65,4 +142,26 @@ export default class DBSQLClient extends EventEmitter implements IDBSQLClient, I
|
|
|
65
142
|
* @internal Not part of the public API. May change without notice.
|
|
66
143
|
*/
|
|
67
144
|
getAuthProvider(): IAuthentication | undefined;
|
|
145
|
+
/** @internal */
|
|
146
|
+
getTelemetryEmitter(): TelemetryEventEmitter | undefined;
|
|
147
|
+
/** @internal */
|
|
148
|
+
getTelemetryAggregator(): MetricsAggregator | undefined;
|
|
149
|
+
/**
|
|
150
|
+
* Operator-visible snapshot of the client's telemetry state: current
|
|
151
|
+
* buffer depth, in-flight statement aggregations, cumulative drops/
|
|
152
|
+
* evictions, and circuit-breaker state. Returns `undefined` when
|
|
153
|
+
* telemetry is disabled (config, env-kill, or feature-flag).
|
|
154
|
+
*
|
|
155
|
+
* Use this in health-check endpoints or shutdown banners to verify that
|
|
156
|
+
* telemetry is flowing. A non-zero `droppedMetrics` between observations
|
|
157
|
+
* means buffer overflow — raise `telemetryMaxPendingMetrics`.
|
|
158
|
+
*/
|
|
159
|
+
getTelemetryStats(): {
|
|
160
|
+
host: string;
|
|
161
|
+
pendingMetricsCount: number;
|
|
162
|
+
inFlightStatements: number;
|
|
163
|
+
droppedMetrics: number;
|
|
164
|
+
evictedStatements: number;
|
|
165
|
+
circuitBreakerState: string;
|
|
166
|
+
} | undefined;
|
|
68
167
|
}
|