newrelic / newrelic-python-agent

New Relic Python Agent
https://docs.newrelic.com/docs/agents/python-agent
Apache License 2.0
168 stars 98 forks source link

Update NewRelicContextFormatter to support including stack traces #1169

Open fritzdj opened 1 week ago

fritzdj commented 1 week ago

Feature Description

NewRelicContextFormatter is in place as an option to manually decorate logs. However, there is no support for adding stack traces to the logs. This would be convenient to have and is a blocker for us using NewRelicContextFormatter at the moment.

Proposal: See https://github.com/newrelic/newrelic-python-agent/pull/1168 -- adding stack_trace_limit as a parameter to the NewRelicContextFormatter constructor would be a good option. If defaulted to 0, this could be an opt-in setting. If it's None or > 0, the result would be a key:value pair for the stack trace being added to the log data. If set to None, all frames would be included in the resulting log data.

Priority

Nice to Have -- there are other options to manually instrument logging with New Relic metadata, but this would be a nice option that would be supported with the core lib.

workato-integration[bot] commented 1 week ago

https://new-relic.atlassian.net/browse/NR-284472

fritzdj commented 1 week ago

https://github.com/newrelic/newrelic-python-agent/pull/1168 was submitted to add support for stack traces