GitHub

Integrate Better Stack with GitHub to connect your repositories and enhance error context with git blame information. This integration allows you to quickly pinpoint the exact code changes and authors associated with errors, streamlining your debugging process.

Setting up the integration

  1. Navigate to ErrorsIntegrations.
  2. Find the GitHub integration and click Add.
  3. Follow the authorization steps to connect your GitHub account.
  4. Select the GitHub repositories you want to connect to Better Stack.
  5. Click Connect Selected.
  6. Go to ErrorsApplications, click Configure in the dropdown menu of the application, and select the repository under Connect repository.

GitHub integration settings

Git blame

  • Automatic git blame data: For errors with stack traces, Better Stack automatically fetches git blame information from your connected GitHub repositories.
  • Identify relevant code changes: See when and what code change introduced an error directly within the error details, including the commit hash and author.
  • Faster debugging: Quickly navigate to the relevant line of code in GitHub to inspect the change that might be causing the issue.

Git blame example

Configure git code paths

If the reported path to the source file in your error stack trace doesn't match the path in your repository, you can set up a mapping to correct this. This ensures that git blame functionality works correctly.

To configure code path mapping:

  1. Go to ErrorsApplications.
  2. Click Configure in the dropdown menu of the application.
  3. Navigate to the Advanced settings tab.
  4. Under Configure git code paths, you'll find two options:
    • Stack trace root (prefix to match in stack traces): Enter the prefix of the file path as it appears in your stack traces (e.g., /usr/src/app).
    • Source code root (Replacement prefix for the repository): Enter the corresponding relative path to your source code within your repository (e.g., apps/backend).

Code mapping settings

Paste the error's URL into a pull request to link it to the error. Copy the URL from the error's page in Better Stack, for example https://errors.betterstack.com/team/t12345/errors/a1b2c3d4?s=67890, and add it to the pull request description or to a comment on the pull request. Better Stack picks it up when the pull request is opened and whenever the description or a comment is added or edited later.

Once linked, Better Stack:

  • Shows the pull request on the error's page with its status: open, merged, or closed.
  • Comments on the pull request with the error's type and message, plus links to the error and its application.
  • Resolves the error when the pull request is merged, the same way Resolve in next release does. This needs the application to report releases.

Pull request not linked?

The pull request has to be in the repository connected to the error's application. Check the repository under Connect repository in the application's settings.

Not seeing the comment on the pull request?

Accept the updated GitHub App permissions. Go to ErrorsIntegrations, click Configure on the GitHub integration, and follow Review permissions in GitHub.