Union Station Ruby hooks core¶ ↑
Union Station is a web application monitoring and performance analytics platform for Ruby. In order for Union Station to analyze your application, your application must send data to Union Station. This gem allows you to do that.
union_station_hooks_core is a web-framework-agnostic gem that
hooks into various Ruby internals in order to send generic
Ruby application analytics information to Union Station. Not all
information can be automatically inferred by hooking into the Ruby
internals, so this gem also provides an API that you can
call at key places in the codebase to supply the right information.
Using Ruby on Rails?¶ ↑
If your application is a Rails application, then you should use the union_station_hooks_rails
gem instead of this gem. union_station_hooks_rails
automatically hooks into Rails to send the right information to Union
Station, so that you don't have to call any APIs. Under the hood,
union_station_hooks_rails makes use of the
union_station_hooks_core API.
Resources: About Union Station | Github | API docs
Table of contents
Installation¶ ↑
Using with Passenger¶ ↑
Note: This documentation section only applies to Passenger 5.0.20 or later!
If you use Passenger, then
you do not need to install the union_station_hooks_core gem.
union_station_hooks_core is bundled with Passenger.
The only thing you need to do is to ensure that the code is called during application startup:
if defined?(UnionStationHooks) UnionStationHooks.initialize! end
(Are you already calling
PhusionPassenger.install_framework_extensions! from somewhere
in your codebase? Please read Legacy code for
important information.)
A good place to call this is in your Rackup file, config.ru.
Or if you are using Rails, you should create a file
config/initializers/union_station.rb in which you call this.
When you have this call in place, enable Union Station support in Passenger. Here are some examples:
-
Passenger with Nginx integration mode
Insert the following config in your virtual host configuration, then restart Nginx:
union_station_support on;
union_station_key <YOUR KEY HERE>;
-
Passenger with Apache integration mode
Insert the following config in your virtual host configuration, then restart Apache:
UnionStationSupport on
UnionStationKey <YOUR KEY HERE>
-
Passenger Standalone
Start Passenger with the --union-station-key parameter:
$ passenger start --union-station-key <YOUR KEY HERE>
Or set the union_station_key configuration option in
Passengerfile.json:
{
"union_station_key": "<YOUR KEY HERE>"
}
Overriding Passenger's version¶ ↑
Note: Are you using union_station_hooks_rails?
Read these
instructions instead.
Each version of Passenger bundles its own version of the
union_station_hooks_core gem. The Passenger maintainers
regularly update their bundled version with the latest version. Sometimes,
you may wish to use a specific version of
union_station_hooks_core, overriding the version that came
bundled with Passenger. For example, we have may published a new version of
union_station_hooks_core with some bug fixes, even though
Passenger hasn't been updated yet.
You can override Passenger's bundled version as follows.
-
Add
union_station_hooks_coreto your Gemfile, like this:gem 'union_station_hooks_core'
-
Install your gem bundle:
bundle install
-
Ensure that your application calls
require 'union_station_hooks_core'during startup, before you access anything in theUnionStationHooksmodule (so before theUnionStationHooks.initialize!call).If you are using Rails, then Rails takes care of that automatically by calling
Bundler.requireinconfig/application.rb, so in that case you don't need to follow this step.
Using without Passenger¶ ↑
It is currently not possible to use Union Station without Passenger. If you would like to have this feature, please let us know.
API¶ ↑
Please refer to the API documentation website.
Legacy code¶ ↑
Before Passenger X.X.X, the Union Station setup instructions used to tell
you to create a config/initializers/passenger.rb in which you
call the following code:
PhusionPassenger.install_framework_extensions! if defined?(PhusionPassenger)
Since Passenger X.X.X,
PhusionPassenger.install_framework_extensions! has become an
alias for UnionStationHooks.initialize!, but the former is
considered deprecated. Please replace the above code with:
if defined?(UnionStationHooks) UnionStationHooks.initialize! end
And please also rename config/initializers/passenger.rb to
config/initializers/union_station.rb.
Contributing¶ ↑
Looking to contribute to this gem? Please read the documentation in the hacking/ directory.