newrelic

Version, currently master branch1 version
  • master branchlatestJul 20, 2019

github.com/romul/newrelic.cr

NewRelic support for Crystal

3 stars
0 dependents
License: MIT

Installation

# Add this to your shard.yml
dependencies:
  newrelic:
    github: romul/newrelic.cr
    branch: master

master is a branch, not a release, so this tracks it rather than pinning a version.

Then run:

shards install

shard.yml

Crystal
0.29.0
License
MIT
Author
Roman Smirnov

Dependencies

This version declares no dependencies.

README

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