Skip to content

romul/newrelic.cr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NewRelic support for Crystal

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

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      newrelic:
        github: romul/newrelic.cr
  2. Run shards install

  3. Copy libnewrelic.a to /usr/local/lib

cp lib/newrelic/bin/libnewrelic.a /usr/local/lib/libnewrelic.a
  1. 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

  1. export NEWRELIC_LICENSE_KEY="your license key"

Usage

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

Contributing

  1. Fork it (https://github.com/romul/newrelic.cr/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

Sponsored by Markeaze

About

NewRelic support for Crystal

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages