For some functions, the New Relic Python agent API has several options for accomplishing the same thing. For example, tracing a function to provide more details on a New Relic-monitored transaction can theoretically be accomplished, depending on your setup, with any of the following APIs:
- A decorator. This is an import-time API. This will be the easiest option for most Python application setups.
- A context manager. This is a runtime-level API. These APIs might be used if you want to trace code that's not encapsulated in a function.
- A wrapper. The wrapper is used to create a wrapped function without the use of a decorator.
- A path-based wrapper. This would be used to wrap functions outside of the code they're declared in. For example, it can be used to instrument library code that you don't want to modify.
For an example of a Python agent API with all four of these possible, see the
function_trace call entry.
If you need more help, check out these support and learning resources:
- Browse the Explorers Hub to get help from the community and join in discussions.
- Find answers on our sites and learn how to use our support portal.
- Run New Relic Diagnostics, our troubleshooting tool for Linux, Windows, and macOS.
- Review New Relic's data security and licenses documentation.