Skip to content
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

Ownership integration #1364

Merged
merged 5 commits into from
Jan 17, 2025
Merged

Ownership integration #1364

merged 5 commits into from
Jan 17, 2025

Conversation

unflxw
Copy link
Contributor

@unflxw unflxw commented Jan 9, 2025

Implements an integration for the ownership gem, as discussed on Slack.

Commits

Add instrument_ownership config option

Add a new instrument_ownership configuration option that can be
used to toggle off instrumentation for the ownership gem.

Add after_create transaction hook

Add a hook that allows for blocks of arbitrary code to be applied to
modify a transaction after it has been created.

Add before_complete transaction hook

Add a before_complete transaction hook, which is executed right
before a transaction is completed. Note that, for transactions
containing multiple errors, this hook is called once for each of
the duplicate transactions that is used to report each of the
errors. This allows the context to be customised for each error.

Instrument ownership gem

Add an instrumentation for the ownership gem. When a transaction
is created, if an owner has been set in the gem, use the name of
the owner as the namespace for the transaction. Do the same when an
owner is set during an active transaction.

If more than one owner is set during a transaction, the namespace
will be that of the last owner that was set.

Notes

@thijsc mentioned it would be nice to contribute this to the gem itself. I took a look at that, but I noticed we'd need something like the after_create and before_complete hooks in this PR to make it work. That said, now that those hooks exist, it should be possible to make them part of the public API, discard the instrumentation in this PR, and instead contribute an instrumentation as a PR to the gem.

@matsimitsu suggested using the owner information to automatically assign errors (and performance issues?) to teams, instead of setting the owner as the namespace. At the moment, this PR uses namespaces, but we could use team assignments instead, or alongside it. Beyond this gem, customers might find it useful to be able to set metadata on their transactions and traces that causes them to automatically be assigned to a team or person. I'm unsure how much work that would be, though.

Regarding testing it, I attempted to use a mock to test it, like we do for several other dependencies. It is possible, but I found myself re-implementing the gem and doubting whether my implementation was an accurate representation of the original, so I decided to add a gemfile instead. I'm happy to reconsider this if we want to avoid the additional gemfile and its corresponding CI runs.

@backlog-helper
Copy link

backlog-helper bot commented Jan 9, 2025

✔️ All good!

New issue guide | Backlog management | Rules | Feedback

@unflxw
Copy link
Contributor Author

unflxw commented Jan 9, 2025

@tombruijn I'm interested in any thoughts about the transaction after_create and before_complete hooks, especially if it seems like a bad idea to add these.

Add a new `instrument_ownership` configuration option that can be
used to toggle off instrumentation for the `ownership` gem.
lib/appsignal/transaction.rb Outdated Show resolved Hide resolved
lib/appsignal/transaction.rb Outdated Show resolved Hide resolved
spec/lib/appsignal/hooks/ownership_spec.rb Outdated Show resolved Hide resolved
lib/appsignal/hooks/ownership.rb Outdated Show resolved Hide resolved
lib/appsignal/transaction.rb Outdated Show resolved Hide resolved
lib/appsignal/transaction.rb Outdated Show resolved Hide resolved
lib/appsignal/transaction.rb Show resolved Hide resolved
lib/appsignal/integrations/ownership.rb Show resolved Hide resolved
spec/lib/appsignal/integrations/ownership_spec.rb Outdated Show resolved Hide resolved
spec/lib/appsignal/transaction_spec.rb Outdated Show resolved Hide resolved
Add a configuration option that toggles whether the Ownership gem
integration sets namespaces, or only sets tags. It defaults to false,
meaning it only sets tags.
Add a hook that allows for blocks of arbitrary code to be applied to
modify a transaction after it has been created.
Add a `before_complete` transaction hook, which is executed right
before a transaction is completed. Note that, for transactions
containing multiple errors, this hook is called once for each of
the duplicate transactions that is used to report each of the
errors. This allows the context to be customised for each error.
@unflxw unflxw force-pushed the ownership-integration branch from b2b50cb to ed09e31 Compare January 13, 2025 16:19
@unflxw unflxw requested a review from tombruijn January 13, 2025 16:35
@unflxw unflxw marked this pull request as ready for review January 13, 2025 16:35
@unflxw unflxw requested a review from luismiramirez January 13, 2025 16:35
@backlog-helper
Copy link

Hi @unflxw,

We've found new issues for this Pull Request. Please see the main comment on this issue for a list of all current warnings. This comment will not be updated to reflect resolved warnings.

  • This Pull Request does not include a changeset. Add a changeset if the change impacts users and should be included in the changelog upon release. Read more about changesets.
    Ignore this rule by adding [skip changeset] to your Pull Request body. - (More info)

New issue guide | Backlog management | Rules | Feedback

@unflxw unflxw force-pushed the ownership-integration branch from ed09e31 to b47ddd9 Compare January 13, 2025 17:28
Add an instrumentation for the `ownership` gem. When a transaction
is created, if an owner has been set in the gem, use the name of
the owner as the owner tag for the transaction. Do the same when an
owner is set during an active transaction.

If more than one owner is set during a transaction, the owner tag
will be that of the last owner that was set.

When the `ownership_set_namespace` config option is enabled, set the
namespace for the transaction to the owner as well.
@unflxw unflxw force-pushed the ownership-integration branch from b47ddd9 to 865b348 Compare January 13, 2025 17:33
@backlog-helper

This comment has been minimized.

@backlog-helper

This comment has been minimized.

@backlog-helper

This comment has been minimized.

1 similar comment
@backlog-helper
Copy link


This is a message from the daily scheduled checks.

New issue guide | Backlog management | Rules | Feedback

@unflxw unflxw removed the request for review from jeffkreeftmeijer January 17, 2025 09:08
@unflxw unflxw merged commit c307d46 into main Jan 17, 2025
157 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants