Sourcegraph DocsSourcegraph Docs
  • Code Intelligence

    • Cody
    • Code Search
  • Code Management

    • Batch Changes
    • Code Monitoring
    • Code Ownership
    • Code Insights
    • Notebooks
  • Platform

    • Sourcegraph Admin
    • Sourcegraph Cloud
    • Integrations
  • CLI & API

    • Sourcegraph & Cody CLI
    • Sourcegraph GraphQL API
    • Sourcegraph Stream API
  • Help & Support

    • SLAs & Premium Support
    • How to videos
    • Tutorials
    • Sourcegraph Accounts
    • Changelog
    • Technical changelog
    • Releases
  1. Docs
  2. code_monitoring
  3. how-tos
  4. starting_points

Start monitoring your code

This page lists code monitors that are commonly used and can be used across most codebases.

Watch for consumers of deprecated endpoints

SHELL
f:\.tsx?$ patterntype:regexp fetch\(['"`]/deprecated-endpoint

If you’re deprecating an API or an endpoint, you may find it useful to set up a code monitor watching for new consumers. As an example, the above query will surface fetch() calls to /deprecated-endpoint within TypeScript files. Replace /deprecated-endpoint with the actual path of the endpoint being deprecated.

Get notified when a file changes

SHELL
patterntype:regexp repo:^github\.com/sourcegraph/sourcegraph$ file:SourcegraphWebApp\.tsx$ type:diff

You may want to get notified when a given file is changed, regardless of the diff contents of the change: the above query will return all changes to the SourcegraphWebApp.tsx file on the github.com/sourcegraph/sourcegraph repo.

Get notified when a specific function call is added

SHELL
repo:^github\.com/sourcegraph/sourcegraph$ type:diff select:commit.diff.added Sprintf

You may want to monitor new additions of a specific function call, for example a deprecated function or a function that introduces a security concern. This query will notify you whenever a new addition of Sprintf is added to the sourcegraph/sourcegraph repository. This query selects all diff additions marked as "+". If a call of Sprintf is both added and removed from a file, this query will still notify due to the addition.

On this page

  1. Start monitoring your code

    1. Watch for consumers of deprecated endpoints
    1. Get notified when a file changes
    1. Get notified when a specific function call is added

Edit this page on GitHub
Questions? Give us feedback