Skip to content

Commit

Permalink
Set experimental mode in telemetry (#6520)
Browse files Browse the repository at this point in the history
* Set experimental mode in telemetry

* Add integration tests
  • Loading branch information
feloy authored Jan 23, 2023
1 parent aa8a3c7 commit f089cba
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
2 changes: 2 additions & 0 deletions pkg/odo/genericclioptions/runnable.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ func GenericRun(o Runnable, cmd *cobra.Command, args []string) error {
// set value for telemetry status in context so that we do not need to call IsTelemetryEnabled every time to check its status
scontext.SetTelemetryStatus(cmd.Context(), segment.IsTelemetryEnabled(userConfig, envConfig))

scontext.SetExperimentalMode(cmd.Context(), envConfig.OdoExperimentalMode)

// Send data to telemetry in case of user interrupt
captureSignals := []os.Signal{syscall.SIGHUP, syscall.SIGTERM, syscall.SIGQUIT, os.Interrupt}
go commonutil.StartSignalWatcher(captureSignals, func(receivedSignal os.Signal) {
Expand Down
25 changes: 15 additions & 10 deletions pkg/segment/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ import (
)

const (
Caller = "caller"
ComponentType = "componentType"
ClusterType = "clusterType"
TelemetryStatus = "isTelemetryEnabled"
DevfileName = "devfileName"
Language = "language"
ProjectType = "projectType"
NOTFOUND = "not-found"
InteractiveMode = "interactive"
Flags = "flags"
Caller = "caller"
ComponentType = "componentType"
ClusterType = "clusterType"
TelemetryStatus = "isTelemetryEnabled"
DevfileName = "devfileName"
Language = "language"
ProjectType = "projectType"
NOTFOUND = "not-found"
InteractiveMode = "interactive"
ExperimentalMode = "experimental"
Flags = "flags"
)

const (
Expand Down Expand Up @@ -122,6 +123,10 @@ func SetInteractive(ctx context.Context, interactive bool) {
setContextProperty(ctx, InteractiveMode, interactive)
}

func SetExperimentalMode(ctx context.Context, value bool) {
setContextProperty(ctx, ExperimentalMode, value)
}

// SetFlags sets flags property for telemetry to record what flags were used
func SetFlags(ctx context.Context, flags *pflag.FlagSet) {
var changedFlags []string
Expand Down
5 changes: 5 additions & 0 deletions tests/integration/cmd_dev_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ var _ = Describe("odo dev command tests", func() {
Expect(td.Properties.CmdProperties[segment.ProjectType]).To(ContainSubstring("nodejs"))
Expect(td.Properties.CmdProperties).Should(HaveKey(segment.Caller))
Expect(td.Properties.CmdProperties[segment.Caller]).To(BeEmpty())
experimentalValue := false
if podman {
experimentalValue = true
}
Expect(td.Properties.CmdProperties[segment.ExperimentalMode]).To(Equal(experimentalValue))
})
}))

Expand Down
1 change: 1 addition & 0 deletions tests/integration/cmd_devfile_deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ ComponentSettings:
Expect(td.Properties.CmdProperties[segment.Flags]).To(BeEmpty())
Expect(td.Properties.CmdProperties).Should(HaveKey(segment.Caller))
Expect(td.Properties.CmdProperties[segment.Caller]).To(BeEmpty())
Expect(td.Properties.CmdProperties[segment.ExperimentalMode]).To(Equal(false))
})
})

Expand Down

0 comments on commit f089cba

Please sign in to comment.