Skip to content

Conversation

@lipskis
Copy link
Contributor

@lipskis lipskis commented Aug 26, 2025

This change adds integration for the code_ownership gem.

Heavily inspired by #1364, this integration uses the before_complete transaction hook and the CodeOwnership.for_backtrace method to add instrumentation to the code_ownership gem.

The PR:

  • tags the current transaction with the owner of the module/class in which the error occurs
  • adds a new instrument_code_ownership configuration option that can toggle instrumentation for the code_ownership gem
  • tests different ownership declaration methods - annotation-based, directory-based and glob-based (they all rely on the same public api method)
  • tests hook setup

A minimal Rails test app that shows the integration in action can be found here.

lipskis added a commit to lipskis/diagnose_tests that referenced this pull request Aug 26, 2025
Add expectations for the `instrument_code_ownership` config option.
Related to appsignal/appsignal-ruby#1443
@lipskis lipskis force-pushed the code-ownership-integration branch from f84b1b0 to 06050bb Compare August 26, 2025 15:41
@tombruijn tombruijn added the enhancement An improvement to an existing feature. label Aug 26, 2025
lipskis and others added 3 commits September 18, 2025 10:30
Add instrumentation to the `code_ownership` gem using the
`before_complete` transaction hook.

This change:
- adds `instrument_code_ownership` configuration option that toggles
  instrumentation for the `code_ownership` gem
- tags the current transaction with the owner of the module/class in
  which the error occurs
- adds integration tests for annotation, directory and glob-based
  declaration methods
- adds tests for hook setup
Add missing "ostruct" gem which is no longer available in the Ruby's
standard library.
This change properly handles falsy values from
`CodeOwnership.for_backtrace`.

The change adds tests for internal error logging when config isn't set
up correctly, swaps `require` for `load` and simplifies the integration
spec.
@lipskis lipskis force-pushed the code-ownership-integration branch from 6b87833 to 761fe78 Compare September 18, 2025 07:31
@backlog-helper
Copy link

backlog-helper bot commented Sep 18, 2025

✔️ All good!

New issue guide | Backlog management | Rules | Feedback

@tombruijn tombruijn self-requested a review September 18, 2025 07:59
@lipskis lipskis force-pushed the code-ownership-integration branch 3 times, most recently from 3f6f915 to 8200a33 Compare September 18, 2025 11:34
@lipskis lipskis force-pushed the code-ownership-integration branch from 8200a33 to 098f21b Compare September 18, 2025 14:03
Previously this branch was using a forked version of the
`diagnose_tests` submodule and a specific branch.

This change also adds a changeset.
@lipskis lipskis force-pushed the code-ownership-integration branch from e48b7f0 to 40860cb Compare September 19, 2025 09:19
@lipskis lipskis merged commit 6c87675 into appsignal:main Sep 19, 2025
198 checks passed
@lipskis lipskis deleted the code-ownership-integration branch September 19, 2025 09:29
lipskis pushed a commit that referenced this pull request Oct 1, 2025
AppSignal currently produces log lines if no Team is found, which look like errors and can be confusing. 

```
INFO -- : ║ [2025-09-30T18:13:32 (process) #8][ERROR] appsignal: Error while looking up CodeOwnership team: NoMethodError: undefined method `name' for nil
```

This change handles cases when no `Team` can be found for a `backtrace`.

Follow-up to #1443
lipskis pushed a commit that referenced this pull request Oct 1, 2025
AppSignal currently produces log lines if no Team is found, which
look like errors and can be confusing.

This change handles cases when no `Team` can be found for a `backtrace`.

Follow-up to #1443
fatkodima added a commit to fatkodima/appsignal-ruby that referenced this pull request Oct 1, 2025
AppSignal currently produces log lines if transaction has no errors, which
look like errors and can be confusing.

This change handles cases when `error` is `nil`.

Follow-up to appsignal#1443
lipskis pushed a commit that referenced this pull request Oct 2, 2025
AppSignal currently produces log lines if a transaction has no errors,
which look like errors and can be confusing.

This change handles cases when `error` is `nil`.

Follow-up to #1443
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement An improvement to an existing feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants