Skip to content

Commit 0fc9009

Browse files
authored
Added metric for lifecycle.started used in Apps (#5202)
## Changes Added metric for lifecycle.started used in Apps ## Tests Added an acceptance test <!-- If your PR needs to be included in the release notes for next release, add a separate entry in NEXT_CHANGELOG.md as part of your PR. -->
1 parent 331fa0e commit 0fc9009

7 files changed

Lines changed: 86 additions & 0 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
bundle:
2+
name: test-bundle
3+
4+
resources:
5+
apps:
6+
myapp:
7+
name: my-app
8+
source_code_path: .
9+
lifecycle:
10+
started: true

acceptance/bundle/telemetry/deploy-app-lifecycle-started/out.test.toml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
2+
>>> [CLI] bundle deploy
3+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
4+
Deploying resources...
5+
✓ Deployment succeeded
6+
Updating deployment state...
7+
Deployment complete!
8+
9+
>>> cat out.requests.txt
10+
{
11+
"bool_values": [
12+
{
13+
"key": "local.cache.attempt",
14+
"value": true
15+
},
16+
{
17+
"key": "local.cache.miss",
18+
"value": true
19+
},
20+
{
21+
"key": "experimental.use_legacy_run_as",
22+
"value": false
23+
},
24+
{
25+
"key": "run_as_set",
26+
"value": false
27+
},
28+
{
29+
"key": "presets_name_prefix_is_set",
30+
"value": false
31+
},
32+
{
33+
"key": "python_wheel_wrapper_is_set",
34+
"value": false
35+
},
36+
{
37+
"key": "skip_artifact_cleanup",
38+
"value": false
39+
},
40+
{
41+
"key": "has_serverless_compute",
42+
"value": false
43+
},
44+
{
45+
"key": "has_classic_job_compute",
46+
"value": false
47+
},
48+
{
49+
"key": "has_classic_interactive_compute",
50+
"value": false
51+
},
52+
{
53+
"key": "app_lifecycle_started",
54+
"value": true
55+
}
56+
]
57+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
trace $CLI bundle deploy
2+
3+
trace cat out.requests.txt | jq 'select(has("path") and .path == "/telemetry-ext") | .body.protoLogs[] | fromjson | .entry.databricks_cli_log.bundle_deploy_event.experimental | {bool_values}'
4+
5+
rm out.requests.txt
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[EnvMatrix]
2+
DATABRICKS_BUNDLE_ENGINE = ["direct"]

bundle/metrics/metrics.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ const (
66
ArtifactBuildCommandIsSet = "artifact_build_command_is_set"
77
ArtifactFilesIsSet = "artifact_files_is_set"
88
PresetsNamePrefixIsSet = "presets_name_prefix_is_set"
9+
AppLifecycleStarted = "app_lifecycle_started"
910
)

bundle/phases/telemetry.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/databricks/cli/bundle"
99
"github.com/databricks/cli/bundle/config"
1010
"github.com/databricks/cli/bundle/libraries"
11+
"github.com/databricks/cli/bundle/metrics"
1112
"github.com/databricks/cli/libs/dyn"
1213
"github.com/databricks/cli/libs/log"
1314
"github.com/databricks/cli/libs/telemetry"
@@ -113,6 +114,13 @@ func LogDeployTelemetry(ctx context.Context, b *bundle.Bundle, errMsg string) {
113114
slices.Sort(clusterIds)
114115
slices.Sort(dashboardIds)
115116

117+
for _, app := range b.Config.Resources.Apps {
118+
if app != nil && app.Lifecycle != nil && app.Lifecycle.Started != nil {
119+
b.Metrics.SetBoolValue(metrics.AppLifecycleStarted, *app.Lifecycle.Started)
120+
break
121+
}
122+
}
123+
116124
// If the bundle UUID is not set, we use a default 0 value.
117125
bundleUuid := "00000000-0000-0000-0000-000000000000"
118126
if b.Config.Bundle.Uuid != "" {

0 commit comments

Comments
 (0)