Skip to content

Commit 1ce2126

Browse files
authored
Add telemetry for serverless and workflow/dbconnect runs (#1543)
## Changes Add telemetry for serverless and workflow/dbconnect runs ## Tests Manually
1 parent e6b270f commit 1ce2126

File tree

6 files changed

+81
-6
lines changed

6 files changed

+81
-6
lines changed

packages/databricks-vscode/src/configuration/ConnectionManager.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ export class ConnectionManager implements Disposable {
137137
) {
138138
this.cli.setClusterId(clusterId);
139139
}
140+
if (this.cluster) {
141+
this.telemetry.recordEvent(Events.COMPUTE_SELECTED, {
142+
type: "cluster",
143+
});
144+
}
140145
this.onDidChangeClusterEmitter.fire(this.cluster);
141146
} catch (e) {
142147
this.configModel.set("clusterId", undefined);
@@ -462,6 +467,9 @@ export class ConnectionManager implements Disposable {
462467
await this.detachCluster();
463468
this.customWhenContext.setServerless(true);
464469
this.onDidChangeClusterEmitter.fire(undefined);
470+
this.telemetry.recordEvent(Events.COMPUTE_SELECTED, {
471+
type: "serverless",
472+
});
465473
}
466474
}
467475

packages/databricks-vscode/src/extension.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,8 @@ export async function activate(
768768
pythonExtensionWrapper,
769769
featureManager,
770770
context,
771-
customWhenContext
771+
customWhenContext,
772+
telemetry
772773
);
773774
const debugFactory = new DatabricksDebugAdapterFactory(
774775
connectionManager,
@@ -780,7 +781,8 @@ export async function activate(
780781
connectionManager,
781782
configModel,
782783
context,
783-
bundleCommands
784+
bundleCommands,
785+
telemetry
784786
);
785787

786788
context.subscriptions.push(

packages/databricks-vscode/src/run/DatabricksWorkflowDebugAdapter.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {LocalUri} from "../sync/SyncDestination";
3131
import {FileUtils} from "../utils";
3232
import {BundleCommands} from "../ui/bundle-resource-explorer/BundleCommands";
3333
import {ConfigModel} from "../configuration/models/ConfigModel";
34+
import {Telemetry} from "../telemetry";
3435

3536
/**
3637
* This interface describes the mock-debug specific launch attributes
@@ -58,12 +59,14 @@ export class DatabricksWorkflowDebugAdapterFactory
5859
private connection: ConnectionManager,
5960
private configModel: ConfigModel,
6061
context: ExtensionContext,
61-
bundleCommands: BundleCommands
62+
bundleCommands: BundleCommands,
63+
telemetry: Telemetry
6264
) {
6365
this.workflowRunner = new WorkflowRunner(
6466
context,
6567
bundleCommands,
66-
connection
68+
connection,
69+
telemetry
6770
);
6871
}
6972

packages/databricks-vscode/src/run/RunCommands.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
} from "../utils/shellUtils";
1313
import {CustomWhenContext} from "../vscode-objs/CustomWhenContext";
1414
import {WorkspaceFolderManager} from "../vscode-objs/WorkspaceFolderManager";
15+
import {Events, Telemetry} from "../telemetry";
1516

1617
/**
1718
* Run related commands
@@ -23,7 +24,8 @@ export class RunCommands {
2324
private readonly pythonExtension: MsPythonExtensionWrapper,
2425
private readonly featureManager: FeatureManager,
2526
private readonly context: ExtensionContext,
26-
private readonly customWhenContext: CustomWhenContext
27+
private readonly customWhenContext: CustomWhenContext,
28+
private readonly telemetry: Telemetry
2729
) {
2830
this.context.subscriptions.push(
2931
window.onDidChangeActiveTextEditor(async () =>
@@ -151,6 +153,11 @@ export class RunCommands {
151153
this.workspaceFolderManager.activeWorkspaceFolder,
152154
config
153155
);
156+
157+
this.telemetry.recordEvent(Events.DBCONNECT_RUN, {
158+
launchType: "debug",
159+
computeType: this.connection.serverless ? "serverless" : "cluster",
160+
});
154161
}
155162

156163
async runFileUsingDbconnect(resource?: Uri) {
@@ -180,5 +187,10 @@ export class RunCommands {
180187
bootstrapPath
181188
)} ${escapePathArgument(targetResource.fsPath)}`
182189
);
190+
191+
this.telemetry.recordEvent(Events.DBCONNECT_RUN, {
192+
launchType: "run",
193+
computeType: this.connection.serverless ? "serverless" : "cluster",
194+
});
183195
}
184196
}

packages/databricks-vscode/src/run/WorkflowRunner.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import Convert from "ansi-to-html";
1717
import {ConnectionManager} from "../configuration/ConnectionManager";
1818
import {WorkspaceFsWorkflowWrapper} from "../workspace-fs/WorkspaceFsWorkflowWrapper";
1919
import {BundleCommands} from "../ui/bundle-resource-explorer/BundleCommands";
20+
import {Events, Telemetry} from "../telemetry";
21+
import {ComputeType, WorkflowTaskType} from "../telemetry/constants";
2022

2123
export class WorkflowRunner implements Disposable {
2224
private panels = new Map<string, WorkflowOutputPanel>();
@@ -25,7 +27,8 @@ export class WorkflowRunner implements Disposable {
2527
constructor(
2628
private context: ExtensionContext,
2729
private bundleCommands: BundleCommands,
28-
private readonly connectionManager: ConnectionManager
30+
private readonly connectionManager: ConnectionManager,
31+
private readonly telemetry: Telemetry
2932
) {}
3033

3134
dispose() {
@@ -133,9 +136,14 @@ export class WorkflowRunner implements Disposable {
133136
}
134137
});
135138

139+
let taskType: WorkflowTaskType = "unknown";
140+
const computeType: ComputeType =
141+
cluster === undefined ? "serverless" : "cluster";
142+
const recordRun = this.telemetry.start(Events.WORKFLOW_RUN);
136143
try {
137144
const notebookType = await FileUtils.isNotebook(program);
138145
if (notebookType) {
146+
taskType = "notebook";
139147
let remoteFilePath: string =
140148
syncDestinationMapper.localToRemoteNotebook(program).path;
141149
if (syncDestinationMapper.remoteUri.type === "workspace") {
@@ -168,7 +176,9 @@ export class WorkflowRunner implements Disposable {
168176
token: panelCancellation.token,
169177
})
170178
);
179+
recordRun({success: true, taskType, computeType});
171180
} else {
181+
taskType = "python";
172182
const originalFileUri =
173183
syncDestinationMapper.localToRemote(program);
174184
const wrappedFile =
@@ -196,6 +206,7 @@ export class WorkflowRunner implements Disposable {
196206
});
197207
//TODO: Respone logs will contain bootstrap code path in the error stack trace. Remove it.
198208
panel.showStdoutResult(response.logs || "");
209+
recordRun({success: true, taskType, computeType});
199210
}
200211
} catch (e: unknown) {
201212
if (e instanceof ApiError) {
@@ -212,6 +223,7 @@ export class WorkflowRunner implements Disposable {
212223
message: (e as any).message,
213224
});
214225
}
226+
recordRun({success: false, taskType, computeType});
215227
}
216228
}
217229
}

packages/databricks-vscode/src/telemetry/constants.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ export enum Events {
2020
BUNDLE_INIT = "bundleInit",
2121
BUNDLE_SUB_PROJECTS = "bundleSubProjects",
2222
CONNECTION_STATE_CHANGED = "connectionStateChanged",
23+
COMPUTE_SELECTED = "computeSelected",
24+
WORKFLOW_RUN = "workflowRun",
25+
DBCONNECT_RUN = "dbconnectRun",
2326
}
2427
/* eslint-enable @typescript-eslint/naming-convention */
2528

@@ -35,6 +38,9 @@ export type BundleRunType =
3538
| "validate"
3639
| "partial-refresh"
3740
| "manual-input";
41+
export type WorkflowTaskType = "python" | "notebook" | "unknown";
42+
export type LaunchType = "run" | "debug";
43+
export type ComputeType = "cluster" | "serverless";
3844

3945
/** Documentation about all of the properties and metrics of the event. */
4046
type EventDescription<T> = {[K in keyof T]?: {comment?: string}};
@@ -162,6 +168,38 @@ export class EventTypes {
162168
comment: "The new state of the connection",
163169
},
164170
};
171+
[Events.COMPUTE_SELECTED]: EventType<{
172+
type: ComputeType;
173+
}> = {
174+
comment: "A compute was selected",
175+
type: {
176+
comment: "The type of the compute",
177+
},
178+
};
179+
[Events.WORKFLOW_RUN]: EventType<
180+
{
181+
success: boolean;
182+
taskType: WorkflowTaskType;
183+
computeType: ComputeType;
184+
} & DurationMeasurement
185+
> = {
186+
comment: "A workflow task was run",
187+
taskType: {
188+
comment: "The type of the workflow task",
189+
},
190+
computeType: {
191+
comment: "The type of the compute",
192+
},
193+
};
194+
[Events.DBCONNECT_RUN]: EventType<{
195+
launchType: LaunchType;
196+
computeType: ComputeType;
197+
}> = {
198+
comment: "A Databricks Connect debug run",
199+
computeType: {
200+
comment: "The type of the compute",
201+
},
202+
};
165203
}
166204

167205
/**

0 commit comments

Comments
 (0)