insights: add site configuration value for commit indexer interval (#25312)

This commit is contained in:
Cristina Birkel 2021-09-24 16:34:42 -04:00 committed by GitHub
parent 6d2d8175c5
commit 452cce8207
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import (
"github.com/cockroachdb/errors"
"github.com/sourcegraph/sourcegraph/internal/conf"
"github.com/sourcegraph/sourcegraph/internal/observation"
"github.com/sourcegraph/sourcegraph/internal/types"
@ -84,8 +85,11 @@ func NewCommitIndexerWorker(ctx context.Context, base dbutil.DB, insights dbutil
}
func (i *CommitIndexer) Handler(ctx context.Context, observationContext *observation.Context) goroutine.BackgroundRoutine {
//TODO(insights) consider adding setting for index interval
interval := time.Hour * 1
intervalMinutes := conf.Get().InsightsCommitIndexerInterval
if intervalMinutes <= 0 {
intervalMinutes = 60
}
interval := time.Minute * time.Duration(intervalMinutes)
return goroutine.NewPeriodicGoroutineWithMetrics(ctx, interval,
goroutine.NewHandlerWithErrorMessage("commit_indexer_handler", func(ctx context.Context) error {

View File

@ -58,6 +58,7 @@ var requireRestart = []string{
"externalURL",
"update.channel",
"insights.query.worker.concurrency",
"insights.commit.indexer.interval",
}
// NeedRestartToApply determines if a restart is needed to apply the changes

View File

@ -1536,6 +1536,8 @@ type SiteConfiguration struct {
HtmlHeadBottom string `json:"htmlHeadBottom,omitempty"`
// HtmlHeadTop description: HTML to inject at the top of the `<head>` element on each page, for analytics scripts
HtmlHeadTop string `json:"htmlHeadTop,omitempty"`
// InsightsCommitIndexerInterval description: The interval (in minutes) at which the insights commit indexer will check for new commits.
InsightsCommitIndexerInterval int `json:"insights.commit.indexer.interval,omitempty"`
// InsightsHistoricalFrameLength description: (debug) duration of historical insights timeframes, one point per repository will be recorded in each timeframe.
InsightsHistoricalFrameLength string `json:"insights.historical.frameLength,omitempty"`
// InsightsHistoricalFrames description: (debug) number of historical insights timeframes to populate

View File

@ -908,6 +908,13 @@
"examples": [50.0, 0.5],
"!go": { "pointer": true }
},
"insights.commit.indexer.interval": {
"description": "The interval (in minutes) at which the insights commit indexer will check for new commits.",
"type": "integer",
"group": "CodeInsights",
"default": 60,
"examples": [120]
},
"htmlHeadTop": {
"description": "HTML to inject at the top of the `<head>` element on each page, for analytics scripts",
"type": "string",