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

CLOUDP-237254: Set deploymet_type telemetry value in missing atlas deployments commands #2790

Merged
merged 9 commits into from Mar 22, 2024

Conversation

blva
Copy link
Contributor

@blva blva commented Mar 20, 2024

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:

  1. pre-run (this covers if customer provides a flag but fails the command)
  2. on selection (this covers if customer goes through interactive flow but fails the command)
  3. post-run (this covers all cases where the command is successful)

I'll add a follow-up PR adding the telemetry to all commands, but want to get a review on this approach first.

Checklist

  • I have signed the MongoDB CLA
  • I have added tests that prove my fix is effective or that my feature works
  • I have added any necessary documentation in document requirements section listed in CONTRIBUTING.md (if appropriate)
  • I have addressed the @mongodb/docs-cloud-team comments (if appropriate)
  • I have updated test/README.md (if an e2e test has been added)
  • I have run make fmt and formatted my code

Further comments

@blva blva changed the title Set telemetry events for deployment_time to lower case CLOUDP-237254: Set deploymet_type telemetry value in missing atlas deployments commands Mar 20, 2024
@@ -71,6 +71,7 @@ func (opts *ListOpts) Run(ctx context.Context) error {
}

func (opts *ListOpts) PostRun() error {
opts.UpdateDeploymentTelemetry()
Copy link
Collaborator

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?

Copy link
Contributor Author

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

@blva blva marked this pull request as ready for review March 22, 2024 12:42
@blva blva requested a review from a team as a code owner March 22, 2024 12:42
@blva blva requested a review from fmenezes March 22, 2024 12:42
internal/cli/atlas/deployments/delete_test.go Outdated Show resolved Hide resolved
AppendDeploymentType()
}

func NewDeploymentTypeTelemetry(opts *DeploymentOpts) DeploymentTelemetry {
Copy link
Collaborator

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

Copy link
Contributor Author

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

Copy link
Collaborator

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

Copy link
Collaborator

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

Comment on lines 31 to 35
if opts.IsLocalDeploymentType() {
telemetry.AppendOption(telemetry.WithDeploymentType(LocalCluster))
} else if opts.IsAtlasDeploymentType() {
telemetry.AppendOption(telemetry.WithDeploymentType(AtlasCluster))
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do the thing once

Suggested change
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

Copy link
Contributor Author

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

internal/telemetry/event.go Outdated Show resolved Hide resolved
@blva blva requested a review from gssbzn March 22, 2024 15:18
Copy link
Collaborator

@gssbzn gssbzn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@blva blva merged commit ffb3129 into master Mar 22, 2024
17 checks passed
@blva blva deleted the CLOUDP-237254 branch March 22, 2024 17:16
@fmenezes fmenezes mentioned this pull request Apr 5, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants