1. APM agents #
Automatic instrumentation per language.
Principle #
An APM agent loads into the application process and automatically instruments known frameworks (web servers, HTTP clients, databases, message queues). It aggregates measurements and sends them roughly every minute (harvest cycle).
| Language | Installation | Specifics |
|---|---|---|
| Java | -javaagent:newrelic.jar | bytecode instrumentation |
| .NET | CLR profiler (installer or NuGet package) | .NET Framework and .NET Core |
| Node.js | npm install newrelic + node -r newrelic | must load before any other module |
| Python | pip install newrelic + newrelic-admin run-program | no code change |
| Ruby, PHP | gem / PHP extension + daemon | the PHP daemon batches sends |
| Go | Go module | manual in-code instrumentation (no dynamic loading) |
Configuring a Python agent #
pip install newrelic==14.3.0
export NEW_RELIC_LICENSE_KEY=<license key>
export NEW_RELIC_APP_NAME=boutique
newrelic-admin run-program gunicorn app:app --bind 0.0.0.0:8000- Configuration uses a file (
newrelic.ini,newrelic.yml…) orNEW_RELIC_*variables, handier in containers. - The application name groups every instance reporting under the same name; several names separated by
;allow an extra rollup. - The region (US or EU) is derived from the license key.
Best practice : Pin the agent version in your dependencies and update it regularly: each release adds frameworks and fixes vulnerabilities.
2. Transactions, Apdex and errors #
Measuring what the user experiences.
Transactions and Apdex #
A transaction is a complete unit of work: web request or background job. It breaks down into segments (code, database, external calls) visible in the breakdown and in transaction traces captured for the slowest ones (by default above 4 × T).
| Apdex class | Condition (T = 0.5 s by default) |
|---|---|
| Satisfied | ≤ T |
| Tolerating | between T and 4T |
| Frustrated | > 4T or error |
Score = (satisfied + tolerating / 2) / total, between 0 and 1. Adjust T per application to the expected latency.
Errors #
- Unhandled exceptions and HTTP error codes are recorded as
TransactionError. - Expected errors (validation, business 404) stay visible but affect neither error rate nor Apdex; ignored errors are not recorded.
- Errors inbox groups errors by fingerprint across services, lets you assign them, mark them resolved and be notified if they come back.
3. Distributed tracing #
Following a request end to end.
Propagation #
- Recent agents enable distributed tracing by default and propagate W3C Trace Context (
traceparent,tracestate) alongside thenewrelicheader: a trace can cross services instrumented by New Relic and by OpenTelemetry. - Default sampling is adaptive head-based; Infinite Tracing sends every span to a trace observer that keeps interesting traces (errors, slowness) afterwards (tail-based).
- The service map and Dependencies view are built from this data.
Enriching data #
import newrelic.agent
@app.post('/order')
def order():
newrelic.agent.add_custom_attribute('customer.plan', customer.plan) # attribute on the Transaction
newrelic.agent.record_custom_event('Order', {'amount': total, 'country': country}) # new NRQL event
...Custom attributes become NRQL dimensions (FACET customer.plan); custom events create a new queryable type (FROM Order).
Watch out : Do not record personal data (e-mail, card) in attributes: use agent exclusion rules or obfuscation rules.
4. OpenTelemetry with New Relic #
The open standard, natively accepted.
Sending OTLP #
export OTEL_EXPORTER_OTLP_ENDPOINT=https://otlp.nr-data.net # EU: https://otlp.eu01.nr-data.net
export OTEL_EXPORTER_OTLP_HEADERS="api-key=$NEW_RELIC_LICENSE_KEY"
export OTEL_SERVICE_NAME=payment
export OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=delta
opentelemetry-instrument python app.py- Ports 4317 (gRPC) and 4318 (HTTP); the
api-keyheader carries a license key. - New Relic recommends delta temporality for metrics; with a Collector, the
cumulativetodeltaprocessor does the conversion. - The service entity is created from the
service.nameresource attribute.
Agent or OpenTelemetry? #
| Criterion | New Relic agent | OpenTelemetry |
|---|---|---|
| Getting started | very simple, full experiences | SDK and Collector to configure |
| Specific features | thread profiler, application security, automatic logs in context | depends on instrumentation libraries |
| Portability | New Relic specific | switch backend without re-instrumenting |
Best practice : Both mix fine in the same system thanks to W3C context: keep agents where they bring the most, OpenTelemetry for new services.
Deployments #
Record every release (change tracking) from CI, via NerdGraph or the CLI: markers appear on APM charts and the comparison view shows the impact on latency and errors.
Commands to know #
Commands to know
newrelic-admin run-program <commande>: run an instrumented Python applicationjava -javaagent:/opt/newrelic/newrelic.jar -jar app.jar: load the Java agentnode -r newrelic server.js: load the Node.js agentOTEL_EXPORTER_OTLP_HEADERS="api-key=…": authenticate OTLP exportSELECT apdex(duration, t: 0.5) FROM Transaction FACET appName: Apdex per application
Sources #
Checked in November 2026: New Relic evolves its platform continuously (UI, plans, limits); check the documentation before relying on a detail.
My progress
Sign in to track your progress and take notes. Sign in
💬 Questions about this lesson
No questions yet: be the first to ask for help or share your configuration.
Recommended Articles
NRQL: querying all your New Relic data
Mastering NRQL, New Relic's query language: SELECT … FROM structure, filters, aggregation functio...
Profiles, OpenTelemetry's fourth signal: continuous profiling and correlation with traces
Understand OpenTelemetry's new profile signal: continuous profiling, flame graphs, data model and...
Traefik: distributed tracing with OpenTelemetry
Enable Traefik v3 tracing with OpenTelemetry (OTLP), propagate the W3C context to applications, s...
From click to database: front-end to back-end traces with Faro
Link browser requests to back-end traces: TracingInstrumentation, traceparent header propagation,...
New Relic dashboards: building, sharing and analysing
Building useful dashboards in New Relic: NRQL widgets, chart choice, template variables, facet li...
Alerts, service levels and incidents in New Relic
Setting up useful alerting in New Relic: policies and NRQL conditions, static and anomaly thresho...
Automating New Relic and controlling costs
Managing New Relic as code and keeping the bill under control: NerdGraph API, newrelic CLI, newre...
New Relic best practices
Best practices to succeed with New Relic: adoption approach, account organization, naming and tag...
Distributed tracing: context propagation (W3C Trace Context and baggage)
Understand and implement OpenTelemetry context propagation: the traceparent header, tracestate, b...