Skip to content

usage-data: restrict scraped events to an allowlist

Administrator requested to merge usage-data/allow-list into main

Created by: coury-clark

Closes https://github.com/sourcegraph/sourcegraph/issues/39094

Implements an allowlist for events that are keyed by name. Currently this is stored in a database table. See linked issue for some thoughts on how this could be improved.

Test plan

To test locally:

Set up gcp credentials

gcloud auth application-default login

Start sg

GOOGLE_APPLICATION_CREDENTIALS="$HOME/.config/gcloud/application_default_credentials.json" sg start ...

Add configuration to the site config

    "exportUsageTelemetry": {
      "enabled": true,
      "topicProjectName": "sourcegraph-dogfood",
      "topicName": "usage-data-testing"
    },

Adding InsightHover to the allowlist and resetting the scraper state:

[         worker] INFO worker.export-usage-telemetry telemetry/telemetry_job.go:127 fetching events from bookmark {"bookmark_id": 0}
[         worker] INFO worker.export-usage-telemetry telemetry/telemetry_job.go:138 telemetryHandler executed {"event count": 448, "maxId": 20578}
select count(*) from event_logs where name = 'InsightHover';
count
448

Merge request reports

Loading