Notes
This release of the Python agent removes support for Python lambda function in the config file, excludes the newrelic header by default, adds support for exclude and include settings for Hybrid Agent traces, anthropic instrumentation, gemini response streaming, improves caching of IS_PYPY in gc_data.py for performance, and adds http.statusCode attribute in transaction events. This release also resends modules during reconnect ensuring they are recorded, guards garbage collection metrics against re-entrant calls, fixes task propagation in async generators and starlette context propagation in StreamingResponse.
Install the agent using easy_install/pip/distribute via the Python Package Index, using conda via the Conda-Forge Package Index, or download it directly from the New Relic download site.
Removed features
-
Remove support for Python lambda functions in the config file
- Previously, the agent allowed specifying a Python lambda function to dynamically name transactions, background task, database trace, profile trace, external trace url and method, function trace, generator trace, and memcache trace. Since support for this feature exposes a security vulnerability in the agent this feature is being removed.
Deprecations
- The
response.statusattribute inWebTransactions is considered deprecated and will be removed in the upcoming 14.0.0 release. It is being replaced byhttp.statusCode. We recommend replacing all references toresponse.statuswithhttp.statusCode.
New features
-
Exclude the
newrelicheader by default- The
newrelicdistributed tracing header is now no longer sent by default. Only the W3Ctraceparentandtracestateheaders will be sent.
- The
-
Add exclude and include settings for Hybrid Agent traces
opentelemetry.traces.includefor the configuration file orNEW_RELIC_OPENTELEMETRY_TRACES_INCLUDEto be used as an environment variableopentelemetry.traces.excludefor the configuration file orNEW_RELIC_OPENTELEMETRY_TRACES_EXCLUDEto be used as an environment variable
The Hybrid Agent's default behavior will be different as well. Now, only libraries and tracers that are supported by OpenTelemetry but not already supported by New Relic will utilize OpenTelemetry's instrumentation. Otherwise, the agent will default to the New Relic instrumentation hooks.
More information about these settings can be found in the Python Agent configuration page as well as the OpenTelemetry API support page.
-
Add Anthropic streaming instrumentation
- Adds instrumentation support for anthropic.
-
Improve caching of IS_PYPY in gc_data.py for performance
-
Now checks and caches IS_PYPY once when the module is loaded.
-
Add Gemini response streaming
- Add response streaming support to Gemini through the google-genai package.
-
Add
http.statusCodeattribute to transaction events- To conform with the rest of the language agents, the Python agent now sends the http status to the
WebTransactionattributehttp.statusCode. The Python agent will continue to send the attribute toresponse.statusas well, but theresponse.statusattribute will be removed in the future.
- To conform with the rest of the language agents, the Python agent now sends the http status to the
Bugs
-
Resend modules during reconnect
- The agent previously only sent the module list periodically after the first connect cycle. If the agent reconnected to the collector, this data would not be resubmitted, so the UI would no longer show the module data. This has now been fixed.
-
Guard garbage collection metrics against re-entrant calls
- Adds a flag to prevent re-entrant calls to
_GCDataSource.record_gc()to prevent infinite recursion on Python 3.13+.
- Adds a flag to prevent re-entrant calls to
-
Enable task propagation in async generators
- Fixes an issue where
AsyncGeneratorProxywould not properly handle transaction context propagation if spread over multiple tasks.
- Fixes an issue where
-
Fix Starlette context propagation in
StreamingResponse- Adds trace context propagation to starlette
StreamingResponsefor both synchronous and asynchronous generators.
- Adds trace context propagation to starlette
Support statement
We recommend updating to the latest agent version as soon as it's available. If you can't upgrade to the latest version, update your agents to a version no more than 90 days old. Read more about keeping agents up to date.
See the New Relic Python agent EOL policy for information about agent releases and support dates.