Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8470383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:30:10+00:00 2026-06-10T16:30:10+00:00

I recently found out about ActiveSupport::Notifications . I think it’s a great tool to

  • 0

I recently found out about ActiveSupport::Notifications. I think it’s a great tool to monitor your applications.

I am currently using it outside of Rails to monitor my Sinatra app and it’s working great.

However I use it a lot, to instrument custom queries and would like to somehow notify the result of a query:

my_input = "some_query"
ActiveSupport::Notifications.instrument("myapp.create", :input => my_input) do
  #stuff
  result = search_for my_input
  #stuff
  result
end

Now I can subscribe to this and can also get the query that was executed (which is available in the payload hash). But I would also like to see the result in my subscriber.

So is there a way to add any custom value to the payload while I am executing the block?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T16:30:12+00:00Added an answer on June 10, 2026 at 4:30 pm

    Just stumbled upon your question when I was looking for the same thing.

    You can simply pass in a block variable, it will represent your payload to you, and you can fill it up while you’re in the block

    my_input = "some_query"
    ActiveSupport::Notifications.instrument("myapp.create", :input => my_input) do |instrument|
      #stuff
      result = search_for my_input
      instrument[:my_result] = result
      #stuff
      result
    end
    

    In your subscriber create a new event from the passed argument:

    ActiveSupport::Notifications.subscribe("myapp.create") do |*args|
      event = ActiveSupport::Notifications::Event.new(*args)
      Rails.logger.info event.payload
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently found out about Cytoscape.js and would like to try out the force-directed
I recently found out about the WeakHashMap data structure in Java. However, I don't
I recently found out about C# extension methods and wrote this one: /// <summary>
I recently found out about n-grams and the cool possibility to compare frequency of
Recently I have been learning about WMI and WQL. I found out the list
I recently found out about java.util.Properties , which allows me to write and read
I recently found out about the awesomeness of the iTunes COM for Windows SDK.
I only recently found out about URL rewriting , so I've still got a
I recently asked a question about IIf vs. If and found out that there
I recently found out about Presenter First and read their whitepapers and blogs, etc.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.