Skip to content

Eliminate usagestatsdeprecated package

Administrator requested to merge eliminate_usage_stats_deprecated_package into main

Created by: dadlerj

I'm not 100% sure who to tag on this—please just let me know if any of you are not the right person!

This update does three things:

  • It (finally) eliminates the old usagestatsdeprecated package. For historical context, this was a redis-based precursor to our postgres-based internal event logging architecture. It was removed from most places a long time ago, but has remained the data source behind user counts for billing purposes (i.e., those that admins saw if they went to the Admin > Usage Statistics page, or if they queried users from the API). Why was this left in place for so long? There were concerns in the past that some customers wouldn't be using the postgres-based system, but I don't believe that's even possible anymore.

  • It updates all calls to that package to use usagestats instead. Similar functions already existed, so this didn't require much updating.

  • However, the usagestats package captures more events than the old usagestatsdeprecated one did! For example, usagestats records events from all users, not just registered ones. usagestats records backend events (e.g. the "ping" event which is logged every time the instance sends a ping, or events that fire when saved searches run, or events that fire when batch changes are created via API, etc. So I added a parameter to the database functions that return unique user counts to exclude system users.

One open question from my end: should I make it so that system users are excluded by default, instead of requiring the dev to set a flag?

I also identified a new bug while testing this: https://github.com/sourcegraph/sourcegraph/issues/38825

Test plan

  • Tested in local instance
  • Validated that all unit tests still worked

...Any other suggestions?

Screenshots

The new admin usage stats page on a fresh instance:

image

The corresponding list of events up to that point:

image

Note that even though there are a number of system user events, they are not showing up on the active users page.

Merge request reports

Loading