insights: Add Total Insights to critical telemetry
Created by: CristinaBirkel
Closes: https://github.com/sourcegraph/sourcegraph/issues/31078
Description
This adds a new field into critical telemetry for totalInsights
.
The way I did this was to use the existing entry that we write into event_logs
and calculate the information based on the stats we are already reporting on. Namely, summing over totals in: CodeInsightsUsageStatistics.InsightTotalCounts.ViewCounts
. This seemed like a lightweight solution.
The other way I could have done this would be to write a separate entry into event_logs
with just this total, and read from there. That might be more straight-forward, but would be more code and db calls and it didn't seem worth it in this case.
Let me know what you think!
Test plan
I tested this locally by disabling non-critical telemetry and verifying that totalInsights
showed up with the correct count. I then re-enabled non-critical telemetry and verified that the new totalInsights
count showed up along with the rest of the non-critical insight telemetry data.