Skip to content

Commit 0b67413

Browse files
Merge pull request #19320 from hmstepanek/python-release-10-3-0
Python release 10.3.0 -- Please merge Nov 19 AM
2 parents 301ffb5 + 351c1b6 commit 0b67413

File tree

3 files changed

+295
-9
lines changed

3 files changed

+295
-9
lines changed

src/content/docs/apm/agents/python-agent/configuration/python-agent-configuration.mdx

+229-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,44 @@ Here are detailed descriptions of each configuration method:
4949
OR
5050
* Set the `NEW_RELIC_CONFIG_FILE` environment variable. If you use the `newrelic-admin` wrapper script, you must use the environment variable because the wrapper script calls the agent automatically.
5151

52-
The configuration file uses a structure similar to Microsoft Windows `.ini` files. For more information, see the Python ConfigParser module's [file format documentation](http://docs.python.org/library/configparser.html).
52+
The agent supports two types of configuration files, agents v10.2.0 and older must use the `.ini` syntax while agent versions v10.3.0 and above running on Python versions 3.11 and above support `.toml` files as well.
53+
54+
<Collapser
55+
className="freq-link"
56+
id="agent-configuration-file-ini"
57+
title="`.ini` configuration file format"
58+
>
59+
The configuration file uses a structure similar to Microsoft Windows `.ini` files. For more information, see the Python ConfigParser module's [file format documentation](https://docs.python.org/3/library/configparser.html).
60+
61+
The basic structure should look like the following:
62+
63+
```ini
64+
[newrelic]
65+
license_key = <license key>
66+
app_name = Python Application
67+
```
68+
</Collapser>
69+
70+
<Collapser
71+
className="freq-link"
72+
id="agent-configuration-file-toml"
73+
title="`.toml` configuration file format"
74+
>
75+
<Callout variant="tip">
76+
Starting with Python 3.11 the newer `.toml` syntax for configuration was added to the [standard library](https://docs.python.org/3/library/tomllib.html). Agent version `10.3.0` added support for using this newer format.
77+
</Callout>
78+
The configuration file uses Tom's Obvious Minimal Language `.toml` files. For more information, see the [official file format documentation](https://toml.io/en/).
79+
80+
To use the `.toml` syntax, the configuration file's name must end with `.toml` to indicate the syntax type. The standard `pyproject.toml` may be used alongside configuration for other libraries, or you may use a more specific file like `newrelic.toml`.
81+
82+
The basic structure should look like the following:
83+
84+
```ini
85+
[tool.newrelic]
86+
license_key = <license key>
87+
app_name = Python Application
88+
```
89+
</Collapser>
5390

5491
<Callout variant="tip">
5592
A sample configuration file is included with the Python agent as `newrelic/newrelic.ini`. You can also generate one from the `newrelic-admin` script using the `generate-config` command, or download a copy from [our download repo](https://download.newrelic.com/python_agent/release/).
@@ -425,7 +462,7 @@ Here are detailed descriptions of each configuration method:
425462

426463
## Multiple environment configuration [#config-file-deployment-environments]
427464

428-
The agent reads its primary configuration from an agent config section called `newrelic`. You can provide overrides for specific deployment environments (for example, Development, Staging, Production) in additional sections. Preface these sections with `[newrelic:environment]`, where `environment` is replaced with the name of your environment.
465+
The agent reads its primary configuration from an agent config section called `[newrelic]` for `ini` files, or `[tool.newrelic]` for `.toml` files. You can provide overrides for specific deployment environments (for example, Development, Staging, Production) in additional sections. Preface these sections with `[newrelic:environment]` for `.ini` files, or `[tool.newrelic.env.environment]` for `.toml` files (where `environment` is replaced with the name of your environment).
429466

430467
To specify that the agent should use an environment-based configuration, use one of these methods:
431468

@@ -438,6 +475,12 @@ If no environment is specified, the agent will use the default settings as speci
438475

439476
The basic structure of the configuration file is:
440477

478+
479+
<Collapser
480+
className="freq-link"
481+
id="config-file-format-example-ini"
482+
title="`.ini` configuration file format"
483+
>
441484
```ini
442485
[newrelic]
443486
... default settings
@@ -451,6 +494,27 @@ The basic structure of the configuration file is:
451494
[newrelic:production]
452495
... override settings
453496
```
497+
</Collapser>
498+
499+
<Collapser
500+
className="freq-link"
501+
id="config-file-format-example-toml"
502+
title="`.toml` configuration file format"
503+
>
504+
```ini
505+
[tool.newrelic]
506+
... default settings
507+
508+
[tool.newrelic.env.development]
509+
... override settings
510+
511+
[tool.newrelic.env.staging]
512+
... override settings
513+
514+
[tool.newrelic.env.production]
515+
... override settings
516+
```
517+
</Collapser>
454518

455519
## General configuration settings [#general-settings]
456520

@@ -4166,6 +4230,160 @@ For some tips on configuring logs for the Python agent, see [Configure Python lo
41664230
</Callout>
41674231
</Collapser>
41684232

4233+
<Collapser
4234+
id="application_logging.forwarding.custom_attributes"
4235+
title="application_logging.forwarding.custom_attributes"
4236+
>
4237+
<table>
4238+
<tbody>
4239+
<tr>
4240+
<th>
4241+
Type
4242+
</th>
4243+
4244+
<td>
4245+
String
4246+
</td>
4247+
</tr>
4248+
4249+
<tr>
4250+
<th>
4251+
Default
4252+
</th>
4253+
4254+
<td>
4255+
(none)
4256+
</td>
4257+
</tr>
4258+
4259+
<tr>
4260+
<th>
4261+
[Set in](#options)
4262+
</th>
4263+
4264+
<td>
4265+
Config file, environment variable
4266+
</td>
4267+
</tr>
4268+
4269+
<tr>
4270+
<th>
4271+
[Environ variable](#environment-variables)
4272+
</th>
4273+
4274+
<td>
4275+
`NEW_RELIC_APPLICATION_LOGGING_FORWARDING_CUSTOM_ATTRIBUTES`
4276+
</td>
4277+
</tr>
4278+
</tbody>
4279+
</table>
4280+
4281+
A hash with key/value pairs to add as custom attributes to all log events forwarded to New Relic. The value must be formatted like: "key1:value1;key2:value2"
4282+
</Collapser>
4283+
4284+
<Collapser
4285+
id="application_logging.forwarding.labels.enabled"
4286+
title="application_logging.forwarding.labels.enabled"
4287+
>
4288+
<table>
4289+
<tbody>
4290+
<tr>
4291+
<th>
4292+
Type
4293+
</th>
4294+
4295+
<td>
4296+
Boolean
4297+
</td>
4298+
</tr>
4299+
4300+
<tr>
4301+
<th>
4302+
Default
4303+
</th>
4304+
4305+
<td>
4306+
`false`
4307+
</td>
4308+
</tr>
4309+
4310+
<tr>
4311+
<th>
4312+
[Set in](#options)
4313+
</th>
4314+
4315+
<td>
4316+
Config file, environment variable
4317+
</td>
4318+
</tr>
4319+
4320+
<tr>
4321+
<th>
4322+
[Environ variable](#environment-variables)
4323+
</th>
4324+
4325+
<td>
4326+
`NEW_RELIC_APPLICATION_LOGGING_FORWARDING_LABELS_ENABLED`
4327+
</td>
4328+
</tr>
4329+
</tbody>
4330+
</table>
4331+
4332+
Toggles whether the agent will add labels to log records for sending to New Relic.
4333+
</Collapser>
4334+
4335+
<Collapser
4336+
id="application_logging.forwarding.labels.exclude"
4337+
title="application_logging.forwarding.labels.exclude"
4338+
>
4339+
<table>
4340+
<tbody>
4341+
<tr>
4342+
<th>
4343+
Type
4344+
</th>
4345+
4346+
<td>
4347+
List of strings
4348+
</td>
4349+
</tr>
4350+
4351+
<tr>
4352+
<th>
4353+
Default
4354+
</th>
4355+
4356+
<td>
4357+
(none)
4358+
</td>
4359+
</tr>
4360+
4361+
<tr>
4362+
<th>
4363+
[Set in](#options)
4364+
</th>
4365+
4366+
<td>
4367+
Config file, environment variable
4368+
</td>
4369+
</tr>
4370+
4371+
<tr>
4372+
<th>
4373+
[Environ variable](#environment-variables)
4374+
</th>
4375+
4376+
<td>
4377+
`NEW_RELIC_APPLICATION_LOGGING_FORWARDING_LABELS_EXCLUDE`
4378+
</td>
4379+
</tr>
4380+
</tbody>
4381+
</table>
4382+
4383+
A case-insensitive list of label names to exclude when you enable including labels in logs. This attribute does not support wildcards or regex.
4384+
<Callout variant="important">When adding labels as attributes, the agent prefixes the keys with `tags.`. This prefix is <b>NOT</b> included when matching against the exclude filtering rules.</Callout>
4385+
</Collapser>
4386+
41694387
<Collapser
41704388
id="application_logging.forwarding.context_data.enabled"
41714389
title="application_logging.forwarding.context_data.enabled"
@@ -5585,11 +5803,19 @@ To disable default instrumentation, provide a special `import-hook` section corr
55855803
id="example-disable-mysqldb"
55865804
title="Example: Disabling MySQLdb database query instrumentation"
55875805
>
5588-
Add the following to the configuration file:
5806+
Add the following to the `.ini` configuration file:
55895807

55905808
```ini
55915809
[import-hook:MySQLdb]
55925810
enabled = false
55935811
```
5812+
5813+
Or for `.toml` configuration files add the following:
5814+
5815+
```ini
5816+
[tool.newrelic.import-hook.MySQLdb]
5817+
enabled = false
5818+
```
5819+
55945820
</Collapser>
55955821
</CollapserGroup>

src/content/docs/logs/logs-context/custom-tags-agent-forwarder-logs.mdx

+2-6
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ tags:
77
- Tag
88
- Labels
99
metaDescription: For apps monitored by New relic language agents, learn how to add custome tags (labels) to logs.
10-
redirects:
11-
- /docs/enable-logs-context
12-
- /docs/apm/agents/net-agent/configuration/net-agent-configuration
13-
- /docs.newrelic.com/docs/apm/agents/ruby-agent/configuration/ruby-agent-configuration/
14-
- /docs/logs/new-relic-logs/enable-logs-context/enable-logs-context-go
1510
freshnessValidatedDate: 2024-11-17
1611
---
1712

@@ -28,4 +23,5 @@ Supported languages:
2823
* [Ruby](/docs.newrelic.com/docs/apm/agents/ruby-agent/configuration/ruby-agent-configuration/) agent versions 9.16.0 or higher.
2924
* Go: coming soon
3025
* Java: coming soon
31-
* Node.js: coming soon
26+
* Node.js: coming soon
27+
* [Python](/docs/apm/agents/python-agent/configuration/python-agent-configuration) agent versions 10.3.0 or higher.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
subject: 'Python agent'
3+
releaseDate: '2024-11-18'
4+
version: 10.3.0
5+
downloadLink: 'https://pypi.python.org/pypi/newrelic'
6+
features: ['Add Valkey support', 'Add TOML configuration file support', 'Add protobuf v5 support for infinite tracing', 'Add support for attaching custom attributes to logs', 'Add support for attaching labels to logs', 'Minor cleanup of HTTPX instrumentation']
7+
bugs: ['Collect module information periodically']
8+
security: []
9+
---
10+
11+
## Notes
12+
13+
This release of the Python agent adds support for Valkey, configuration via TOML file, protobuf v5 for infinite tracing, attaching custom attributes and labels to log events, and some minor cleanup of HTTPX instrumentation. HTTP/2 support was validated for [Daphne](https://pypi.org/project/daphne/), [Hypercorn](https://pypi.org/project/Hypercorn/), and [HTTPX](https://pypi.org/project/httpx/). Module information is now collected periodically which fixes a bug where the CPU usage would spike on application startup.
14+
15+
The Python agent now allows you to opt-in to adding your custom tags (labels) to agent-forwarded logs. With custom tags on logs, platform engineers can easily filter, search, and correlate log data for faster and more efficient troubleshooting, improved performance, and optimized resource utilization. To learn more about this feature see the [documentation](/docs/logs/logs-context/Custom-tags-agent-forwarder-logs).
16+
17+
Install the agent using `easy_install/pip/distribute` via the [Python Package Index](https://pypi.python.org/pypi/newrelic) or download it directly from the [New Relic download site](https://download.newrelic.com/python_agent/release).
18+
19+
## New features
20+
21+
* Add support for Valkey
22+
23+
* Add instrumentation for [Valkey](https://pypi.org/project/valkey/). Thanks [@jairhenrique](https://github.com/jairhenrique) for the contribution!
24+
25+
* Add TOML configuration file support
26+
27+
* Support to read TOML configuration is now available. Thanks [@Tatsh](https://github.com/Tatsh) for the contribution!
28+
29+
* Add infinite tracing pb2 file for protobuf v5
30+
31+
* This adds an additional pb2 file used for infinite tracing that is compatible with [protobuf](https://pypi.org/project/protobuf/) v5.
32+
33+
* Add support for attaching custom attributes to logs
34+
35+
* A new configuration option has been added called `application_logging.forwarding.custom_attributes` that will add custom attributes to all log events when set.
36+
37+
* Add support for attaching labels to log events
38+
39+
* Labels as attributes can now be added to log events. When `application_logging.forwarding.labels.enabled` is set the values in `labels` will be added to all log events. Labels can be excluded by setting `application_logging.forwarding.labels.exclude`.
40+
41+
## Enhancements
42+
43+
* Minor cleanup of HTTPX instrumentation
44+
45+
* Some minor cleanup was done in the HTTPX instrumentation.
46+
47+
* Validate HTTP/2 support
48+
49+
* Added tests to ensure HTTP/2 support for the following frameworks:
50+
* [Daphne](https://pypi.org/project/daphne/)
51+
* [Hypercorn](https://pypi.org/project/Hypercorn/)
52+
* [HTTPX](https://pypi.org/project/httpx/)
53+
54+
## Bug fixes
55+
56+
* Collect module information from application periodically instead of at startup
57+
58+
* Previously, the New Relic Python agent collected the application's module information all at once during startup. In some extreme cases this would cause a large spike in CPU usage. This enhancement allows the agent to do this incrementally throughout the application's operation, preventing potential memory spikes during agent startup.
59+
60+
## Support statement
61+
62+
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](/docs/new-relic-solutions/new-relic-one/install-configure/update-new-relic-agent/) about keeping agents up to date.
63+
64+
See the New Relic Python agent [EOL policy](/docs/apm/agents/python-agent/getting-started/python-agent-eol-policy/) for information about agent releases and support dates.

0 commit comments

Comments
 (0)