Skip to content

LoC and file count insights #1205

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

Merged
merged 5 commits into from
Jun 24, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/admin/updates/docker_compose.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ For upgrade procedures or general info about sourcegraph versioning see the link
>
> ***If the notes indicate a patch release exists, target the highest one.***

## v6.3 patch 1

- Grafana's port 3370 is no longer open by default for unauthenticated access for Docker Compose and Pure Docker deployments. Admins can still access Grafana by logging in to their Sourcegraph instance, navigating to the Site Admin page, then clicking Monitoring from the left navigation menu. If customers require port 3370 to be open, see [[PR 1204](https://github.com/sourcegraph/deploy-sourcegraph-docker/pull/1204/files)] for insight on how to add this port to their `docker-compose.override.yaml` file.

## v6.2.2553

### Known issues
Expand Down
64 changes: 64 additions & 0 deletions docs/code_insights/types/inventory-stats.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Inventory Stats

<p type="subtitle">Learn about your project's inventory stats type of Code Insights.</p>

An inventory stats code insight lets you track code inventory metrics such as file counts, lines of code, and language usage trends in your repositories. Sourcegraph Code Search Enterprise users can track these metrics across all repositories in their organization.

To create an inventory stats code insight:

- Navigate to the Code Insights tab from the Sourcegraph instance
- Click on the **Create insight** button
- Select **Inventory Stats** as the type of insight
- Choose your list of target repositories on which you want to perform an insight
- Next, pick the inventory metrics you want to track, like lines of code, file size, and file count
- Finally, add a **title** and **granularity** of the insight
- And click **Create code insight** once you are done

While configuring these fields, you can also see a live preview of the insight on the right side of the page.

After you have created the insight, you can view it on the **Code Insights** tab.

![inventory-stats](https://storage.googleapis.com/sourcegraph-assets/Docs/inventory-stats-insights-0625.png)

Now, you can perform all the actions you can on other Code Insights, such as editing, filtering, sharing, and deleting.

## Inventory environment variables

<Callout type="note">Inventory environment variables have been moved into site configuration. This impacts any self-hosted customer using these environment variables. Cloud customers are not impacted by this change.</Callout>

If you are a self-hosted Sourcegraph Enterprise user, we have moved the inventory environment variables into the **inventory** section of the **Site configuration** settings in your **Site admin** page.

Here's a list oI the Inventory environment variables and their new site configuration settings, with default values:

- `USE_ENHANCED_LANGUAGE_DETECTION` ==> `"disableEnhancedLanguageDetection"`
- defaults to `false`
- `GET_INVENTORY_GIT_SERVER_CONCURRENCY` ==> `"gitServerConcurrency"`
- defaults to `4`
- `GET_INVENTORY_REDIS_CONCURRENCY` ==> `"redisConcurrency"`
- defaults to `20`
- `GET_INVENTORY_MAX_INV_IN_MEMORY` ==> `"maxInventoryInMemory"`
- defaults to `1000`
- `GET_INVENTORY_TIMEOUT` ==> `"timeoutInMinutes"`
- defaults to `5`

Here's an example of the site configuration section:

```json
"inventory" : {
"disableEnhancedLanguageDetection": false,
"gitServerConcurrency": 4,
"redisConcurrency": 20,
"maxInventoryInMemory": 1000,
"timeoutInMinutes": 5
}
```

<Callout type="info">To accommodate default values in your Site configuration vs. environment variables, the positive `USE_ENHANCED_LANGUAGE_DETECTION` env var has been changed to the negative `disableEnhancedLanguageDetection`.</Callout>

There is a new environment variable for managing `worker` resources when processing Inventory insights:

```json
INSIGHTS_INVENTORY_BATCH_SIZE
```

This environment variable controls the number of repositories to process in a single batch for inventory insights in the code insights worker. It affects memory usage while processing repos. Lower number is less memory used. It does not affect the speed of the process.