newrelic/elixir_agent
54.8
Weak · 18 September 2026
10.2k
lines of production code
Elixir
primary language
1
measurement over time
What this system is
This system is the New Relic Elixir agent, an Application Performance Monitoring (APM) library that provides automatic and manual instrumentation for Elixir applications. It captures telemetry data—including metrics, distributed traces, logs, and errors—from key frameworks like Phoenix, Ecto, and Oban, and transmits this data to the New Relic collector. The agent also includes infrastructure for monitoring the underlying Erlang VM and supporting background job processing.
How it got here
2018 — Initial agent release and core infrastructure
21 changes.
This period marks the initial release of the New Relic Elixir agent, establishing the foundational architecture for application performance monitoring. It introduces comprehensive auto-instrumentation for key Elixir libraries, distributed tracing capabilities, and a structured supervision hierarchy for data harvesting and collector communication.
2019–2020 — Telemetry instrumentation and distributed tracing
19 changes.
This period focused on expanding automatic instrumentation for key Elixir frameworks like Phoenix, Ecto, and Redix, while introducing support for the W3C Trace Context standard to enable distributed tracing interoperability. The team also built a new Telemetry SDK for handling logs, spans, and metrics, and developed a comprehensive suite of example applications and integration tests to validate these new capabilities.
2021–2025 — Auto-instrumentation expansion and example apps
9 changes.
This period focused on extending automatic instrumentation capabilities to cover Phoenix LiveView, Mix tasks, Oban job processing, and Absinthe GraphQL APIs. The team also introduced dimensional metrics harvesting and structured error reporting to improve telemetry data quality and accuracy. Comprehensive test coverage and dedicated example applications were added to validate these new features and guide users.
Features
Add Ecto SQL telemetry instrumentation
New files in lib/new\_relic/telemetry/ecto introduce support for tracking Ecto database queries. The handler captures query metrics (duration, queue time, decode time) and reports them as New Relic datastore spans and metrics, including SQL statements, table names, and operations. The metadata parser extracts table and operation details from Postgrex and MyXQL results, with fallback logic for other adapters. A supervisor detects Ecto repo initialization events to dynamically attach telemetry handlers.
_lib/new\relic/telemetry/ecto · high confidence
Add Ecto example app with multi-database support
The Ecto example application now includes a new \EctoExample.Database\ module that automatically starts and migrates repositories for PostgreSQL, MySQL, and SQLite3. The \EctoExample.Router\ exercises these adapters by running error, count, stream, and delete queries against all three databases, providing a comprehensive demonstration of multi-adapter support within the example.
_examples/apps/ecto\example/lib · high confidence
Add Redix example application with HTTP endpoints
The Redix example application now includes a web interface via a Plug-based router. Users can access the /hello endpoint to perform Redis operations (SET, GET, pipeline, and direct PID-based commands) and the /err endpoint to trigger pipeline errors, facilitating easier testing and demonstration of Redix features within a Phoenix/Plug context.
_examples/apps/redix\example/lib · high confidence
Add W3C Trace Context Validation Service example
Introduces a new example application that implements the W3C Trace Context Validation Service. The app runs an HTTP server on port 4002 and exposes a /test endpoint that accepts JSON payloads, forwards them to external URLs, and injects distributed trace headers via New Relic to validate trace context propagation.
_examples/apps/w3c\_trace\_context\validation · high confidence
Add W3C Trace Context support for distributed tracing
NewRelic agents now support the W3C Trace Context standard, enabling interoperability with other tracing systems. This change introduces parsing and encoding for the \traceparent\ header (defining version, trace ID, parent ID, and flags) and the \tracestate\ header (handling NewRelic-specific vendor data and other vendor entries). The implementation includes validation logic to reject invalid headers and restrict access to NewRelic-specific state based on trusted account keys, ensuring that distributed traces are correctly propagated and interpreted across service boundaries.
_lib/new\_relic/distributed\_trace/w3c\_trace\context · high confidence
Add automatic instrumentation for Mix tasks and non-linked Task processes
New Relic now automatically instruments Mix tasks and connects non-linked Task processes (such as those created via Task.start, Task.async\_stream, and Task.Supervisor) to the current transaction. This ensures that background work spawned by these mechanisms is captured in the transaction trace, providing end-to-end visibility for asynchronous operations that previously ran outside the transaction context.
_lib/new\relic/instrumented · high confidence
Add support for New Relic Span Events and Distributed Tracing
The library now generates and reports Span Events, enabling Distributed Tracing capabilities. A new \NewRelic.Span.Event\ module defines the span data structure and formats intrinsics for HTTP and datastore categories, while \NewRelic.Span.Reporter\ routes these spans to either the standard Collector or the Infinite Tracing SDK based on feature configuration.
_lib/new\relic/span · high confidence
Added Oban example application
A new example application has been added to demonstrate the auto-instrumentation of Oban. This includes the necessary project structure files such as the formatter configuration, gitignore rules, and a README explaining the app's purpose.
_examples/apps/oban\example · high confidence
Added Oban example application for job processing
A new example application has been added to demonstrate Oban integration. It includes an application module that starts the Oban supervisor with PostgreSQL-based notification and inline testing mode, and a worker implementation that handles job execution, including specific error handling for jobs marked with an 'error' argument and simulated processing delays for standard jobs.
_examples/apps/oban\example/lib · high confidence
Added example app demonstrating Mix.Task instrumentation and graceful degradation
The \examples/apps/instrumented\_task\ directory now includes an example application that showcases how to instrument a \Mix.Task\ using \NewRelic.Instrumented.Mix.Task\. It provides two tasks: \InstrumentedTask\, which uses the instrumentation macro, and \UninstrumentedTask\, which calls \NewRelic.report\_custom\_metric\ directly to demonstrate that the agent handles calls gracefully even if the \new\_relic\_agent\ application is not started.
_examples/apps/instrumented\task · high confidence
Expanded automatic instrumentation for Phoenix, Absinthe, Oban, and background jobs
The telemetry library now automatically instruments several key Elixir frameworks and libraries. It adds support for Phoenix LiveView (capturing mount, handle\_params, handle\_event, and render lifecycle events), Absinthe GraphQL (tracking operations, field resolution, and query arguments), and Oban background jobs (recording job execution, queue times, and errors). Additionally, it introduces new instrumentation for Finch HTTP client requests and Redix Redis connections, while enhancing existing Phoenix and Plug coverage with more specific transaction naming and error handling.
_lib/new\relic/telemetry · high confidence
Initial implementation of custom and transaction event harvesters
The agent now includes dedicated harvesters for collecting and sending custom events and transaction events. These new components manage event storage with configurable reservoir sizes, apply attribute processing (such as deep flattening for custom events), and handle the reporting of supportability metrics and debug logs upon harvest completion.
_lib/new\_relic/harvest/collector/custom\event · high confidence
Initial implementation of error trace and transaction error event harvesters
The agent now includes dedicated harvesters for collecting and sending error data. The Error Trace harvester buffers up to 20 unique error traces in memory before sending them to the collector, while the Transaction Error Event harvester uses a configurable reservoir size (defaulting to 10) to sample and store transaction error events. Both components track metrics for supportability and log harvest completion details at the debug level.
_lib/new\_relic/harvest/collector/error\_trace, lib/new\_relic/harvest/collector/transaction\_error\event · high confidence
Initial implementation of span event harvesting
Introduces the SpanEvent Harvester, a new GenServer responsible for collecting, prioritizing, and sending span event data to New Relic. This component manages a priority queue of span events, applies sampling logic based on reservoir size, and formats the data for transmission via the collector protocol, enabling detailed distributed tracing support.
_lib/new\_relic/harvest/collector/span\event · high confidence
Initial implementation of the New Relic collector communication layer
This change introduces the core infrastructure for communicating with the New Relic collector, including the AgentRun GenServer for managing connection state and metadata, the Protocol module for handling HTTP requests and response codes (such as 410 for shutdown and 401/409 for restarts), and the Collector Supervisor for managing harvest cycles. It establishes the initial connection flow, payload construction (including labels and display names), and error handling logic for the Elixir agent.
_lib/new\relic/harvest/collector · high confidence
Initial implementation of the metric harvester
The metric harvester component has been introduced to collect and aggregate custom metrics. It provides APIs to report and increment custom metrics, which are then merged and stored using Erlang's :counters module for efficient memory usage. The harvester aggregates call counts, total/exclusive times, and min/max values, encoding floating-point precision into integers before sending the harvested data to the collector.
_lib/new\relic/harvest/collector/metric · high confidence
Initial release of the New Relic Elixir agent (v1.41.0)
This commit introduces the initial version of the New Relic Elixir agent, providing telemetry-based auto-instrumentation for Phoenix, Plug, Ecto, Finch, Oban, Absinthe, and other libraries, along with support for distributed tracing, manual function tracing, and logs in context. The repository is initialized with standard project configuration files including \.formatter.exs\ (with a 120-character line length), \.gitignore\, a \CHANGELOG.md\ documenting features up to v1.41.0, a \README.md\ with installation and usage instructions, and an Apache 2.0 \LICENSE\ file.
(repo-wide) · high confidence
Introduce Erlang VM and process-level application performance monitoring
This change adds a new sampling infrastructure to the agent, introducing dedicated GenServers to monitor the BEAM VM, ETS tables, and specific processes. The Beam sampler collects metrics on memory usage (total, processes, ETS, atoms, binary, code), CPU utilization, scheduler utilization, garbage collections, and I/O. The ETS sampler tracks the size and memory consumption of named tables, while the Process sampler monitors registered processes for memory, message queue length, and reductions. Additionally, a TopProcess sampler identifies the top processes by memory and message queue activity. These samples are reported as custom events, providing deeper visibility into the underlying Erlang runtime performance.
_lib/new\relic/sampler · high confidence
Introduce dimensional metrics harvesting with count, gauge, and summary support
A new harvester module has been added to collect and aggregate dimensional metrics of type count, gauge, and summary. It accepts metrics with attributes, merges them by type, name, and attributes, and formats them for transmission via the Telemetry SDK API, including interval timing and common metadata.
_lib/new\_relic/harvest/telemetry\_sdk/dimensional\metrics · high confidence
Introduction of distributed trace sampling and W3C trace context support
This change introduces the core infrastructure for distributed tracing within the agent. It adds a \BackoffSampler\ GenServer that uses Erlang counters to efficiently manage sampling rates and backoff cycles based on agent targets. It also implements W3C Trace Context support, allowing the agent to extract and generate \traceparent\ and \tracestate\ headers, including parsing New Relic-specific data from the tracestate. Additionally, a \NewRelicContext\ module handles the encoding and decoding of New Relic's proprietary distributed trace payloads, including validation and trust key verification.
_lib/new\_relic/distributed\trace · high confidence
New Absinthe example app with automatic GraphQL instrumentation
An example application demonstrating automatic instrumentation of an Absinthe GraphQL API via the New Relic Agent. The app includes a basic schema and resolvers, with specific tracing enabled for resolver functions using \NewRelic.Tracer\. It also includes tests verifying that the telemetry handlers are correctly attached and that subscription registrations do not detach them, ensuring accurate metric and span collection for GraphQL operations.
_examples/apps/absinthe\example · high confidence
New Ecto example app with telemetry instrumentation
Added a new example application demonstrating how to instrument an Ecto database app with New Relic Agent via telemetry. The example includes configuration files for code formatting and git ignores, along with a README explaining that the instrumentation is fully automatic.
_examples/apps/ecto\example · high confidence
New Phoenix example app with Bandit and LiveView instrumentation
The \examples/apps/phx\_example\ directory now contains a complete, trimmed-down Phoenix application designed to demonstrate auto-instrumentation capabilities. This example includes dual endpoint configurations supporting both the standard Cowboy adapter and the Bandit adapter, along with Phoenix LiveView support. It provides a practical reference for how Phoenix controllers, LiveView components, and error handling are instrumented, including specific telemetry spans for view rendering and transaction metrics.
_examples/apps/phx\example · high confidence
New Relic Agent public API for transaction and attribute management
The library introduces a public API module (\NewRelic\) that allows users to manually manage transaction lifecycle and reporting. Key capabilities include setting transaction names, adding custom attributes (with automatic flattening of nested structures), and starting/stopping 'Other' transactions (non-web processes like GenStage or Tasks) with optional support for connecting to distributed traces via W3C or New Relic headers. It also provides macros for wrapping code blocks in transactions, functions to ignore or exclude processes from transaction reporting, and advanced methods to manually connect processes to existing transactions.
lib · high confidence
New Relic Elixir Agent v1.31.0 Initial Release
This change introduces the initial version (1.31.0) of the New Relic Elixir Agent, adding comprehensive application performance monitoring capabilities. The agent provides automatic instrumentation for Phoenix, Plug, Ecto, Redix, Oban, Absinthe, and Finch via Telemetry, and supports Distributed Tracing with W3C Trace Context and New Relic headers. It includes a new Telemetry SDK-based architecture for sending logs (with Logs in Context), spans, and custom events, alongside configurable feature toggles for error collection, query collection, and function argument collection. The agent also supports infinite tracing, graceful shutdown, and utilization data collection for environments like Kubernetes and Heroku.
_lib/new\relic · high confidence
New Relic agent metric data structures and transformation logic
This change introduces the core data structures and transformation logic for New Relic metrics within the agent. It defines the \NewRelic.Metric\ struct to hold metric fields such as call counts, total/exclusive times, and min/max values, and implements \NewRelic.Metric.MetricData\ to convert internal event types (custom metrics, HTTP dispatchers, web/other transactions, caller durations, and datastore operations) into these standardized metric records. This enables the agent to accurately report performance data including transaction total times and scoped datastore statements to the New Relic backend.
_lib/new\relic/metric · high confidence
New Telemetry SDK for logs, spans, and metrics
A new Telemetry SDK has been introduced to handle the collection and transmission of logs, distributed traces (spans), and dimensional metrics. This includes dedicated API endpoints for posting each telemetry type, a configuration module that determines regional collector URLs (supporting EU regions and infinite tracing hosts), and a supervisor tree that manages the harvesting cycles for logs, spans, and metrics independently.
_lib/new\_relic/harvest/telemetry\sdk · high confidence
New example applications and local development infrastructure
Added a new set of example applications, including a Redix example for Redis auto-instrumentation, along with the necessary infrastructure to run them locally. This includes a docker-compose.yml file to spin up dependent services (PostgreSQL, MySQL, Redis), standardized .formatter.exs and .gitignore files for the examples directory and its sub-apps, and a README explaining how to run tests and add new example apps.
examples · high confidence
New example configuration for New Relic agent integration
A new configuration file has been added to the examples directory to set up the New Relic agent for the example applications. This configuration sets the logger level to debug, defines the New Relic application name and license key settings (with collector bypass enabled for local development), and dynamically imports configuration from sub-applications. It also conditionally imports a secret configuration file if it exists and the environment is not set to test, facilitating easier setup for developers wanting to use New Relic with the example apps.
examples/config · high confidence
New utility modules for error handling, HTTP, and vendor detection
This change introduces several new utility modules in the \lib/new\_relic/util\ directory to support core agent functionality. \NewRelic.Util.Error\ normalizes and formats Erlang errors and stacktraces, with support for redacting arguments based on configuration. \NewRelic.Util.HTTP\ handles outbound requests using \:httpc\ with gzip compression and secure SSL settings via CAStore. \NewRelic.Util.Vendor\ detects infrastructure context by querying AWS metadata, Kubernetes environment variables, and Docker cgroup files. Additional utilities include \NewRelic.Util.Apdex\ for calculating performance scores, \NewRelic.Util.Event\ for processing and limiting event attribute sizes, \NewRelic.Util.PriorityQueue\ for managing high-priority events, \NewRelic.Util.RequestStart\ for parsing queue start times, and \NewRelic.Util.ConditionalCompile\ for version matching.
_lib/new\relic/util · high confidence
Transaction trace harvesting implementation
The agent now includes a dedicated harvester for transaction traces, which collects and stores trace data based on configurable minimum duration, maximum named traces, and maximum slow traces settings. This component aggregates trace information and prepares it for sending to the New Relic collector, supporting the collection of performance metrics for transaction monitoring.
_lib/new\_relic/harvest/collector/transaction\trace · high confidence
Architecture
New structured supervision hierarchy for data harvesting
The library introduces a dedicated supervision tree for the harvesting subsystem, adding \NewRelic.Harvest.Supervisor\ as the root, \NewRelic.Harvest.DataSupervisor\ to manage per-namespace cycles, \NewRelic.Harvest.HarvesterSupervisor\ (a DynamicSupervisor) for individual harvester processes, and \NewRelic.Harvest.HarvestCycle\ (a GenServer) to orchestrate periodic data collection. A new \NewRelic.Harvest.HarvesterStore\ (backed by ETS) tracks current harvester PIDs, enabling the cycle to swap harvesters and send data via \Task.Supervisor\. This structure supports the \manual\_shutdown\ API on the main supervisor, which gracefully stops all harvesters across the defined collector and telemetry SDK cycles.
_lib/new\relic/harvest · high confidence
Behavioural changes
Example app now supports Postgres, MySQL, and SQLite3 repositories
The Ecto example application has been updated to demonstrate support for multiple database adapters. The configuration now defines three repositories—PostgresRepo, MySQLRepo, and SQLite3Repo—each with its own connection settings (host, port, credentials), allowing users to run the example against any of these three database systems.
_examples/apps/ecto\example/config · high confidence
Initial configuration structure for New Relic agent
The application now includes a base configuration file that conditionally imports environment-specific settings, loading a secret configuration file when available in non-test environments. A dedicated test configuration is introduced to set the logger level to warning and define New Relic agent parameters, including the application name, license key, collector bypass mode, automatic attributes, and specific paths to ignore for web transactions.
config · high confidence
Introduce structured error reporting for transactions and processes
Added new modules \NewRelic.Error.Reporter.CrashReport\ and \NewRelic.Error.Reporter.ErrorMsg\ to handle error reporting for both transaction and process contexts. \CrashReport\ specifically filters out non-500 HTTP errors and prevents double-reporting of exceptions re-raised by PlugCowboy, while \ErrorMsg\ provides a standardized way to parse and report error messages and stack traces. These changes ensure that errors are correctly attributed to the relevant process or transaction and reported to New Relic with appropriate metadata.
_lib/new\relic/error/reporter · high confidence
New direct and macro-based function tracing implementation
The tracer module has been refactored to introduce a new direct tracing API (lib/new\_relic/tracer/direct.ex) and a macro-based instrumentation system (lib/new\_relic/tracer/macro.ex). The direct API allows manual span management with configurable limits on open spans, while the macro system automatically wraps functions marked with @trace, supporting guards and private functions. This change also introduces support for extended attributes, configurable argument tracing, and improved handling of external calls and datastore metrics, replacing previous tracing mechanisms with a more flexible and robust foundation.
_lib/new\relic/tracer · high confidence
New error reporting infrastructure using Logger filters
The error collection subsystem has been replaced with a new implementation that hooks into the Erlang/OTP \:logger\ system via primary filters instead of the legacy \error\_logger\ handler. This change introduces dedicated modules for handling crash reports and error messages, formatting them into New Relic-specific event and trace structures, and managing the lifecycle through a new supervisor. Users benefit from more robust error capture that integrates with modern logging standards and correctly distinguishes between transaction-scoped and process-scoped errors.
_lib/new\relic/error · high confidence
New transaction tracking architecture with Erlang trace-based process monitoring
The transaction tracking system has been restructured to use a dedicated Erlang trace mechanism for monitoring spawned processes. New modules including \NewRelic.Transaction.ErlangTrace\, \ErlangTraceManager\, and \ErlangTraceSupervisor\ have been introduced to intercept \proc\_lib\ and \Task.Supervised\ spawn events, allowing the agent to accurately track child processes within a transaction. This is supported by a new \Sidecar\ architecture that manages transaction state and attributes via ETS tables, and a \Complete\ module that handles final transaction processing, including time transformation, queue duration calculation, and the generation of segment trees for distributed tracing.
_lib/new\relic/transaction · high confidence
Redix example app configures HTTP port 4003
The Redix example application now includes a configuration file that sets the HTTP server port to 4003, allowing users to run the example service on this specific port.
_examples/apps/redix\example/config · high confidence
Test coverage
Added integration tests for Ecto example app metrics and query parsing; Added integration tests for New Relic collector connectivity and telemetry data posting; Added test coverage for core agent components; Added tests for Ecto and Finch telemetry instrumentation; Added tests for Oban job instrumentation; Added tests for Redix instrumentation in the example app; Added tests for Telemetry SDK configuration and harvesters; Added tests for auto-instrumented Task module; New test helper module for agent testing.
Dependencies
New example applications and updated agent dependencies
Added new example applications for Absinthe, Ecto, Oban, Phoenix, Redix, and W3C trace context validation to demonstrate agent instrumentation, alongside an updated root mix.exs and lockfile that bump core dependencies such as telemetry to 1.4.2, Ecto to 3.12.5, and Phoenix to 1.7.18.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Baseline
- First survey — no prior run to compare against. CAI 55.
Lenses
- Code Health 98
- Architecture 97
- Maturity 62
- Readiness 29
- Security 91
Changes since last survey
- 300 commits — 264 feature/other, 36 fixes
By area
- lib/new_relic — 113 commits
- (repo) — 64 commits
- (root) — 54 commits
- examples/apps — 27 commits
- .github/workflows — 25 commits
- test/error_test.exs — 4 commits
- config/config.exs — 2 commits
- test/logs_in_context_test.exs — 2 commits
- test/telemetry_sdk — 2 commits
- examples/mix.exs — 1 commit
- lib/new_relic.ex — 1 commit
- test/integration — 1 commit
- test/metric_transaction_test.exs — 1 commit
- test/other_transaction_test.exs — 1 commit
- test/ssl_test.exs — 1 commit
- test/support — 1 commit
Notable commits
- fix: Add license section and fix mailto
- fix: Add missing PR to changelog; attempt to fix integration tests
- fix: Fix Elixir type system complaint
- fix: Fix Finch attributes (#513)
- fix: Fix TTs for bandit
- fix: Fix absinthe subscription regsitration (#566)
- fix: Fix bandit attribute
- fix: Fix bandit duration with exception (#524)
- fix: Fix bandit response time metric
- fix: Fix bug with NewRelic.span
- fix: Fix bug with missing bandit conn
- fix: Fix dializyer complaint about trace_info
- fix: Fix elixir_logger/2 (#510)
- fix: Fix error reporting (#523)
- fix: Fix incorrect spec for report_custom_metric (#544)
- fix: Fix oban queue_time unit
- fix: Fix other transaction leak (#352)
- fix: Fix parsing of other SELECTs (#340)
- fix: Fix phoenix attr
- fix: Fix table name escaping parsing (#338)
- …and 280 more
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
newrelic/elixir_agent was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 18 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 282c7489b08a670babf323f3bea678f10e2fc54b — the exact code this score is about.
- Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-5d04157a340d.