-
Notifications
You must be signed in to change notification settings - Fork 117
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 support for dry-monitor events #924
Conversation
New hook that adds transaction events every time a dry-monitor notifications instrumentation is called. There's also specific support for `rom-sql` events emitted through `dry-monitor`.
I'm not entirely into adding the |
I do think it's valuable to be able to tell apart ActiveSupport notifications and Dry::Monitor notifications. Maybe instead of the |
|
||
Appsignal::Transaction.current.finish_event( | ||
title || event_id.to_s, | ||
title, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the formatted event test, both title
and name
are set to "query.postgres"
, but in the test for the generic event one of them is left empty. Is that the intended behaviour? If not:
title, | |
title || event_id.to_s, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might also want to provide a .dry
suffix for the resulting event category -- although we don't currently do this for ActiveSupport notifications.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't add dry to the event category. It's the thing that reports it, but no one cares about that detail.
end | ||
|
||
Appsignal::EventFormatter.register( | ||
"sql.dry", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"sql.dry", | |
"sql.rom", |
Let's name it for the gem it's formatting the events for.
We have a bunch of sql formatters that do very similar things and we can combine them one day, but this is a safer approach right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this has to match the prefix given to look for an event formatter when the dry-monitor instrumentation receives the event -- and this instrumentation is generic to all dry-monitor events (just like the activesupport notifications one is generic to all activesupport events)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do so, there's no way of automatically formatting the events rom-sql
emits because they're called just sql
. The suffix is added in the dry-monitor
to add a minimum granularity.
I'm going to propose a change upstream to make rom-sql
emit sql.rom
events instead. As ActiveRecord does.
|
||
Appsignal::Transaction.current.finish_event( | ||
title || event_id.to_s, | ||
title, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't add dry to the event category. It's the thing that reports it, but no one cares about that detail.
def install | ||
require "appsignal/integrations/dry_monitor" | ||
|
||
::Dry::Monitor::Notifications.send(:prepend, Appsignal::Integrations::DryMonitorIntegration) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know we went this route for the active support notifications integration because of performance issues, but I don't know if that's a problem here. We can instead subscribe to the wildcard *
event name instead to receive events from the instrumentation and use the built-in method of listening for events.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I recall correctly (I was taking a look at this yesterday with Luismi) users can create several Dry::Monitor::Notifications
instances, each being its own "notification hub" of sorts -- it's not a singleton like ActiveSupport::Notifications
. This allows us to instrument all instances.
This comment has been minimized.
This comment has been minimized.
Since it doesn't seem that the change that @luismiramirez proposed upstream is going to happen, how about merging the original implementation that @luismiramirez proposed? The one where we internally add (To be clear, the If not, then we may want to consider just closing this. :( |
That approach is probably good enough, but it's been a while since I looked at this PR. Do we have any links to issues/posts/discussions about this upstream change? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs rebase
This comment has been minimized.
This comment has been minimized.
14 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This is a message from the daily scheduled checks. |
New hook that adds transaction events every time a dry-monitor notifications instrumentation is called.
There's also specific support for
rom-sql
events emitted throughdry-monitor
.Screenshot:
Closes: #910