|
| 1 | +# Inventory Stats |
| 2 | + |
| 3 | +<p type="subtitle">Learn about your project's inventory stats type of Code Insights.</p> |
| 4 | + |
| 5 | +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. |
| 6 | + |
| 7 | +To create an inventory stats code insight: |
| 8 | + |
| 9 | +- Navigate to the Code Insights tab from the Sourcegraph instance |
| 10 | +- Click on the **Create insight** button |
| 11 | +- Select **Inventory Stats** as the type of insight |
| 12 | +- Choose your list of target repositories on which you want to perform an insight |
| 13 | +- Next, pick the inventory metrics you want to track, like lines of code, file size, and file count |
| 14 | +- Finally, add a **title** and **granularity** of the insight |
| 15 | +- And click **Create code insight** once you are done |
| 16 | + |
| 17 | +While configuring these fields, you can also see a live preview of the insight on the right side of the page. |
| 18 | + |
| 19 | +After you have created the insight, you can view it on the **Code Insights** tab. |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | +Now, you can perform all the actions you can on other Code Insights, such as editing, filtering, sharing, and deleting. |
| 24 | + |
| 25 | +## Inventory environment variables |
| 26 | + |
| 27 | +<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> |
| 28 | + |
| 29 | +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. |
| 30 | + |
| 31 | +Here's a list oI the Inventory environment variables and their new site configuration settings, with default values: |
| 32 | + |
| 33 | +- `USE_ENHANCED_LANGUAGE_DETECTION` ==> `"disableEnhancedLanguageDetection"` |
| 34 | + - defaults to `false` |
| 35 | +- `GET_INVENTORY_GIT_SERVER_CONCURRENCY` ==> `"gitServerConcurrency"` |
| 36 | + - defaults to `4` |
| 37 | +- `GET_INVENTORY_REDIS_CONCURRENCY` ==> `"redisConcurrency"` |
| 38 | + - defaults to `20` |
| 39 | +- `GET_INVENTORY_MAX_INV_IN_MEMORY` ==> `"maxInventoryInMemory"` |
| 40 | + - defaults to `1000` |
| 41 | +- `GET_INVENTORY_TIMEOUT` ==> `"timeoutInMinutes"` |
| 42 | + - defaults to `5` |
| 43 | + |
| 44 | +Here's an example of the site configuration section: |
| 45 | + |
| 46 | +```json |
| 47 | +"inventory" : { |
| 48 | + "disableEnhancedLanguageDetection": false, |
| 49 | + "gitServerConcurrency": 4, |
| 50 | + "redisConcurrency": 20, |
| 51 | + "maxInventoryInMemory": 1000, |
| 52 | + "timeoutInMinutes": 5 |
| 53 | +} |
| 54 | +``` |
| 55 | + |
| 56 | +<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> |
| 57 | + |
| 58 | +There is a new environment variable for managing `worker` resources when processing Inventory insights: |
| 59 | + |
| 60 | +```json |
| 61 | +INSIGHTS_INVENTORY_BATCH_SIZE |
| 62 | +``` |
| 63 | + |
| 64 | +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. |
0 commit comments