This is a binding to the New Relic C SDK, that allow to take advantage of New Relic's monitoring capabilities and features to instrument in programs written in Crystal.
The binding itself is fully featured and could be found in LibNewRelic. Also provided some wrappers and macros to simplify basic use cases. See below
-
Add the dependency to your
shard.yml
:dependencies: newrelic: github: romul/newrelic.cr
-
Run
shards install
-
Copy
libnewrelic.a
to/usr/local/lib
cp lib/newrelic/bin/libnewrelic.a /usr/local/lib/libnewrelic.a
- Copy
newrelic-daemon
wherever you would like
cp lib/newrelic/bin/newrelic-daemon newrelic-daemon
Note: Copies of libnewrelic.a
& newrelic-daemon
are built for Linux x86_64 for 1.1.0 version of C-SDK, if you would like another target platform or version, please follow build instructions from C-SDK
- export NEWRELIC_LICENSE_KEY="your license key"
require "newrelic"
# these 2 lines are required to call only once (when program starts)
NewRelic::Agent.configure_log("newrelic.log") # optional
NewRelic::Agent.start("Your App Name")
NewRelic.web_transaction("transaction_name") do
# some code
NewRelic.segment("segment_name", "Category") do
# some other code
end
end
Note: Don't forget to run newrelic-daemon
on the same machine. Your application, which makes API calls, reports data to the daemon over a socket; in turn, the daemon reports the data to New Relic.
For debug purposes you can start the daemon in the foreground with:
./newrelic-daemon -f --logfile stdout --loglevel debug
- Fork it (https://github.com/romul/newrelic.cr/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
- Roman Smirnov - creator and maintainer
Sponsored by Markeaze