Code AI platform with Code Search & Cody
Go to file
Robert Lin e835a66c76
telemetrygateway: add exporter and service (#56699)
This change adds:

- telemetry export background jobs: flagged behind `TELEMETRY_GATEWAY_EXPORTER_EXPORT_ADDR`, default empty => disabled
- telemetry redaction: configured in package `internal/telemetry/sensitivemetadataallowlist`
- telemetry-gateway service receiving events and forwarding it to a pub/sub topic (or just logging it, as configured in local dev)
- utilities for easily creating an event recorder: `internal/telemetry/telemetryrecorder`
Notes:

- all changes are feature-flagged to some degree, off by default, so the merge should be fairly low-risk.
- we decided that transmitting the full license key continues to be the way to go. we transmit it once per stream and attach it on all events in the telemetry-gateway. there is no auth mechanism at the moment
- GraphQL return type `EventLog.Source` is now a plain string instead of string enum. This should not be a breaking change in our clients, but must be made so that our generated V2 events do not break requesting of event logs

Stacked on https://github.com/sourcegraph/sourcegraph/pull/56520

Closes https://github.com/sourcegraph/sourcegraph/issues/56289
Closes https://github.com/sourcegraph/sourcegraph/issues/56287

## Test plan

Add an override to make the export super frequent:

```
env:
  TELEMETRY_GATEWAY_EXPORTER_EXPORT_INTERVAL: "10s"
  TELEMETRY_GATEWAY_EXPORTER_EXPORTED_EVENTS_RETENTION: "5m"
```

Start sourcegraph:

```
sg start
```

Enable `telemetry-export` featureflag (from https://github.com/sourcegraph/sourcegraph/pull/56520)

Emit some events in GraphQL:

```gql
mutation {
  telemetry {
    recordEvents(events:[{
      feature:"foobar"
      action:"view"
      source:{
        client:"WEB"
      }
      parameters:{
        version:0
      }
    }]) {
      alwaysNil
    }
  }
```

See series of log events:

```
[         worker] INFO worker.telemetrygateway-exporter telemetrygatewayexporter/telemetrygatewayexporter.go:61 Telemetry Gateway export enabled - initializing background routines
[         worker] INFO worker.telemetrygateway-exporter telemetrygatewayexporter/exporter.go:99 exporting events {"maxBatchSize": 10000, "count": 1}
[telemetry-g...y] INFO telemetry-gateway.pubsub pubsub/topic.go:115 Publish {"TraceId": "7852903434f0d2f647d397ee83b4009b", "SpanId": "8d945234bccf319b", "message": "{\"event\":{\"id\":\"dc96ae84-4ac4-4760-968f-0a0307b8bb3d\",\"timestamp\":\"2023-09-19T01:57:13.590266Z\",\"feature\":\"foobar\", ....
```

Build:

```
export VERSION="insiders"
bazel run //cmd/telemetry-gateway:candidate_push --config darwin-docker --stamp --workspace_status_command=./dev/bazel_stamp_vars.sh -- --tag $VERSION --repository us.gcr.io/sourcegraph-dev/telemetry-gateway
```

Deploy: https://github.com/sourcegraph/managed-services/pull/7

Add override:

```yaml
env:
  # Port required. TODO: What's the best way to provide gRPC addresses, such that a
  # localhost address is also possible?
  TELEMETRY_GATEWAY_EXPORTER_EXPORT_ADDR: "https://telemetry-gateway.sgdev.org:443"
```

Repeat the above (`sg start` and emit some events):

```
[         worker] INFO worker.telemetrygateway-exporter telemetrygatewayexporter/exporter.go:94 exporting events {"maxBatchSize": 10000, "count": 6}
[         worker] INFO worker.telemetrygateway-exporter telemetrygatewayexporter/exporter.go:113 events exported {"maxBatchSize": 10000, "succeeded": 6}
[         worker] INFO worker.telemetrygateway-exporter telemetrygatewayexporter/exporter.go:94 exporting events {"maxBatchSize": 10000, "count": 1}
[         worker] INFO worker.telemetrygateway-exporter telemetrygatewayexporter/exporter.go:113 events exported {"maxBatchSize": 10000, "succeeded": 1}
```
2023-09-20 05:20:15 +00:00
.aspect Bump NodeJS to v18 (#56546) 2023-09-13 17:48:33 +02:00
.buildkite bazel: move backcompat tests to their own pipeline (#55489) 2023-08-22 16:57:25 +00:00
.github label-notify: add search-platform and apis (#56766) 2023-09-19 15:09:22 +02:00
.vscode Remove GitHub proxy service (#56485) 2023-09-14 19:43:40 +02:00
client update code references to "Sourcegraph App" -> "Cody App" (#56747) 2023-09-19 12:31:12 -10:00
cmd telemetrygateway: add exporter and service (#56699) 2023-09-20 05:20:15 +00:00
dev telemetrygateway: add exporter and service (#56699) 2023-09-20 05:20:15 +00:00
doc telemetrygateway: add exporter and service (#56699) 2023-09-20 05:20:15 +00:00
docker-images Let enry decide the filetype unconditionally for code highlighting (#56559) 2023-09-19 15:50:32 +00:00
enterprise telemetrygateway: add exporter and service (#56699) 2023-09-20 05:20:15 +00:00
internal telemetrygateway: add exporter and service (#56699) 2023-09-20 05:20:15 +00:00
lib telemetrygateway: add exporter and service (#56699) 2023-09-20 05:20:15 +00:00
migrations telemetry: init internal APIs and events cache store layer (#56520) 2023-09-19 21:53:42 -07:00
monitoring grpc: add dashboard for site-configuration service to frontend page (#56799) 2023-09-19 22:40:20 +00:00
schema grpc: add dashboard for site-configuration service to frontend page (#56799) 2023-09-19 22:40:20 +00:00
src-tauri app: Move out of enterprise and merge with cmd/sourcegraph-oss (#56447) 2023-09-08 16:23:46 +02:00
testing Merge enterprise and non-enterprise server images (#56446) 2023-09-11 14:39:27 +02:00
third_party local: fix issues when cross-compiling syntax-highlighter to produce a container image on Mac machines (#55969) 2023-08-22 12:46:43 +02:00
third-party-licenses chore: update third-party licenses (#56335) 2023-09-18 07:45:46 +00:00
ui/assets [Search Jobs]: Add special zero state for the initial empty state (#56516) 2023-09-13 13:17:03 -03:00
windows/installer/cody Disable services that are causing issues on Windows. (#54263) 2023-06-27 19:08:53 +00:00
wolfi-images updating wolfi images for realease 5.1.9 (#56552) 2023-09-12 12:53:37 -04:00
wolfi-packages update p4-fusion version to 1.13 (#56780) 2023-09-19 11:12:34 -07:00
.bazel_fix_commands.json bazel: add command sets that uses bazel under the hood (#48460) 2023-03-02 11:31:51 +01:00
.bazelignore Remove completions review tool (#55201) 2023-07-21 17:03:16 +02:00
.bazeliskrc build: update to Aspect CLI 5.5.4 (#54468) 2023-06-29 22:44:05 -07:00
.bazelrc Bump NodeJS to v18 (#56546) 2023-09-13 17:48:33 +02:00
.bazelversion Update bazel to 6.1.1 (#50472) 2023-04-11 10:51:21 +02:00
.browserslistrc web: migrate from yarn to pnpm (#46143) 2023-01-11 19:50:09 -08:00
.dockerignore web: migrate from yarn to pnpm (#46143) 2023-01-11 19:50:09 -08:00
.editorconfig chore: Add .lua to editorconfig. (#44267) 2022-11-11 15:25:32 +08:00
.eslintignore bazel: implement custom ESLint Bazel rule (#52062) 2023-05-22 04:05:45 -07:00
.eslintrc.js Eslint fix type imports (#54920) 2023-08-10 21:12:31 +02:00
.gitattributes github: show bazel diff again (#54719) 2023-07-07 16:43:45 +00:00
.gitignore cody web: provide suggestions in context selector (#56039) 2023-09-11 04:25:47 +05:30
.graphqlrc.yml
.hadolint.yaml bump comby version to 1.7.1 (#35830) 2022-05-20 20:12:01 -07:00
.mailmap mailmap: add entries for Eric and Renovate (#50966) 2023-04-25 09:42:22 +02:00
.mocharc.js build: still need BAZEL_BINDIR for webpack_bundle custom rule (#48796) 2023-03-07 20:02:11 -08:00
.npmrc pnpm: remove update notifier message (#51630) 2023-05-10 08:53:39 +02:00
.percy.yml ci: percy defer snapshots upload (#54116) 2023-06-25 18:57:49 -07:00
.pre-commit-config.yaml dev: add a pre-commit hook to searches for tokens (#56499) 2023-09-12 16:20:44 +02:00
.prettierignore bazel: move backcompat tests to their own pipeline (#55489) 2023-08-22 16:57:25 +00:00
.stylelintignore rework plugin structure and implement frontside blogpost (#46883) 2023-02-15 11:49:51 +02:00
.stylelintrc.json web: drop bootstrap depenedency (#41401) 2022-09-07 03:11:26 -07:00
.tool-versions Bump NodeJS to v18 (#56546) 2023-09-13 17:48:33 +02:00
.trivyignore ci: ignore benign CVE-2021-43816 in prometheus (#31069) 2022-02-11 16:49:10 +00:00
babel.config.jest.js bazel: fix the web application bundle in Bazel (#50383) 2023-04-10 21:16:12 -07:00
babel.config.js bazel: fix the web application bundle in Bazel (#50383) 2023-04-10 21:16:12 -07:00
BUILD.bazel Allow to run e2e tests locally (#55998) 2023-08-29 11:08:47 -05:00
CHANGELOG.app.md update code references to "Sourcegraph App" -> "Cody App" (#56747) 2023-09-19 12:31:12 -10:00
CHANGELOG.md Update CHANGELOG.md for PR 56697 (#56806) 2023-09-19 19:55:15 -04:00
CODENOTIFY nix: update pnpm hash (#51512) 2023-05-05 12:51:59 +00:00
CONTRIBUTING.md Docs: Fix docs page link in main CONTRIBUTING.md (#45160) 2022-12-05 14:57:45 +01:00
deps.bzl deps: upgrade github.com/sourcegraph/log (#56732) 2023-09-20 03:02:57 +00:00
doc.go
eslint-relative-formatter.js bazel: implement custom ESLint Bazel rule (#52062) 2023-05-22 04:05:45 -07:00
flake.lock sg: use bazel run universtal-ctags (#55944) 2023-08-18 16:02:46 +00:00
flake.nix sg: use bazel run universtal-ctags (#55944) 2023-08-18 16:02:46 +00:00
gen.go chore: Update go-mockgen (#44305) 2022-11-11 19:24:00 +00:00
go.mod deps: upgrade github.com/sourcegraph/log (#56732) 2023-09-20 03:02:57 +00:00
go.sum deps: upgrade github.com/sourcegraph/log (#56732) 2023-09-20 03:02:57 +00:00
graphql-schema-linter.config.js
gulpfile.js web: drop legacy GraphQL schema generator (#45945) 2022-12-25 18:10:20 -08:00
jest.config.base.js bazel: wildcard jest tests (#49282) 2023-03-17 03:38:49 -07:00
jest.config.js tests: use glob for jest projects field (#29681) 2022-01-13 01:11:52 -08:00
jest.snapshot-resolver.js bazel: wildcard jest tests (#49282) 2023-03-17 03:38:49 -07:00
junit.xml SGM-6462 - Add About Sourcegraph CTA to main nav in dotcom (#56228) 2023-09-05 13:41:23 -04:00
LICENSE relicense all paths other than MIT licensed code, client/cody*, jetbrains, VS code, and browser extension to enterprise (#53345) (#53345) 2023-06-13 10:28:11 -07:00
LICENSE.enterprise
lighthouserc.js web: migrate from yarn to pnpm (#46143) 2023-01-11 19:50:09 -08:00
linter_deps.bzl bzl: port go compiler directives linter from sg lint to nogo (#54485) 2023-06-30 14:31:15 +02:00
mockgen.temp.yaml Add GraphQL read resolvers for code hosts (#55882) 2023-08-21 13:10:22 +00:00
mockgen.test.yaml Use external service rate limiters with redis (#56428) 2023-09-12 16:01:35 +02:00
mockgen.yaml mocks: Reorganize mock definitions into multiple files (#36967) 2022-06-27 20:59:16 +00:00
nogo_config.json Move enterprise/internal/batches package to internal/batches (#54855) 2023-07-12 08:42:35 -06:00
package.json Bump NodeJS to v18 (#56546) 2023-09-13 17:48:33 +02:00
pnpm-lock.yaml bump cody-shared package version (#56770) 2023-09-19 11:40:47 -04:00
pnpm-workspace.yaml cody: development branch (#49761) 2023-03-23 20:41:11 +01:00
postcss.config.js
prettier.config.js clean up Cody CSS to increase shareability and improve display in web app (#50279) 2023-04-03 12:29:05 -07:00
README.md relicense all paths other than MIT licensed code, client/cody*, jetbrains, VS code, and browser extension to enterprise (#53345) (#53345) 2023-06-13 10:28:11 -07:00
renovate.json chore: add test plans to bot and release tool PRs (#31351) 2022-02-22 07:53:25 -08:00
SECURITY.md
service-catalog.yaml lib/servicecatalog: init to distribute catalog (#46999) 2023-01-26 17:22:27 -08:00
sg.config.yaml telemetrygateway: add exporter and service (#56699) 2023-09-20 05:20:15 +00:00
shell.nix Bump NodeJS to v18 (#56546) 2023-09-13 17:48:33 +02:00
sonar-project.properties Use Buildkite to run Sonarcloud (#54875) 2023-07-21 12:16:03 -04:00
stamp_tags.bzl Switch to OCI/Wolfi based image (#52693) 2023-06-02 12:12:52 +02:00
svgo.config.js Performance: Optimize static SVG assets with SVGO (#26285) 2021-10-27 15:27:36 +01:00
tsconfig.all.json remove cody code that was moved to separate cody repo (#54729) 2023-07-10 00:31:47 -10:00
tsconfig.base.json web: fix pnpm-lock issue (#47478) 2023-02-09 22:04:31 -08:00
tsconfig.eslint.json web: fix pnpm-lock issue (#47478) 2023-02-09 22:04:31 -08:00
WORKSPACE Bump NodeJS to v18 (#56546) 2023-09-13 17:48:33 +02:00

DocsContributingTwitterDiscord

Build status Scorecard Latest release Discord Contributors


Sourcegraph makes it easy to read, write, and fix code—even in big, complex codebases.

  • Code search: Search all of your repositories across all branches and all code hosts.
  • Code intelligence: Navigate code, find references, see code owners, trace history, and more.
  • Fix and refactor: Roll out large-scale changes to many repositories at once and track big migrations.

Getting started



Development

Refer to the Developing Sourcegraph guide to get started.

Documentation

The doc directory has additional documentation for developing and understanding Sourcegraph:

License

This repository contains primarily non-OSS-licensed files, and some OSS licensed files (for example, IDE extensions). We maintain one repository rather than two separate repositories mainly for development convenience.

See the LICENSE for an explanation of how files are licensed.