newrelic / newrelic-python-agent

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

Support Lambda Extension #1139

Open rittneje opened 4 months ago

rittneje commented 4 months ago

Is your feature request related to a problem? Please describe.

We are trying to switch from the old log group subscription approach to your Lambda extension. https://github.com/newrelic/newrelic-lambda-extension

It seems that the Python agent doesn't support it though. Even with the layer installed, it still outputs telemetry directly to the logs. And I don't see any mention of the special named pipe (/tmp/newrelic-telemetry) in this repo.

Feature Description

Automatically detect and use the named pipe from the extension, like the other language agents do.

Describe Alternatives

None.

Additional context

None.

Priority

Must Have. Until this is fixed, we are unable to get all of our Python lambda functions to use a unified log group.

workato-integration[bot] commented 4 months ago

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

TimPansino commented 4 months ago

The Lambda functionality is published as layers over at https://github.com/newrelic/newrelic-lambda-layers. The layers include some additional code that is used to interface with the lambda extension. An outdated version of the additional functionality is published to PyPi as newrelic-lambda which contains the handler code needed to interface with the extension. Note that version has missing support for API gateway v2, and will be potentially missing some information from traces if used with API gateway v2.

It's easiest to set up lambda monitoring using our Lambda CLI. You can find an example for Python located here.

hmstepanek commented 4 months ago

Log forwarding should be on by default however, maybe your lambda had it turned off since you were using a different forwarder before. See the following for the necessary configuration options: https://docs.newrelic.com/docs/logs/logs-context/configure-logs-context-python/ Note logging and log forwarding can be set via an environment variable on your lambda if you are not using a configuration file (very likely). Additionally, this should already be configured for you using the process Tim linked above but make sure the following environment variable is set in your lambda as well: NEW_RELIC_SERVERLESS_MODE_ENABLED = true.

rittneje commented 3 months ago

@TimPansino You need to keep your PyPI distribution up to date. We should not be forced to use your layer for a Python library. It's also really annoying to require people tamper with the configuration of their lambda function with regards to the registered handler, as it makes it difficult to easily disable New Relic when it breaks. I also don't understand why Python needs to differ from other languages on this point. Please fix your Python agent so that it just works, like your Go agent does.

@hmstepanek This issue is not about log forwarding. It's strictly about the telemetry that used to be reported via the log group subscription and ingest lambda function.