-
Notifications
You must be signed in to change notification settings - Fork 76
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
CLOUDP-237254: Set deploymet_type telemetry value in missing atlas deployments commands #2790
Conversation
@@ -71,6 +71,7 @@ func (opts *ListOpts) Run(ctx context.Context) error { | |||
} | |||
|
|||
func (opts *ListOpts) PostRun() error { | |||
opts.UpdateDeploymentTelemetry() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the expectation for list here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it will only set it if customer provides --type local/atlas, otherwise it will not set the type
AppendDeploymentType() | ||
} | ||
|
||
func NewDeploymentTypeTelemetry(opts *DeploymentOpts) DeploymentTelemetry { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] in go the recommendation is to accept interfaces and return structs, not the other way around
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can do that it may look a bit weird for DeploymentOpts
though as there we need to use DeploymentType
we'd need to cast with something like this (which works fine):
func NewDeploymentTypeTelemetry(opts DeploymentTelemetry) *DeploymentOpts {
return opts.(*DeploymentOpts)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a bit weird that you need to cast it to an interface if it accepts an interface but let's leave this for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the problem may be this is not really a "new" which should return a new object but this is more of a "cast as interface" thing
if opts.IsLocalDeploymentType() { | ||
telemetry.AppendOption(telemetry.WithDeploymentType(LocalCluster)) | ||
} else if opts.IsAtlasDeploymentType() { | ||
telemetry.AppendOption(telemetry.WithDeploymentType(AtlasCluster)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do the thing once
if opts.IsLocalDeploymentType() { | |
telemetry.AppendOption(telemetry.WithDeploymentType(LocalCluster)) | |
} else if opts.IsAtlasDeploymentType() { | |
telemetry.AppendOption(telemetry.WithDeploymentType(AtlasCluster)) | |
} | |
var deploymentType string | |
if opts.IsLocalDeploymentType() { | |
deploymentType = LocalCluster | |
} else if opts.IsAtlasDeploymentType() { | |
deploymentType = AtlasCluster | |
} | |
if deploymentType != "" { | |
telemetry.AppendOption(telemetry.WithDeploymentType()) | |
} |
I would also say maybe is better to do a switch over opts.DeploymentType
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i prefer the suggestion you gave above as it uses the standard methods to check if it's atlas or local
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Proposed changes
Jira ticket: CLOUDP-237254
We were sending telemetry events on selection and some commands, this is an approach to try to unify and append deployment_type value at 3 steps:
I'll add a follow-up PR adding the telemetry to all commands, but want to get a review on this approach first.
Checklist
make fmt
and formatted my codeFurther comments