Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set experimental mode in telemetry #6520

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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