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

Add monitor instrumentation helpers #1161

Merged
merged 4 commits into from
Jul 12, 2024
Merged

Add monitor instrumentation helpers #1161

merged 4 commits into from
Jul 12, 2024

Conversation

tombruijn
Copy link
Member

@tombruijn tombruijn commented Jul 5, 2024

Add new "create a transaction" helpers to replace the monitor_transaction and monitor_single_transaction helpers. These helpers do too much and are confusing to use. We didn't end up using them ourselves anymore in our integrations.

These new helpers are based on what we most commonly do in the Ruby gem to instrument blocks of code.

These helpers don't accept adding metadata to the transaction using an env argument. This can now be set using the instrumentation helpers like set_action, set_params, set_custom_data, etc.

If an app wants to track blocks of code with an instrumentation event, Appsignal.instrument needs to be called in the Appsignal.monitor block.

If this helper were to both create a transaction and an instrumentation event the arguments would get complicated and it becomes unclear what it's meant to be used for.

These helpers support nested transaction in such a way that it won't break anything, but the namespace and action arguments are ignored when a parent transaction is active.

To do

  • Decide if we want to add this
  • Deprecate the monitor_transaction and monitor_single_transaction helpers

@tombruijn tombruijn self-assigned this Jul 5, 2024
@tombruijn tombruijn mentioned this pull request Jul 8, 2024
82 tasks
@tombruijn tombruijn force-pushed the monitor-helper branch 2 times, most recently from cf6a6b8 to 9d1b0bb Compare July 10, 2024 05:40
@tombruijn tombruijn changed the title Add monitor helper Add monitor instrumentation helpers Jul 10, 2024
@tombruijn tombruijn marked this pull request as ready for review July 10, 2024 05:46
lib/appsignal/helpers/instrumentation.rb Outdated Show resolved Hide resolved
lib/appsignal/helpers/instrumentation.rb Outdated Show resolved Hide resolved
lib/appsignal/helpers/instrumentation.rb Outdated Show resolved Hide resolved
lib/appsignal/helpers/instrumentation.rb Show resolved Hide resolved
@tombruijn tombruijn requested a review from unflxw July 11, 2024 14:26
@tombruijn
Copy link
Member Author

@unflxw I've updated the helper. Please review :)

@backlog-helper

This comment has been minimized.

Add new "create a transaction" helpers to replace the
`monitor_transaction` and `monitor_single_transaction` helpers.
These helpers do too much and are confusing to use. We didn't end up
using them ourselves anymore in our integrations.

These new helpers are based on what we most commonly do in the Ruby gem
to instrument blocks of code.

These helpers don't accept adding metadata to the transaction using an
`env` argument. This can now be set using the instrumentation helpers
like `set_action`, `set_params`, `set_custom_data`, etc.

If an app wants to track blocks of code with an instrumentation event,
`Appsignal.instrument` needs to be called in the `Appsignal.monitor`
block.

If this helper were to both create a transaction and an instrumentation
event the arguments would get complicated and it becomes unclear what
it's meant to be used for.

These helpers support nested transaction in such a way that it won't
break anything, but the namespace and action arguments are ignored when
a parent transaction is active.
Immediately call `yield` rather than check if a parent Transaction is
active every time.
Clarify the docs and how to use the helper.
Avoid potential issues with the action name not being set and no
transaction being reported.

For most scenarios it will be fine to set the action name before the
block is instrumented. For the more advanced scenarios the action name
argument can be set to `nil` or `:set_later` and call
`Appsignal.set_action` in the block to set the action name.
@tombruijn tombruijn merged commit 119152d into main Jul 12, 2024
117 checks passed
@tombruijn tombruijn deleted the monitor-helper branch July 12, 2024 13:03
@backlog-helper
Copy link

  • This Pull Request has been closed or merged, but is still in a column that is considered to be 'in progress'. Please move the Pull Request to the 'Done' column when no more work will be done on this. - (More info)

This is a message from the daily scheduled checks.

New issue guide | Backlog management | Rules | Feedback

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.

2 participants