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

Rails notifications: investigate subscribe to custom event topics #1517

Closed
6 tasks
fallwith opened this issue Oct 1, 2022 · 3 comments
Closed
6 tasks

Rails notifications: investigate subscribe to custom event topics #1517

fallwith opened this issue Oct 1, 2022 · 3 comments
Assignees
Labels
rails Issues related to the Ruby on Rails framework

Comments

@fallwith
Copy link
Contributor

fallwith commented Oct 1, 2022

Rails' ActiveSupport::Notifications will allow users to set up the publication of and subscription to custom event topics. See Creating custom events.

We should investigate if there is a good way to ask an app for a list of custom events it has on the go and then subscribe to those. Alternatively, we could offer an allow list of topic names to subscribe to in the agent configuration.

Tasks

  • Determine if a Rails app can be asked for a list of custom topics
  • Determine the best way to instruct the agent to subscribe to custom topics
    • All custom topics?
    • Allowlist of topics?
    • Blocklist of topics?
  • Should we expose our subscriptions API in a manner similar to our tracer API and allow the customer to have complete control over the monitoring of custom notifications? Perhaps a user could specify a datastore segment or use a generic span.

Some example custom events as described here:

  • User login and logout
  • Password change success or fail
  • User login failed or succeeded
  • OR any other user activity
@workato-integration
Copy link

@fallwith fallwith added this to the Rails Notifications milestone Oct 1, 2022
@hannahramadan hannahramadan changed the title Rails notifications: subscribe to custom event topics Rails notifications: investigate subscribe to custom event topics Oct 17, 2022
@kaylareopelle kaylareopelle added rails Issues related to the Ruby on Rails framework and removed core technology labels Oct 28, 2022
@fallwith
Copy link
Contributor Author

Determine if a Rails app can be asked for a list of custom topics

  • The public API for events seems to want the caller to already be aware of the name of an event.
  • We can get at the list of string events with ActiveSupport::Notifications.notifier.instance_variable_get(:@string_subscribers).keys
    • The other type of events besides "string" events is "other" events, which are stored in @other_subscribers
  • The list of events will be mix of default Rails events AND custom events.
    • There does not appear to be way to differentiate the default ones from the custom ones.
    • We could potentially keep a predefined list of all known Rails events and suspect all others to be custom
      • This approach would only work if the instrumented Rails app was at or below the latest version known to the agent. Otherwise, we couldn't rule out new default events having been added by a newer Rails version.

Determine the best way to instruct the agent to subscribe to custom topics

  • All custom topics?
  • Allowlist of topics?
  • Blocklist of topics?

Given that the list can not be separated into custom and non-custom events, the event list is not exposed via a public API, and any automated determination cannot be easily futureproofed, I'm currently leaning to requiring an allowlist of custom events to monitor in the config.

@fallwith
Copy link
Contributor Author

fallwith commented Dec 2, 2022

Investigation and implementation complete. See #1659.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rails Issues related to the Ruby on Rails framework
Projects
Archived in project
Development

No branches or pull requests

2 participants