-
Notifications
You must be signed in to change notification settings - Fork 0
Add documentation for .otignore feature (OT-1318) #16
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
stephenbryant-opentrace
merged 7 commits into
main
from
docs/ot-1318-otignore-documentation
Feb 6, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
457520d
Add documentation for .otignore feature (OT-1318)
12fa2dd
Add links to .otignore documentation in GitHub and GitLab pages
f4af328
Changed order, placing 'ignore' doc next to the Git integration docs
1a7f89f
Removed negation example using `**` as files cannot be re-included if…
1c5f94a
Removed paragraph from 'File still appears' section that talks about …
a51818e
Document default directory exclusions in .otignore guide
c65223a
Updated the 'why' message, and added some blank linkes to help MD->HT…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,364 @@ | ||
| # Excluding Files with .otignore | ||
|
|
||
| ## Overview | ||
|
|
||
| OpenTrace analyzes your repository to build a knowledge graph of your codebase. While this analysis is valuable, you may want to exclude certain files or directories from being analyzed. The `.otignore` file allows you to specify which files and directories OpenTrace should skip during analysis. | ||
|
|
||
| ### Why Use .otignore? | ||
|
|
||
| Common scenarios for using `.otignore`: | ||
|
|
||
| - **Generated code**: Protobuf files, specs, or code generated by tools | ||
| - **Third-party dependencies**: Vendor directories, or other package directories | ||
| - **Secrets**: API tokens, keys or similar pieces of information | ||
| - **Large binary files**: Archives, images, or other non-code assets | ||
| - **Performance optimization**: Reduce analysis time for large repositories | ||
|
|
||
| ### Difference to .gitignore | ||
|
|
||
| `.otignore` serves a different purpose than `.gitignore`: | ||
|
|
||
| - **`.gitignore`**: Controls which files Git tracks and commits | ||
| - **`.otignore`**: Controls which *committed* files OpenTrace analyzes | ||
|
|
||
| Since OpenTrace only has access to files that are already committed to your repository, `.otignore` helps you exclude committed files that you don't want analyzed (like vendored dependencies or generated code that you choose to commit). | ||
|
|
||
| ## Quick Start | ||
|
|
||
| To start using `.otignore`: | ||
|
|
||
| 1. Create a file named `.otignore` (or `.opentraceignore`) in your repository root | ||
| 2. Add patterns for files or directories to exclude (uses gitignore syntax) | ||
| 3. Commit the file to your repository | ||
| 4. The next OpenTrace analysis will automatically respect your exclusions | ||
|
|
||
| **Example `.otignore` file:** | ||
|
|
||
| ``` | ||
| # Exclude generated protobuf code | ||
| *.pb.go | ||
| *.pb.py | ||
|
|
||
| # Exclude vendored dependencies | ||
| /vendor/ | ||
| /node_modules/ | ||
|
|
||
| # Exclude build outputs | ||
| /dist/ | ||
| /build/ | ||
| ``` | ||
|
|
||
| ## Configuration | ||
|
|
||
| ### Supported Filenames | ||
|
|
||
| OpenTrace recognizes two filenames for ignore patterns: | ||
|
|
||
| - `.otignore` (recommended) | ||
| - `.opentraceignore` (alternative) | ||
|
|
||
| If both files exist, patterns from both will be applied. Patterns from `.otignore` are loaded first, followed by patterns from `.opentraceignore`. | ||
|
|
||
| ### File Location | ||
|
|
||
| The ignore file must be placed in the **repository root directory**. Ignore files in subdirectories are not currently supported. | ||
|
|
||
| ### Default Exclusions | ||
|
|
||
| OpenTrace automatically excludes certain directories from analysis, even without an `.otignore` file. These directories are always skipped: | ||
|
|
||
| - `.git` - Git repository metadata | ||
| - `.venv`, `venv` - Python virtual environments | ||
| - `node_modules` - Node.js dependencies | ||
| - `__pycache__` - Python bytecode cache | ||
| - `.pytest_cache` - Pytest cache | ||
| - `.mypy_cache` - MyPy type checker cache | ||
| - `.tox` - Tox testing environments | ||
| - `dist` - Distribution/build output | ||
| - `build` - Build artifacts | ||
| - `.eggs` - Python egg artifacts | ||
| - `vendor` - Vendored dependencies | ||
|
|
||
| These default exclusions work alongside your `.otignore` patterns. You don't need to add these directories to your `.otignore` file - they're already excluded automatically. | ||
|
|
||
| !!! note "Why these defaults?" | ||
| These directories typically contain dependencies, build artifacts, or caching data that adds noise to analysis without providing value. Excluding them by default improves performance and keeps your knowledge graph focused on your actual source code. | ||
|
|
||
| ## Pattern Syntax | ||
|
|
||
| `.otignore` uses the same pattern syntax as `.gitignore`, powered by the `pathspec` library. This ensures familiar and predictable behavior. | ||
|
|
||
| ### Basic Patterns | ||
|
|
||
| | Pattern | Matches | | ||
| |---------|---------| | ||
| | `file.txt` | Specific file named `file.txt` in any directory | | ||
| | `*.log` | All files ending with `.log` | | ||
| | `test` | Any file or directory named `test` | | ||
|
|
||
| ### Directory Patterns | ||
|
|
||
| | Pattern | Matches | | ||
| |---------|---------| | ||
| | `logs/` | Directory named `logs` (trailing slash required) | | ||
| | `/build/` | Directory named `build` only in repository root | | ||
| | `**/temp/` | Directory named `temp` at any depth | | ||
|
|
||
| ### Wildcards | ||
|
|
||
| | Wildcard | Meaning | | ||
| |----------|---------| | ||
| | `*` | Matches any characters except `/` | | ||
| | `**` | Matches any characters including `/` (any depth) | | ||
| | `?` | Matches exactly one character | | ||
|
|
||
| **Examples:** | ||
|
|
||
| ``` | ||
| # Match all .log files | ||
| *.log | ||
|
|
||
| # Match all files in any __pycache__ directory | ||
| **/__pycache__/** | ||
|
|
||
| # Match .js files in any test directory | ||
| **/test/*.js | ||
| ``` | ||
|
|
||
| ### Negation Patterns | ||
|
|
||
| Use `!` to re-include files that were previously excluded: | ||
|
|
||
| ``` | ||
| # Exclude all .txt files | ||
| *.txt | ||
|
|
||
| # But include this important one | ||
| !important.txt | ||
| ``` | ||
|
|
||
| ### Comments | ||
|
|
||
| Lines starting with `#` are treated as comments and ignored: | ||
|
|
||
| ``` | ||
| # This is a comment explaining the next pattern | ||
| *.tmp | ||
| ``` | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Example 1: Python Project | ||
|
|
||
| ``` | ||
| # Exclude Python generated files | ||
| **/__pycache__/ | ||
| *.pyc | ||
| *.pyo | ||
| *.pyd | ||
| .Python | ||
|
|
||
| # Exclude virtual environments | ||
| /venv/ | ||
| /.venv/ | ||
| /env/ | ||
|
|
||
| # Exclude generated protobuf code | ||
| *_pb2.py | ||
| *_pb2_grpc.py | ||
| ``` | ||
|
|
||
| ### Example 2: JavaScript/TypeScript Project | ||
|
|
||
| ``` | ||
| # Exclude dependencies | ||
| /node_modules/ | ||
| /bower_components/ | ||
|
|
||
| # Exclude build outputs | ||
| /dist/ | ||
| /build/ | ||
| /.next/ | ||
| /out/ | ||
|
|
||
| # Exclude generated files | ||
| *.generated.ts | ||
| ``` | ||
|
|
||
| ### Example 3: Go Project | ||
|
|
||
| ``` | ||
| # Exclude vendored dependencies | ||
| /vendor/ | ||
|
|
||
| # Exclude generated protobuf code | ||
| *.pb.go | ||
|
|
||
| # Exclude compiled binaries | ||
| /bin/ | ||
| *.exe | ||
| ``` | ||
|
|
||
| ### Example 4: Monorepo | ||
|
|
||
| ``` | ||
| # Exclude all node_modules in monorepo | ||
| **/node_modules/ | ||
|
|
||
| # Exclude all dist directories | ||
| **/dist/ | ||
|
|
||
| # Exclude specific generated service code | ||
| services/api/generated/ | ||
| services/auth/generated/ | ||
|
|
||
| # But include the schema definitions | ||
| !services/*/generated/schema.yaml | ||
| ``` | ||
|
|
||
| ## Common Use Cases | ||
|
|
||
| ### Excluding Protobuf/OpenAPI Generated Code | ||
|
|
||
| Generated API code often creates noise in analysis results: | ||
|
|
||
| ``` | ||
| # Protocol Buffers | ||
| *.pb.go | ||
| *.pb.py | ||
| *_pb2.py | ||
| *_pb2_grpc.py | ||
|
|
||
| # OpenAPI/Swagger | ||
| /generated/openapi/ | ||
| **/swagger-generated/ | ||
| ``` | ||
|
|
||
| ### Ignoring Vendored Dependencies | ||
|
|
||
| Third-party code adds unnecessary complexity to your knowledge graph: | ||
|
|
||
| ``` | ||
| # Go vendor directory | ||
| /vendor/ | ||
|
|
||
| # JavaScript/Node | ||
| /node_modules/ | ||
|
|
||
| # Ruby gems | ||
| /vendor/bundle/ | ||
|
|
||
| # Python packages | ||
| /site-packages/ | ||
| ``` | ||
|
|
||
| ### Excluding Test Fixtures and Mocks | ||
|
|
||
| Large test data files can slow down analysis: | ||
|
|
||
| ``` | ||
| # Test fixtures | ||
| **/fixtures/ | ||
| **/testdata/ | ||
|
|
||
| # Mock data | ||
| **/mocks/ | ||
| **/__mocks__/ | ||
| ``` | ||
|
|
||
| ### Performance Optimization for Large Repos | ||
|
|
||
| For very large repositories, exclude non-essential directories: | ||
|
|
||
| ``` | ||
| # Documentation site builds | ||
| /docs/site/ | ||
| /docusaurus/build/ | ||
|
|
||
| # IDE configurations (if committed) | ||
| /.vscode/ | ||
| /.idea/ | ||
|
|
||
| # Large binary assets | ||
| /assets/images/ | ||
| /public/uploads/ | ||
| ``` | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Pattern Not Working? | ||
|
|
||
| **Check your syntax:** | ||
|
|
||
| - Ensure patterns follow gitignore format | ||
| - Directory patterns need a trailing `/` | ||
| - Use `/` as the path separator (even on Windows) | ||
| - Test your patterns with a gitignore validator | ||
|
|
||
| **Example issue:** | ||
| ``` | ||
| # ❌ Won't match directories | ||
| node_modules | ||
|
|
||
| # ✅ Correctly matches directories | ||
| node_modules/ | ||
| ``` | ||
|
|
||
| ### File Still Appears in Analysis? | ||
|
|
||
| **Check file location:** | ||
|
|
||
| - Ensure `.otignore` is in the repository root, not a subdirectory | ||
| - Verify the file is named exactly `.otignore` or `.opentraceignore` | ||
|
|
||
| ### Changes Not Taking Effect? | ||
|
|
||
| **Commit your .otignore file:** | ||
|
|
||
| - Changes only apply after the `.otignore` file is committed | ||
| - OpenTrace reads the ignore file from the committed repository | ||
| - Run `git add .otignore && git commit -m "Update otignore patterns"` | ||
|
|
||
| **Wait for next analysis:** | ||
|
|
||
| - Changes apply to new analysis runs, not retroactively | ||
| - Trigger a new repository sync in OpenTrace to apply changes | ||
|
|
||
| ## Technical Details | ||
|
|
||
| ### Pattern Matching Implementation | ||
|
|
||
| OpenTrace uses the `pathspec` library with gitignore-style pattern matching, ensuring behavior identical to `.gitignore` files. Patterns are applied to relative paths from the repository root. | ||
|
|
||
| ### Scope of Exclusions | ||
|
|
||
| The `.otignore` file affects all Git-based integrations: | ||
|
|
||
| - GitHub repository analysis | ||
| - GitLab repository analysis | ||
| - Any future Git-based source integrations | ||
|
|
||
| Files excluded by `.otignore` will not appear in: | ||
|
|
||
| - The knowledge graph | ||
| - Code search results | ||
| - Dependency analysis | ||
| - Investigation context | ||
|
|
||
| ### Performance Impact | ||
|
|
||
| Using `.otignore` to exclude large directories can significantly improve: | ||
|
|
||
| - Analysis speed | ||
| - Memory usage during analysis | ||
| - Knowledge graph size and query performance | ||
|
|
||
| For repositories with thousands of files, excluding generated code and dependencies can reduce analysis time by 50% or more. | ||
|
|
||
| ## Best Practices | ||
|
|
||
| 1. **Commit your .otignore early**: Add it when you first set up OpenTrace for your repository | ||
| 2. **Start broad, refine later**: Begin by excluding obvious directories like `node_modules/`, then add more specific patterns as needed | ||
| 3. **Document your patterns**: Use comments to explain why certain paths are excluded | ||
| 4. **Review periodically**: As your repository evolves, update `.otignore` to reflect new generated code or dependencies | ||
| 5. **Keep it simple**: Don't over-optimize - exclude only what meaningfully impacts analysis quality or performance | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OBSERVATION: The pattern
.Pythonis not a standard Python-related file or directory that is typically ignored. It might be a typo or a very specific convention. If it's not a typo, it could be confusing for users. Standard patterns usually include__pycache__/,*.pyc, and virtual environment folders likevenv/. Consider removing this line if it's not a common pattern to avoid confusion.