Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add usagestats ping for migrated extension metrics #41412

Merged
merged 5 commits into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions client/web/src/site-admin/SiteAdminPingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,25 @@ export const SiteAdminPingsPage: React.FunctionComponent<React.PropsWithChildren
</ul>
<ul>Aggregate count of daily redirects from extension to Sourcegraph instance</ul>
</li>
<li>
Migrated extensions data
<ul>
Aggregate data of:
<li>
<ul>Count interactions with the Git blame feature</ul>
philipp-spiess marked this conversation as resolved.
Show resolved Hide resolved
<ul>Count of unique users who interacted with the Git blame feature</ul>
philipp-spiess marked this conversation as resolved.
Show resolved Hide resolved
<ul>Count interactions with the open in editor feature</ul>
<ul>Count of unique users who interacted with the open in editor feature</ul>
<ul>Count interactions with the search exports feature</ul>
<ul>Count of unique users who interacted with the search exports feature</ul>
<ul>Count interactions with the go imports search query transformation feature</ul>
<ul>
Count of unique users who interacted with the go imports search query transformation
feature
</ul>
</li>
</ul>
</li>
</ul>
{updatesDisabled ? (
<Text>All telemetry is disabled.</Text>
Expand Down
17 changes: 17 additions & 0 deletions cmd/frontend/internal/app/updatecheck/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,17 @@ func getAndMarshalIDEExtensionsUsageJSON(ctx context.Context, db database.DB) (_
return json.Marshal(ideExtensionsUsage)
}

func getAndMarshalMigratedExtensionsUsageJSON(ctx context.Context, db database.DB) (_ json.RawMessage, err error) {
defer recordOperation("getAndMarshalMigratedExtensionsUsageJSON")

migratedExtensionsUsage, err := usagestats.GetMigratedExtensionsUsageStatistics(ctx, db)
if err != nil {
return nil, err
}

return json.Marshal(migratedExtensionsUsage)
}

func getAndMarshalCodeHostVersionsJSON(_ context.Context, _ database.DB) (_ json.RawMessage, err error) {
defer recordOperation("getAndMarshalCodeHostVersionsJSON")(&err)

Expand Down Expand Up @@ -406,6 +417,7 @@ func updateBody(ctx context.Context, logger log.Logger, db database.DB) (io.Read
NotebooksUsage: []byte("{}"),
CodeHostIntegrationUsage: []byte("{}"),
IDEExtensionsUsage: []byte("{}"),
MigratedExtensionsUsage: []byte("{}"),
}

totalUsers, err := getTotalUsersCount(ctx, db)
Expand Down Expand Up @@ -526,6 +538,11 @@ func updateBody(ctx context.Context, logger log.Logger, db database.DB) (io.Read
logFunc("getAndMarshalIDEExtensionsUsageJSON failed", log.Error(err))
}

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))
Expand Down
2 changes: 2 additions & 0 deletions cmd/frontend/internal/app/updatecheck/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ type pingRequest struct {
CodeHostVersions json.RawMessage `json:"codeHostVersions"`
CodeHostIntegrationUsage json.RawMessage `json:"codeHostIntegrationUsage"`
IDEExtensionsUsage json.RawMessage `json:"ideExtensionsUsage"`
MigratedExtensionsUsage json.RawMessage `json:"migratedExtensionsUsage"`
InitialAdminEmail string `json:"initAdmin"`
TosAccepted bool `json:"tosAccepted"`
TotalUsers int32 `json:"totalUsers"`
Expand Down Expand Up @@ -319,6 +320,7 @@ type pingPayload struct {
CodeHostVersions json.RawMessage `json:"code_host_versions"`
CodeHostIntegrationUsage json.RawMessage `json:"code_host_integration_usage"`
IDEExtensionsUsage json.RawMessage `json:"ide_extensions_usage"`
MigratedExtensionsUsage json.RawMessage `json:"migrated_extensions_usage"`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume it's enough to add this to the usage ping payload like this and downstream will save it for us somewhere? cc @ebrodymoore

InstallerEmail string `json:"installer_email"`
AuthProviders string `json:"auth_providers"`
ExtServices string `json:"ext_services"`
Expand Down
11 changes: 11 additions & 0 deletions cmd/frontend/internal/app/updatecheck/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ func TestSerializeBasic(t *testing.T) {
NotebooksUsage: nil,
CodeHostIntegrationUsage: nil,
IDEExtensionsUsage: nil,
MigratedExtensionsUsage: nil,
SearchUsage: nil,
GrowthStatistics: nil,
SavedSearches: nil,
Expand Down Expand Up @@ -187,6 +188,7 @@ func TestSerializeBasic(t *testing.T) {
"notebooks_usage": null,
"code_host_integration_usage": null,
"ide_extensions_usage": null,
"migrated_extensions_usage": null,
"search_usage": null,
"growth_statistics": null,
"saved_searches": null,
Expand Down Expand Up @@ -255,6 +257,7 @@ func TestSerializeFromQuery(t *testing.T) {
"notebooks_usage": null,
"code_host_integration_usage": null,
"ide_extensions_usage": null,
"migrated_extensions_usage": null,
"search_usage": null,
"growth_statistics": null,
"saved_searches": null,
Expand Down Expand Up @@ -295,6 +298,7 @@ func TestSerializeBatchChangesUsage(t *testing.T) {
NotebooksUsage: nil,
CodeHostIntegrationUsage: nil,
IDEExtensionsUsage: nil,
MigratedExtensionsUsage: nil,
NewCodeIntelUsage: nil,
SearchUsage: nil,
GrowthStatistics: nil,
Expand Down Expand Up @@ -334,6 +338,7 @@ func TestSerializeBatchChangesUsage(t *testing.T) {
"notebooks_usage": null,
"code_host_integration_usage": null,
"ide_extensions_usage": null,
"migrated_extensions_usage": null,
"search_usage": null,
"growth_statistics": null,
"saved_searches": null,
Expand Down Expand Up @@ -475,6 +480,7 @@ func TestSerializeCodeIntelUsage(t *testing.T) {
NotebooksUsage: nil,
CodeHostIntegrationUsage: nil,
IDEExtensionsUsage: nil,
MigratedExtensionsUsage: nil,
NewCodeIntelUsage: testUsage,
SearchUsage: nil,
GrowthStatistics: nil,
Expand Down Expand Up @@ -609,6 +615,7 @@ func TestSerializeCodeIntelUsage(t *testing.T) {
"notebooks_usage": null,
"code_host_integration_usage": null,
"ide_extensions_usage": null,
"migrated_extensions_usage": null,
"dependency_versions": null,
"extensions_usage": null,
"code_insights_usage": null,
Expand Down Expand Up @@ -675,6 +682,7 @@ func TestSerializeOldCodeIntelUsage(t *testing.T) {
NotebooksUsage: nil,
CodeHostIntegrationUsage: nil,
IDEExtensionsUsage: nil,
MigratedExtensionsUsage: nil,
NewCodeIntelUsage: nil,
SearchUsage: nil,
GrowthStatistics: nil,
Expand Down Expand Up @@ -779,6 +787,7 @@ func TestSerializeOldCodeIntelUsage(t *testing.T) {
"notebooks_usage": null,
"code_host_integration_usage": null,
"ide_extensions_usage": null,
"migrated_extensions_usage": null,
"dependency_versions": null,
"extensions_usage": null,
"code_insights_usage": null,
Expand Down Expand Up @@ -823,6 +832,7 @@ func TestSerializeCodeHostVersions(t *testing.T) {
NotebooksUsage: nil,
CodeHostIntegrationUsage: nil,
IDEExtensionsUsage: nil,
MigratedExtensionsUsage: nil,
NewCodeIntelUsage: nil,
SearchUsage: nil,
GrowthStatistics: nil,
Expand Down Expand Up @@ -862,6 +872,7 @@ func TestSerializeCodeHostVersions(t *testing.T) {
"notebooks_usage": null,
"code_host_integration_usage": null,
"ide_extensions_usage": null,
"migrated_extensions_usage": null,
"search_usage": null,
"growth_statistics": null,
"saved_searches": null,
Expand Down
22 changes: 16 additions & 6 deletions doc/admin/pings.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Critical telemetry includes only the high-level data below required for billing,
- Aggregated repository statistics
- Total size of git repositories stored in bytes
- Total number of lines of code stored in text search index
- Code Insights: total count of insights
- Code Insights: total count of insights

</details>

Expand Down Expand Up @@ -113,11 +113,11 @@ This telemetry can be disabled using the `disableNonCriticalTelemetry` option in
- Total counts of hovers, clicks, and drags of insights by type (e.g. search, code stats)
- Total counts of edits, additions, and removals of insights by type
- Total count of clicks on the "Add more insights" and "Configure insights" buttons on the insights page
- Weekly count of users that have created an insight, and count of users that have created their first insight this week
- Weekly count of users that have created an insight, and count of users that have created their first insight this week
- Weekly count of total and unique views to the `Create new insight`, `Create search insight`, and `Create language insight` pages
- Weekly count of total and unique clicks of the `Create search insight`, `Create language usage insight`, and `Explore the extensions` buttons on the `Create new insight` page
- Weekly count of total and unique clicks of the `Create` and `Cancel` buttons on the `Create search insight` and `Create language insight` pages
- Total count of insights grouped by time interval (step size) in days
- Total count of insights grouped by time interval (step size) in days
- Total count of insights set organization visible grouped by insight type
- Total count of insights grouped by presentation type, series type, and presentation-series type.
- Weekly count of unique users that have viewed code insights in-product landing page
Expand Down Expand Up @@ -169,8 +169,18 @@ This telemetry can be disabled using the `disableNonCriticalTelemetry` option in
- Count of total searches performed
- Aggregate counts of current daily user state:
- Count of users who installed the extension
- Count of users who uninstalled the extension
- Count of users who uninstalled the extension
- Aggregate count of current daily redirects from extension to Sourcegraph instance
- Migrated extensions usage data
- Aggregate data of:
- Count interactions with the Git blame feature
philipp-spiess marked this conversation as resolved.
Show resolved Hide resolved
- Count of unique users who interacted with the Git blame feature
philipp-spiess marked this conversation as resolved.
Show resolved Hide resolved
- Count interactions with the open in editor feature
- Count of unique users who interacted with the open in editor feature
- Count interactions with the search exports feature
- Count of unique users who interacted with the search exports feature
- Count interactions with the go imports search query transformation feature
- Count of unique users who interacted with the go imports search query transformation feature

</details>

Expand All @@ -196,7 +206,7 @@ It may happen that Sourcegraph will stop sending critical telemetry to Sourcegra
Sourcegraph telemetry pings are handled by a goroutine running on Sourcegraphs frontend service called [`updatecheck`](https://sourcegraph.com/github.com/sourcegraph/sourcegraph/-/blob/cmd/frontend/internal/app/updatecheck/client.go?subtree=true), `updatecheck` is [started](https://sourcegraph.com/search?q=context:global+repo:%5Egithub%5C.com/sourcegraph/sourcegraph%24+file:%5Ecmd/frontend/internal/cli/serve_cmd%5C.go+updatecheck.Start%28db%29&patternType=literal) on container startup and periodically requests a variety of queries be run in the `pgsql` database.


### Misconfigured update.channel
### Misconfigured update.channel
The most common scenario in which Sourcegraph stops sending pings is a change to the `update.channel` setting in an instance's [site config](https://docs.sourcegraph.com/admin/config/site_config)
```
"update.channel": "release",
Expand All @@ -223,4 +233,4 @@ Example:

If the `update.check` is running, and the site config is correctly configured, then it may be the case that `pgsql` is failing to return data from the SQL queries to the `frontend`. Check out the frontend logs for logs tagged [`telemetry: updatecheck failed`](https://sourcegraph.com/search?q=context:global+repo:%5Egithub%5C.com/sourcegraph/sourcegraph%24+file:%5Ecmd/frontend/internal/app/updatecheck/client%5C.go+telemetry:+updatecheck+failed&patternType=literal).

If issues persist, please reach out to a team member for support at support@sourcegraph.com
If issues persist, please reach out to a team member for support at support@sourcegraph.com
30 changes: 30 additions & 0 deletions internal/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,36 @@ type IDEExtensionsUsageUserState struct {
Uninstalls int32
}

// MigratedExtensionsUsageStatistics repreents the numbers of interactions with
// the migrated extensions (git blame, open in editor, search exports, and go
// imports search).
type MigratedExtensionsUsageStatistics struct {
GitBlameEnabled *int32
GitBlameEnabledUniqueUsers *int32
GitBlameDisabled *int32
GitBlameDisabledUniqueUsers *int32
GitBlamePopupViewed *int32
GitBlamePopupViewedUniqueUsers *int32
GitBlamePopupClicked *int32
GitBlamePopupClickedUniqueUsers *int32

SearchExportPerformed *int32
SearchExportPerformedUniqueUsers *int32
SearchExportFailed *int32
SearchExportFailedUniqueUsers *int32

GoImportsSearchQueryTransformed *int32
GoImportsSearchQueryTransformedUniqueUsers *int32

OpenInEditor []*MigratedExtensionsOpenInEditorUsageStatistics
}

type MigratedExtensionsOpenInEditorUsageStatistics struct {
IdeKind string
Clicked *int32
ClickedUniqueUsers *int32
}

// CodeHostIntegrationUsage represents the daily, weekly and monthly
// number of unique users and events for code host integration usage
// and inbound traffic from code host integration to Sourcegraph instance
Expand Down