newrelic-python-agent icon indicating copy to clipboard operation
newrelic-python-agent copied to clipboard

NR cannot instrument tracing with python agent on non-web application

Open jonathan-fileread opened this issue 1 year ago • 1 comments

Description NOTE: # ( Describe the problem you're encountering. )

Hello! We've setup a python agent in our kubernetes container that runs a worker which polls from a queue.

The dockerfile entrypoint looks something like this -

CMD ["python3", "/app/workerservice"]

We get logs but we do not receive distributed traces.

We have NEW_RELIC_DISTRIBUTED_TRACING_ENABLED set to true in the environment variables.

New relic is injected via our main.py, looking something like this.


import newrelic.agent

newrelic.agent.initialize()

@newrelic.agent.background_task()

async def main():

insert-some-components-here

if __name__ == '__main__':

asyncio.run(main())

Here's our permalink. permalink: https://onenr.io/0EjOoDd18j6

python agent, newrelic==9.1.2 on python,

we ran the CLI diagnostic, but to no avail.

this is also a non-web-app worker we are looking to monitor - there are no frameworks used, just plain python. [TIP]: # ( Do NOT share sensitive information, whether personal, proprietary, or otherwise! )

Expected Behavior NOTE: # ( Tell us what you expected to happen. )

our goal is to instrument the agent to send distributed traces to the traces directory. we have a lot of dependencies to our worker services that we'd like to monitor.

Troubleshooting or NR Diag results NOTE: # ( Provide any other relevant log data. ) [TIP]: # ( Scrub logs and diagnostic information for sensitive information )

Steps to Reproduce NOTE: # ( Please be as specific as possible. ) [TIP]: # ( Link a sample application that demonstrates the issue. )

  • provided in permalink, but screenshot attached. Screenshot 2023-12-06 at 12 11 45 AM

Your Environment [TIP]: # ( Include as many relevant details about your environment as possible including the running version of New Relic software and any relevant configurations. )

  • added in the permalink Additional context [TIP]: # ( Add any other context about the problem here. For example, relevant community posts or support tickets. )

jonathan-fileread avatar Dec 06 '23 05:12 jonathan-fileread

If main loops forever and never exits than you need to move the background task decorator into something that has a finite start and end time. We will not record a distributed trace until the thing the background task is wrapping has exited. You may also need to set the startup timeout, startup_timeout = 30 so that the first background task is captured.

hmstepanek avatar Dec 28 '23 18:12 hmstepanek

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 26 '25 12:04 stale[bot]

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

Given no response from the user we are closing this issue.

Ak-x avatar Jul 30 '25 12:07 Ak-x