mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 17:11:49 +00:00
Pings: track if "cody.contextFilters" field is configured in site config (#62080)
This commit is contained in:
parent
7f67d2ea75
commit
cfe13d0beb
@ -21,6 +21,8 @@ All notable changes to Sourcegraph are documented in this file.
|
||||
- Added syntax highlighting for the [Pkl](https://pkl-lang.org/) configuration language. [#61478](https://github.com/sourcegraph/sourcegraph/pull/61478)
|
||||
- New `rev:at.time()` search filter that allows you to search a branch at a point in time. [#61513](https://github.com/sourcegraph/sourcegraph/pull/61513)
|
||||
- "cody.contextFilters" field to the site config. Admins can set include and exclude rules to define which repositories Cody can use as context in its requests to third-party LLMs. [#61101](https://github.com/sourcegraph/sourcegraph/pull/61101), [#61641](https://github.com/sourcegraph/sourcegraph/pull/61641)
|
||||
- Added whether "cody.contextFilters" field is configured in the site config to pings. [#62080](https://github.com/sourcegraph/sourcegraph/pull/62080)
|
||||
- Added exhaustive logging for all gRPC requests sent to gitserver. This feature is off by default, and can be enabled by setting the `SRC_GITSERVER_EXHAUSTIVE_LOGGING_ENABLED` environment variable to `true`. [#61270](https://github.com/sourcegraph/sourcegraph/pull/61270)
|
||||
- Added exhaustive logging for all gRPC requests sent to gitserver service gitserver. This feature is off by default, and can be enabled by setting the `SRC_GITSERVER_EXHAUSTIVE_LOGGING_ENABLED` environment variable to `true`. [#61270](https://github.com/sourcegraph/sourcegraph/pull/61270)
|
||||
- Added exhaustive logging for all gRPC requests sent to the repository service in gitserver. This feature is off by default, and can be enabled by setting the `SRC_GITSERVER_EXHAUSTIVE_LOGGING_ENABLED` environment variable to `true`. [#62158](https://github.com/sourcegraph/sourcegraph/pull/62158)
|
||||
|
||||
|
||||
@ -435,6 +435,7 @@ export const SiteAdminPingsPage: React.FunctionComponent<React.PropsWithChildren
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Whether Cody context filters are configured in the site config (true/false)</li>
|
||||
</ul>
|
||||
{updatesDisabled && <Text>All telemetry is disabled.</Text>}
|
||||
</Container>
|
||||
|
||||
@ -600,13 +600,6 @@ func updateBody(ctx context.Context, logger log.Logger, db database.DB) (io.Read
|
||||
if err != nil {
|
||||
logFunc("getAndMarshalBatchChangesUsageJSON failed", log.Error(err))
|
||||
}
|
||||
// We don't bother doing this on Sourcegraph.com as it is expensive and not needed.
|
||||
if !dotcom.SourcegraphDotComMode() {
|
||||
r.GrowthStatistics, err = getAndMarshalGrowthStatisticsJSON(ctx, db)
|
||||
if err != nil {
|
||||
logFunc("getAndMarshalGrowthStatisticsJSON failed", log.Error(err))
|
||||
}
|
||||
}
|
||||
r.SavedSearches, err = getAndMarshalSavedSearchesJSON(ctx, db)
|
||||
if err != nil {
|
||||
logFunc("getAndMarshalSavedSearchesJSON failed", log.Error(err))
|
||||
@ -672,14 +665,6 @@ func updateBody(ctx context.Context, logger log.Logger, db database.DB) (io.Read
|
||||
logFunc("getAndMarshalIDEExtensionsUsageJSON failed", log.Error(err))
|
||||
}
|
||||
|
||||
// We don't bother doing this on Sourcegraph.com as it is expensive and not needed.
|
||||
if !dotcom.SourcegraphDotComMode() {
|
||||
r.MigratedExtensionsUsage, err = getAndMarshalMigratedExtensionsUsageJSON(ctx, db)
|
||||
if err != nil {
|
||||
logFunc("getAndMarshalMigratedExtensionsUsageJSON failed", log.Error(err))
|
||||
}
|
||||
}
|
||||
|
||||
r.CodeHostVersions, err = getAndMarshalCodeHostVersionsJSON(ctx, db)
|
||||
if err != nil {
|
||||
logFunc("getAndMarshalCodeHostVersionsJSON failed", log.Error(err))
|
||||
@ -718,6 +703,21 @@ func updateBody(ctx context.Context, logger log.Logger, db database.DB) (io.Read
|
||||
r.AccessRequestEnabled = conf.IsAccessRequestEnabled()
|
||||
r.AuthProviders = authProviderTypes()
|
||||
|
||||
// We don't bother doing this on Sourcegraph.com as it is expensive and not needed.
|
||||
if !dotcom.SourcegraphDotComMode() {
|
||||
r.GrowthStatistics, err = getAndMarshalGrowthStatisticsJSON(ctx, db)
|
||||
if err != nil {
|
||||
logFunc("getAndMarshalGrowthStatisticsJSON failed", log.Error(err))
|
||||
}
|
||||
|
||||
r.MigratedExtensionsUsage, err = getAndMarshalMigratedExtensionsUsageJSON(ctx, db)
|
||||
if err != nil {
|
||||
logFunc("getAndMarshalMigratedExtensionsUsageJSON failed", log.Error(err))
|
||||
}
|
||||
|
||||
r.CodyContextFiltersConfigured = conf.SiteConfig().CodyContextFilters != nil
|
||||
}
|
||||
|
||||
// The following methods are the most expensive to calculate, so we do them in
|
||||
// parallel.
|
||||
|
||||
|
||||
@ -237,11 +237,12 @@ type pingRequest struct {
|
||||
ActiveToday bool `json:"activeToday,omitempty"` // Only used in Cody App
|
||||
HasCodyEnabled bool `json:"hasCodyEnabled,omitempty"`
|
||||
// CodyUsage is deprecated, but here so we can receive pings from older instances
|
||||
CodyUsage json.RawMessage `json:"codyUsage,omitempty"`
|
||||
CodyUsage2 json.RawMessage `json:"codyUsage2,omitempty"`
|
||||
CodyProviders json.RawMessage `json:"codyProviders,omitempty"`
|
||||
RepoMetadataUsage json.RawMessage `json:"repoMetadataUsage,omitempty"`
|
||||
LlmUsage json.RawMessage `json:"llmUsage,omitempty"`
|
||||
CodyUsage json.RawMessage `json:"codyUsage,omitempty"`
|
||||
CodyUsage2 json.RawMessage `json:"codyUsage2,omitempty"`
|
||||
CodyProviders json.RawMessage `json:"codyProviders,omitempty"`
|
||||
RepoMetadataUsage json.RawMessage `json:"repoMetadataUsage,omitempty"`
|
||||
LlmUsage json.RawMessage `json:"llmUsage,omitempty"`
|
||||
CodyContextFiltersConfigured bool `json:"codyContextFiltersConfigured,omitempty"`
|
||||
}
|
||||
|
||||
type dependencyVersions struct {
|
||||
@ -373,6 +374,7 @@ type pingPayload struct {
|
||||
CodyProviders json.RawMessage `json:"cody_providers"`
|
||||
RepoMetadataUsage json.RawMessage `json:"repo_metadata_usage"`
|
||||
LlmUsage json.RawMessage `json:"llm_usage"`
|
||||
CodyContextFiltersConfigured string `json:"cody_context_filters_configured"`
|
||||
}
|
||||
|
||||
func logPing(logger log.Logger, pubsubClient pubsub.TopicPublisher, meter *Meter, r *http.Request, pr *pingRequest, hasUpdate bool) {
|
||||
@ -476,6 +478,7 @@ func marshalPing(pr *pingRequest, hasUpdate bool, clientAddr string, now time.Ti
|
||||
CodyProviders: pr.CodyProviders,
|
||||
RepoMetadataUsage: pr.RepoMetadataUsage,
|
||||
LlmUsage: pr.LlmUsage,
|
||||
CodyContextFiltersConfigured: strconv.FormatBool(pr.CodyContextFiltersConfigured),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -145,41 +145,42 @@ func makeDefaultPingRequest(t *testing.T) *pingRequest {
|
||||
t.Helper()
|
||||
|
||||
return &pingRequest{
|
||||
ClientSiteID: "0101-0101",
|
||||
LicenseKey: "mylicense",
|
||||
ExternalURL: "https://sourcegraph.test",
|
||||
DeployType: "server",
|
||||
ClientVersionString: "3.12.6",
|
||||
AuthProviders: []string{"foo", "bar"},
|
||||
ExternalServices: []string{extsvc.KindGitHub, extsvc.KindGitLab},
|
||||
CodeHostVersions: nil,
|
||||
BuiltinSignupAllowed: true,
|
||||
AccessRequestEnabled: true,
|
||||
HasExtURL: false,
|
||||
UniqueUsers: 123,
|
||||
Activity: json.RawMessage(`{"foo":"bar"}`),
|
||||
BatchChangesUsage: nil,
|
||||
CodeIntelUsage: nil,
|
||||
CodeMonitoringUsage: nil,
|
||||
NotebooksUsage: nil,
|
||||
CodeHostIntegrationUsage: nil,
|
||||
IDEExtensionsUsage: nil,
|
||||
MigratedExtensionsUsage: nil,
|
||||
OwnUsage: nil,
|
||||
SearchUsage: nil,
|
||||
GrowthStatistics: nil,
|
||||
SavedSearches: nil,
|
||||
HomepagePanels: nil,
|
||||
SearchOnboarding: nil,
|
||||
InitialAdminEmail: "test@sourcegraph.com",
|
||||
TotalUsers: 234,
|
||||
HasRepos: true,
|
||||
EverSearched: false,
|
||||
EverFindRefs: true,
|
||||
RetentionStatistics: nil,
|
||||
HasCodyEnabled: false,
|
||||
CodyUsage: nil,
|
||||
CodyProviders: nil,
|
||||
ClientSiteID: "0101-0101",
|
||||
LicenseKey: "mylicense",
|
||||
ExternalURL: "https://sourcegraph.test",
|
||||
DeployType: "server",
|
||||
ClientVersionString: "3.12.6",
|
||||
AuthProviders: []string{"foo", "bar"},
|
||||
ExternalServices: []string{extsvc.KindGitHub, extsvc.KindGitLab},
|
||||
CodeHostVersions: nil,
|
||||
BuiltinSignupAllowed: true,
|
||||
AccessRequestEnabled: true,
|
||||
HasExtURL: false,
|
||||
UniqueUsers: 123,
|
||||
Activity: json.RawMessage(`{"foo":"bar"}`),
|
||||
BatchChangesUsage: nil,
|
||||
CodeIntelUsage: nil,
|
||||
CodeMonitoringUsage: nil,
|
||||
NotebooksUsage: nil,
|
||||
CodeHostIntegrationUsage: nil,
|
||||
IDEExtensionsUsage: nil,
|
||||
MigratedExtensionsUsage: nil,
|
||||
OwnUsage: nil,
|
||||
SearchUsage: nil,
|
||||
GrowthStatistics: nil,
|
||||
SavedSearches: nil,
|
||||
HomepagePanels: nil,
|
||||
SearchOnboarding: nil,
|
||||
InitialAdminEmail: "test@sourcegraph.com",
|
||||
TotalUsers: 234,
|
||||
HasRepos: true,
|
||||
EverSearched: false,
|
||||
EverFindRefs: true,
|
||||
RetentionStatistics: nil,
|
||||
HasCodyEnabled: false,
|
||||
CodyUsage: nil,
|
||||
CodyProviders: nil,
|
||||
CodyContextFiltersConfigured: false,
|
||||
}
|
||||
}
|
||||
|
||||
@ -253,6 +254,7 @@ func TestSerializeBasic(t *testing.T) {
|
||||
"ever_find_refs": "true",
|
||||
"total_repos": "0",
|
||||
"active_today": "false",
|
||||
"cody_context_filters_configured": "false",
|
||||
"os": "",
|
||||
"timestamp": "`+now.UTC().Format(time.RFC3339)+`"
|
||||
}`)
|
||||
@ -333,6 +335,7 @@ func TestSerializeLimited(t *testing.T) {
|
||||
"ever_find_refs": "false",
|
||||
"total_repos": "345",
|
||||
"active_today": "true",
|
||||
"cody_context_filters_configured": "false",
|
||||
"os": "mac",
|
||||
"timestamp": "`+now.UTC().Format(time.RFC3339)+`"
|
||||
}`)
|
||||
@ -415,6 +418,7 @@ func TestSerializeFromQuery(t *testing.T) {
|
||||
"ever_find_refs": "true",
|
||||
"total_repos": "0",
|
||||
"active_today": "false",
|
||||
"cody_context_filters_configured": "false",
|
||||
"os": "",
|
||||
"timestamp": "`+now.UTC().Format(time.RFC3339)+`"
|
||||
}`)
|
||||
@ -480,6 +484,7 @@ func TestSerializeBatchChangesUsage(t *testing.T) {
|
||||
"ever_find_refs": "true",
|
||||
"total_repos": "0",
|
||||
"active_today": "false",
|
||||
"cody_context_filters_configured": "false",
|
||||
"os": "",
|
||||
"timestamp": "`+now.UTC().Format(time.RFC3339)+`"
|
||||
}`)
|
||||
@ -545,6 +550,7 @@ func TestSerializeGrowthStatistics(t *testing.T) {
|
||||
"ever_find_refs": "true",
|
||||
"total_repos": "0",
|
||||
"active_today": "false",
|
||||
"cody_context_filters_configured": "false",
|
||||
"os": "",
|
||||
"timestamp": "`+now.UTC().Format(time.RFC3339)+`"
|
||||
}`)
|
||||
@ -811,6 +817,7 @@ func TestSerializeCodeIntelUsage(t *testing.T) {
|
||||
"ever_find_refs": "true",
|
||||
"total_repos": "0",
|
||||
"active_today": "false",
|
||||
"cody_context_filters_configured": "false",
|
||||
"os": "",
|
||||
"timestamp": "`+now.UTC().Format(time.RFC3339)+`"
|
||||
}`)
|
||||
@ -968,6 +975,7 @@ func TestSerializeOldCodeIntelUsage(t *testing.T) {
|
||||
"ever_find_refs": "true",
|
||||
"total_repos": "0",
|
||||
"active_today": "false",
|
||||
"cody_context_filters_configured": "false",
|
||||
"os": "",
|
||||
"timestamp": "`+now.UTC().Format(time.RFC3339)+`"
|
||||
}`)
|
||||
@ -1033,6 +1041,7 @@ func TestSerializeCodeHostVersions(t *testing.T) {
|
||||
"ever_find_refs": "true",
|
||||
"total_repos": "0",
|
||||
"active_today": "false",
|
||||
"cody_context_filters_configured": "false",
|
||||
"os": "",
|
||||
"timestamp": "`+now.UTC().Format(time.RFC3339)+`"
|
||||
}`)
|
||||
@ -1156,6 +1165,7 @@ func TestSerializeOwn(t *testing.T) {
|
||||
"ever_find_refs": "true",
|
||||
"total_repos": "0",
|
||||
"active_today": "false",
|
||||
"cody_context_filters_configured": "false",
|
||||
"os": "",
|
||||
"timestamp": "`+now.UTC().Format(time.RFC3339)+`"
|
||||
}`)
|
||||
@ -1263,6 +1273,7 @@ func TestSerializeRepoMetadataUsage(t *testing.T) {
|
||||
"ever_find_refs": "true",
|
||||
"total_repos": "0",
|
||||
"active_today": "false",
|
||||
"cody_context_filters_configured": "false",
|
||||
"os": "",
|
||||
"timestamp": "`+now.UTC().Format(time.RFC3339)+`"
|
||||
}`)
|
||||
@ -1328,6 +1339,73 @@ func TestSerializeCodyProviders(t *testing.T) {
|
||||
"ever_find_refs": "true",
|
||||
"total_repos": "0",
|
||||
"active_today": "false",
|
||||
"cody_context_filters_configured": "false",
|
||||
"os": "",
|
||||
"timestamp": "`+now.UTC().Format(time.RFC3339)+`"
|
||||
}`)
|
||||
}
|
||||
|
||||
func TestCodyContextFiltersConfigured(t *testing.T) {
|
||||
pr := makeDefaultPingRequest(t)
|
||||
pr.CodyContextFiltersConfigured = true
|
||||
|
||||
now := time.Now()
|
||||
payload, err := marshalPing(pr, true, "127.0.0.1", now)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error %s", err)
|
||||
}
|
||||
|
||||
compareJSON(t, payload, `{
|
||||
"remote_ip": "127.0.0.1",
|
||||
"remote_site_version": "3.12.6",
|
||||
"repo_metadata_usage": null,
|
||||
"remote_site_id": "0101-0101",
|
||||
"license_key": "mylicense",
|
||||
"external_url": "https://sourcegraph.test",
|
||||
"has_update": "true",
|
||||
"unique_users_today": "123",
|
||||
"site_activity": {"foo":"bar"},
|
||||
"batch_changes_usage": null,
|
||||
"code_intel_usage": null,
|
||||
"new_code_intel_usage": null,
|
||||
"dependency_versions": null,
|
||||
"extensions_usage": null,
|
||||
"code_insights_usage": null,
|
||||
"code_insights_critical_telemetry": null,
|
||||
"code_monitoring_usage": null,
|
||||
"cody_usage_2": null,
|
||||
"cody_providers": null,
|
||||
"notebooks_usage": null,
|
||||
"code_host_integration_usage": null,
|
||||
"ide_extensions_usage": null,
|
||||
"llm_usage": null,
|
||||
"migrated_extensions_usage": null,
|
||||
"own_usage": null,
|
||||
"search_usage": null,
|
||||
"growth_statistics": null,
|
||||
"has_cody_enabled": "false",
|
||||
"saved_searches": null,
|
||||
"search_jobs_usage": null,
|
||||
"search_onboarding": null,
|
||||
"homepage_panels": null,
|
||||
"repositories": null,
|
||||
"repository_size_histogram": null,
|
||||
"retention_statistics": null,
|
||||
"installer_email": "test@sourcegraph.com",
|
||||
"auth_providers": "foo,bar",
|
||||
"ext_services": "GITHUB,GITLAB",
|
||||
"code_host_versions": null,
|
||||
"builtin_signup_allowed": "true",
|
||||
"access_request_enabled": "true",
|
||||
"deploy_type": "server",
|
||||
"total_user_accounts": "234",
|
||||
"has_external_url": "false",
|
||||
"has_repos": "true",
|
||||
"ever_searched": "false",
|
||||
"ever_find_refs": "true",
|
||||
"total_repos": "0",
|
||||
"active_today": "false",
|
||||
"cody_context_filters_configured": "true",
|
||||
"os": "",
|
||||
"timestamp": "`+now.UTC().Format(time.RFC3339)+`"
|
||||
}`)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user