Set experimental mode in telemetry (#6520)

* Set experimental mode in telemetry

* Add integration tests
This commit is contained in:
Philippe Martin
2023-01-23 12:47:43 +01:00
committed by GitHub
parent aa8a3c7c79
commit f089cba02a
4 changed files with 23 additions and 10 deletions

View File

@@ -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) {

View File

@@ -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 (
@@ -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

View File

@@ -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))
})
}))

View File

@@ -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))
})
})