telemetry-export: 5.2.1 default enablement#57605
Conversation
13471bc to
2d66db1
Compare
|
Current dependencies on/for this PR: This comment was auto-generated by Graphite. |
2d66db1 to
4cb709f
Compare
4cb709f to
46b74db
Compare
46b74db to
032d2b4
Compare
|
Codenotify: Notifying subscribers in CODENOTIFY files for diff b621b8b...cce3f4c.
|
df2250a to
be4bd05
Compare
|
|
||
| // SetMockExportMode configures the store's mock export mode for use in testing. | ||
| // | ||
| // ⚠️ Use in tests only! |
There was a problem hiding this comment.
Wondering if we should do similar thing as https://github.com/sourcegraph/sourcegraph/blob/2af7aecbf68cdeab3e2a038577b8dee68b23bd57/internal/lazyregexp/lazyre.go#L104
to programmatically prevent misuse outside tests.
There was a problem hiding this comment.
This seems a bit delicate, and is only used on one place in Sourcegraph right now, so I'm a bit hesitant to add this 😅
I think hopefully the need to cast this into a mock interface and call a method with "mock" in the name is a sufficient deterrence
There was a problem hiding this comment.
Usually I would have this test helpers accept a testing.T but because it's a bit engrained into the implementatin, and we shouldn't import testing due to side effects as part of the program, I opted not to here
Co-authored-by: Joe Chen <joe@sourcegraph.com>
e631e17 to
ad60b04
Compare
…telemetry-export_5.2.1_default_enablement
|
The backport to To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-5.2 5.2
# Navigate to the new working tree
cd .worktrees/backport-5.2
# Create a new branch
git switch --create backport-57605-to-5.2
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 20c771bc3194152e81f30ea2a4529e4f5fcd7fd4
# Push it to GitHub
git push --set-upstream origin backport-57605-to-5.2
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-5.2If you encouter conflict, first resolve the conflict and stage all files, then run the commands below: git cherry-pick --continue
# Push it to GitHub
git push --set-upstream origin backport-57605-to-5.2
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-5.2
|
|
Opened backport manually in #57681 |
This change implements the license-based enforcement of telemetry export as outlined in [the plan for the 5.2.1 release](https://docs.google.com/document/d/1Z1Yp7G61WYlQ1B4vO5-mIXVtmvzGmD7PqYHNBQV-2Ik/edit#bookmark=id.w10771x4dx7y). Most of this functionality has been tested in various environments for some time: dotcom, s2, rctest, cody-dev, demo, and 9 trial Cloud instances (with more to be enabled before the final 5.2.1 release, see sourcegraph/customer#2416), processing about 2 million events in the last 7 days (a small set of events currently instrumented in the new system). The following changes are made to how this feature is enabled: 1. An export enablement mode is added to package `internal/licensing` that evaluates what we export based on the configured license, configured based on license plan or tags in the license, but the levels are unlikely to change): - all events (default going forward) - cody-only (`Feature=~'cody|cody.*'`), since Cody events are a special case covered by terms of use - nothing (air-gapped instance) 3. When persisting events to the export queue, the enablement mode is checked to decide if anything gets written to the database. 4. Exporter background workers are now enabled by default, checking the mode on each iteration to decide if we need to run the exporter at all. We also create a new connection to Telemetry Gateway on each run now, to ensure Telemetry Gateway downtime does not break instances. The feature flag `telemetry-export` and env var `TELEMETRY_GATEWAY_EXPORTER_EXPORT_ADDR` remain configurable, but in a default-enabled state - in 5.2.2, the ability to disable these capabilities via configuration will be removed, and the license-based mechanism will become the only way to disable this feature, as requested in the [telemetry export rollout plan](https://docs.google.com/document/d/1Z1Yp7G61WYlQ1B4vO5-mIXVtmvzGmD7PqYHNBQV-2Ik/edit#bookmark=id.w10771x4dx7y). Parts that require follow-up changes are denoted with `TODO(5.2.2)` comments. A changelog entry and docs are added in https://github.com/sourcegraph/sourcegraph/pull/57606 Part of https://github.com/sourcegraph/sourcegraph/issues/56816 - [x] New unit/integration test coverage - [x] Existing tests pass with minimal changes - [x] Manual testing: - Comment out `sg.config.yaml` line `TELEMETRY_GATEWAY_EXPORTER_EXPORT_ADDR: "http://127.0.0.1:10080"` and add `TELEMETRY_GATEWAY_EXPORTER_EXPORT_INTERVAL: "30s"`, exporter starts by default. Run some searches to generate events, and see that worker doesn't export anything, as the default mode for an older license is to disable export (seen in logs and metrics) - Set `dev-private` license to a new, real one from sourcegraph.com, remove all mentions of `SOURCEGRAPH_LICENSE_GENERATION_KEY` from `sg.config.yaml`, repeat above, events now export (seen in logs and metrics): `[ worker] INFO worker.telemetrygateway-exporter telemetrygatewayexporter/exporter.go:129 events exported {"maxBatchSize": 10000, "succeeded": 1}` --------- Co-authored-by: Joe Chen <joe@sourcegraph.com> (cherry picked from commit 20c771b)
…57681) telemetry-export: 5.2.1 default enablement (#57605) This change implements the license-based enforcement of telemetry export as outlined in [the plan for the 5.2.1 release](https://docs.google.com/document/d/1Z1Yp7G61WYlQ1B4vO5-mIXVtmvzGmD7PqYHNBQV-2Ik/edit#bookmark=id.w10771x4dx7y). Most of this functionality has been tested in various environments for some time: dotcom, s2, rctest, cody-dev, demo, and 9 trial Cloud instances (with more to be enabled before the final 5.2.1 release, see sourcegraph/customer#2416), processing about 2 million events in the last 7 days (a small set of events currently instrumented in the new system). The following changes are made to how this feature is enabled: 1. An export enablement mode is added to package `internal/licensing` that evaluates what we export based on the configured license, configured based on license plan or tags in the license, but the levels are unlikely to change): - all events (default going forward) - cody-only (`Feature=~'cody|cody.*'`), since Cody events are a special case covered by terms of use - nothing (air-gapped instance) 3. When persisting events to the export queue, the enablement mode is checked to decide if anything gets written to the database. 4. Exporter background workers are now enabled by default, checking the mode on each iteration to decide if we need to run the exporter at all. We also create a new connection to Telemetry Gateway on each run now, to ensure Telemetry Gateway downtime does not break instances. The feature flag `telemetry-export` and env var `TELEMETRY_GATEWAY_EXPORTER_EXPORT_ADDR` remain configurable, but in a default-enabled state - in 5.2.2, the ability to disable these capabilities via configuration will be removed, and the license-based mechanism will become the only way to disable this feature, as requested in the [telemetry export rollout plan](https://docs.google.com/document/d/1Z1Yp7G61WYlQ1B4vO5-mIXVtmvzGmD7PqYHNBQV-2Ik/edit#bookmark=id.w10771x4dx7y). Parts that require follow-up changes are denoted with `TODO(5.2.2)` comments. A changelog entry and docs are added in https://github.com/sourcegraph/sourcegraph/pull/57606 Part of https://github.com/sourcegraph/sourcegraph/issues/56816 - [x] New unit/integration test coverage - [x] Existing tests pass with minimal changes - [x] Manual testing: - Comment out `sg.config.yaml` line `TELEMETRY_GATEWAY_EXPORTER_EXPORT_ADDR: "http://127.0.0.1:10080"` and add `TELEMETRY_GATEWAY_EXPORTER_EXPORT_INTERVAL: "30s"`, exporter starts by default. Run some searches to generate events, and see that worker doesn't export anything, as the default mode for an older license is to disable export (seen in logs and metrics) - Set `dev-private` license to a new, real one from sourcegraph.com, remove all mentions of `SOURCEGRAPH_LICENSE_GENERATION_KEY` from `sg.config.yaml`, repeat above, events now export (seen in logs and metrics): `[ worker] INFO worker.telemetrygateway-exporter telemetrygatewayexporter/exporter.go:129 events exported {"maxBatchSize": 10000, "succeeded": 1}` --------- Co-authored-by: Joe Chen <joe@sourcegraph.com> (cherry picked from commit 20c771b)

This change implements the license-based enforcement of telemetry export as outlined in the plan for the 5.2.1 release.
Most of this functionality has been tested in various environments for some time: dotcom, s2, rctest, cody-dev, demo, and 9 trial Cloud instances (with more to be enabled before the final 5.2.1 release, see https://github.com/sourcegraph/customer/issues/2416), processing about 2 million events in the last 7 days (a small set of events currently instrumented in the new system). The following changes are made to how this feature is enabled:
internal/licensingthat evaluates what we export based on the configured license, configured based on license plan or tags in the license, but the levels are unlikely to change):Feature=~'cody|cody.*'), since Cody events are a special case covered by terms of useThe feature flag
telemetry-exportand env varTELEMETRY_GATEWAY_EXPORTER_EXPORT_ADDRremain configurable, but in a default-enabled state - in 5.2.2, the ability to disable these capabilities via configuration will be removed, and the license-based mechanism will become the only way to disable this feature, as requested in the telemetry export rollout plan. Parts that require follow-up changes are denoted withTODO(5.2.2)comments.A changelog entry and docs are added in https://github.com/sourcegraph/sourcegraph/pull/57606
Part of https://github.com/sourcegraph/sourcegraph/issues/56816
Test plan
sg.config.yamllineTELEMETRY_GATEWAY_EXPORTER_EXPORT_ADDR: "http://127.0.0.1:10080"and addTELEMETRY_GATEWAY_EXPORTER_EXPORT_INTERVAL: "30s", exporter starts by default. Run some searches to generate events, and see that worker doesn't export anything, as the default mode for an older license is to disable export (seen in logs and metrics)dev-privatelicense to a new, real one from sourcegraph.com, remove all mentions ofSOURCEGRAPH_LICENSE_GENERATION_KEYfromsg.config.yaml, repeat above, events now export (seen in logs and metrics):[ worker] INFO worker.telemetrygateway-exporter telemetrygatewayexporter/exporter.go:129 events exported {"maxBatchSize": 10000, "succeeded": 1}