Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

[fix] Only trigger externalAcctSignup event when a new user is created#63843

Merged
pjlast merged 8 commits into
mainfrom
petrilast-src-461-bug-discovered-where-customers-on-v54x-with-http-auth-are
Jul 22, 2024
Merged

[fix] Only trigger externalAcctSignup event when a new user is created#63843
pjlast merged 8 commits into
mainfrom
petrilast-src-461-bug-discovered-where-customers-on-v54x-with-http-auth-are

Conversation

@pjlast

@pjlast pjlast commented Jul 16, 2024

Copy link
Copy Markdown
Contributor

Currently events are triggered whenever a user signs in with http-header auth. This is because of the GetAndSaveUser function always triggering an event.

However, before the new telemetry events, these events were only created when a new user was created.

This PR brings the new telemetry code in line with the old telemetry code to stop the massive amounts of spam caused by this event.

Closes SRC-461

Test plan

Adjust expected events in unit test.

Changelog

  • Fixed an issue where the http-header auth would cause a massive amount of event logs spam

@cla-bot cla-bot Bot added the cla-signed label Jul 16, 2024
@github-actions github-actions Bot added team/product-platform team/source Tickets under the purview of Source - the one Source to graph it all labels Jul 16, 2024
@pjlast pjlast changed the title Only store externalAuthSignup event if new user created or new extacc… [fix] Only trigger externalAcctSignup event when a new user is created Jul 16, 2024
@pjlast pjlast marked this pull request as ready for review July 16, 2024 07:28
@pjlast pjlast requested review from a team and bobheadxi July 16, 2024 07:28

@eseliger eseliger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I want Robert to review this, but code change in general LGTM, without knowing what the event was supposed to track 😬

@eseliger eseliger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ah: changelog entry :)

Comment thread cmd/frontend/auth/user.go
}()
// Record our V2 event.
recorder.Record(telemetryCtx, telemetryV2UserSignUpFeatureName, action, &telemetry.EventParameters{
Version: 2, // We've significantly refactored telemetryV2UserSignUpFeatureName occurrences

@bobheadxi bobheadxi Jul 16, 2024

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
Version: 2, // We've significantly refactored telemetryV2UserSignUpFeatureName occurrences
Version: 3, // We've significantly refactored telemetryV2UserSignUpFeatureName occurrences

This can help the data team drop all the "old" version of the events

Comment thread cmd/frontend/auth/user.go
telemetry.EventMetadata{
"serviceVariant": telemetry.Number(serviceVariant),
// Track the various outcomes of the massive signup closure above.
"newUserSaved": telemetry.Bool(newUserSaved),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we still need newUserSaved in the metadata, if we only record the event when newUserSaved?

@bobheadxi bobheadxi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for digging into this! Overall LGTM, but - doesn't this mean that we no longer record telemetry when you sign up with a new external account into an existing user?

i.e. I sign in with GitHub, then sign in with GitLab into the same user, we should now only get one event based on a reading of the code, and there will be no record of the second sign-in with GitLab. Maybe that's what we want anyway?

@pjlast

pjlast commented Jul 18, 2024

Copy link
Copy Markdown
Contributor Author

@bobheadxi we can do newUserSaved || extAcctAdded (or whatever the variable names are). I just went with what the legacy telemetry did. But if we want as much telemetry as possible (without overloading the system ofc) then we can go this route instead

@bobheadxi

Copy link
Copy Markdown
Member

@pjlast what you suggest sounds good to me! I also don't know how much data we want from this specifically, so I defer to your judgement as to what is useful as owner of this stuff. You could also check in with someone from the data analytics team about the specific scenarios they might be interested in, as the last time I was in this code is because they were looking at one of the events emitted here

@pjlast pjlast merged commit cd65951 into main Jul 22, 2024
@pjlast pjlast deleted the petrilast-src-461-bug-discovered-where-customers-on-v54x-with-http-auth-are branch July 22, 2024 11:42
sourcegraph-release-bot pushed a commit that referenced this pull request Jul 22, 2024
…d or external account is saved (#63843)

(cherry picked from commit cd65951)
craigfurman pushed a commit that referenced this pull request Jul 22, 2024
…ew user is created (#63975)

Currently events are triggered whenever a user signs in with
`http-header` auth. This is because of the `GetAndSaveUser` function
always triggering an event.

However, before the new telemetry events, these events were only created
when a new user was created.

This PR brings the new telemetry code in line with the old telemetry
code to stop the massive amounts of spam caused by this event.

Closes SRC-461

## Test plan

Adjust expected events in unit test.



## Changelog

- Fixed an issue where the `http-header` auth would cause a massive
amount of event logs spam


 <br> Backport cd65951 from #63843

Co-authored-by: Petri-Johan Last <petri.last@sourcegraph.com>
craigfurman referenced this pull request Jul 23, 2024
…ed (#64005)

Follow-up on https://github.com/sourcegraph/sourcegraph/pull/63843

Based on comments from
[this](https://sourcegraph.slack.com/archives/C04RG0JD8L9/p1721668767261719?thread_ts=1721661216.365709&amp;cid=C04RG0JD8L9)
Slack thread, it seems like the events causing the spam are ones where a
new ext acct is saved without a user being created. So if we want to fix
the spam we need to only save an event if a user was created.



## Test plan

Test updated.



## Changelog


 <br> Backport 777c7a0 from #64004

Co-authored-by: Petri-Johan Last <petri.last@sourcegraph.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

backport 5.5.x cla-signed team/product-platform team/source Tickets under the purview of Source - the one Source to graph it all

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants