SDKs overview
New Relic provides a suite of Software Development Kits (SDKs), referred to as 'agents,' to facilitate the instrumentation of applications and infrastructure for performance monitoring and observability. These agents are designed to collect various telemetry data, including metrics, events, logs, and traces, from applications written in different programming languages and running on various platforms. The collected data is then transmitted to the New Relic platform for analysis, visualization, and alerting.
The primary function of New Relic's SDKs is to enable Application Performance Monitoring (APM). This involves tracking key performance indicators such as response times, throughput, error rates, and transaction traces. Beyond APM, agents also support infrastructure monitoring, browser monitoring, and mobile monitoring by integrating directly into the application runtime or server environment. New Relic also supports OpenTelemetry standards, allowing for broader compatibility with open-source instrumentation libraries.
Official SDKs by language
New Relic offers official agents for a range of popular programming languages, each tailored to the specific language's ecosystem and runtime characteristics. These agents are actively maintained and updated by New Relic to ensure compatibility with new language versions and frameworks. The table below outlines the core official SDKs, their typical package names, and common installation methods.
| Language | Package/Agent Name | Installation Command (Example) | Maturity |
|---|---|---|---|
| Java | New Relic Java Agent | java -javaagent:/path/to/newrelic.jar -jar myapp.jar |
Stable, actively developed |
| Python | newrelic |
pip install newrelic |
Stable, actively developed |
| Go | github.com/newrelic/go-agent/v3/newrelic |
go get github.com/newrelic/go-agent/v3/newrelic |
Stable, actively developed |
| Node.js | newrelic |
npm install newrelic --save |
Stable, actively developed |
| Ruby | newrelic_rpm |
Add gem 'newrelic_rpm' to Gemfile, then bundle install |
Stable, actively developed |
| .NET | New Relic .NET Agent | Installer for Windows/Linux, NuGet package for .NET Core | Stable, actively developed |
| PHP | New Relic PHP Agent | Installer for Linux/Windows, PECL extension | Stable, actively developed |
Installation
The installation process for New Relic agents generally involves a few steps:
- Sign up for a New Relic account: Access to the platform is required to obtain your license key.
- Download and install the agent: This varies by language. For Java, it's a JAR file; for Python and Node.js, it's typically a package manager installation (
pipornpm); for .NET and PHP, it often involves a system-level installer or extension. Detailed instructions are available in the New Relic Java agent installation guide and other language-specific guides. - Configure the agent: Agents require configuration, primarily your New Relic license key and an application name. This is usually done via an environment variable, a configuration file (e.g.,
newrelic.yml), or programmatically. - Restart your application: For most agents, the application or server process must be restarted for the agent to initialize and begin collecting data.
For example, to install the Python agent, you would execute pip install newrelic and then configure your application to load the agent, often by setting the NEW_RELIC_LICENSE_KEY and NEW_RELIC_APP_NAME environment variables and importing newrelic.agent at the start of your application.
Quickstart example
This Python example demonstrates how to integrate the New Relic agent into a basic Flask application. This setup enables the agent to automatically instrument web transactions, database calls, and errors.
# app.py
import os
from flask import Flask
# Ensure NEW_RELIC_LICENSE_KEY and NEW_RELIC_APP_NAME are set as environment variables
# Example: export NEW_RELIC_LICENSE_KEY='YOUR_LICENSE_KEY'
# Example: export NEW_RELIC_APP_NAME='My Python Flask App'
# Initialize New Relic agent
# This should typically be done as early as possible in your application's lifecycle
# The agent will look for newrelic.ini or environment variables for configuration
# For more complex configurations, consult the New Relic Python agent documentation:
# https://docs.newrelic.com/docs/agents/python-agent/installation/install-python-agent/
# Check if license key is set before importing newrelic.agent
if os.getenv('NEW_RELIC_LICENSE_KEY') and os.getenv('NEW_RELIC_APP_NAME'):
import newrelic.agent
newrelic.agent.initialize(config_file=None, environment='production') # config_file=None to use env vars
print("New Relic agent initialized.")
else:
print("New Relic agent not initialized. License key or app name missing.")
app = Flask(__name__)
@app.route('/')
@newrelic.agent.function_trace()
def hello_world():
return 'Hello, New Relic!'
@app.route('/slow')
@newrelic.agent.function_trace(name='slow_endpoint_trace')
def slow_endpoint():
import time
time.sleep(0.5) # Simulate some work
return 'This was a slow request!'
if __name__ == '__main__':
app.run(debug=True, port=8000)
To run this example:
- Install Flask and the New Relic Python agent:
pip install Flask newrelic - Set your New Relic license key and application name as environment variables (e.g.,
export NEW_RELIC_LICENSE_KEY='YOUR_KEY',export NEW_RELIC_APP_NAME='MyFlaskExample'). - Run the application:
python app.py - Access
http://localhost:8000/andhttp://localhost:8000/slowin your browser.
After a few minutes, data from your application should appear in your New Relic APM dashboard under the specified application name.
Community libraries
While New Relic provides a comprehensive set of official agents, the community also contributes libraries and integrations that extend New Relic's capabilities or offer alternative instrumentation methods. These often leverage New Relic's public APIs, such as the Telemetry Data Platform APIs for ingesting custom metrics, events, and logs, or the NerdGraph API for programmatic access to New Relic data and configuration.
Examples of community contributions might include:
- Custom instrumentation for niche frameworks: Libraries that provide automatic instrumentation for less common web frameworks or libraries not officially supported by New Relic agents.
- Integrations with specific cloud services: Tools that pull metrics or logs from cloud providers (beyond official integrations) and push them to New Relic via its APIs.
- Open-source exporters: Projects that convert data from other monitoring systems into a format compatible with New Relic, often utilizing OpenTelemetry standards as an intermediary.
- Deployment and automation scripts: Community-developed scripts for automating the deployment and configuration of New Relic agents in various CI/CD pipelines or infrastructure-as-code environments.
Developers can typically find these community-driven projects on platforms like GitHub, often by searching for "New Relic" alongside the specific technology or language. It is important to note that community libraries may not carry the same level of support or maintenance as official New Relic agents.