Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NewRelic agent: Failed to extract source code context from callable #515

Closed
altonotch opened this issue Apr 10, 2022 · 4 comments · Fixed by #708
Closed

NewRelic agent: Failed to extract source code context from callable #515

altonotch opened this issue Apr 10, 2022 · 4 comments · Fixed by #708

Comments

@altonotch
Copy link

Description
I added newrelic apm to a tornado based application. The agent is outputting a lot of error messages: newrelic.api.time_trace ERROR - Failed to extract source code context from callable <address.to.request.handler.here>. Report this issue to newrelic support.

Is this something in our code?

Expected Behavior
No error messages and expected to see transactions in the APM.

Steps to Reproduce

  1. install newrelic==7.10.0.175
  2. wrap python main.py execution in newrelic-admin run-python path/to/code

Your Environment
Python 3.9.2
NewRelic 7.10.0.175
Tornado 6.1.0

@TimPansino
Copy link
Contributor

Hello! This is an issue in a new feature we've just added in this version. If you're seeing that log message, your application should be safely recovering from the issue and there shouldn't be any crashes related to it. (If there are, definitely let us know.)

Could you tell us a bit about the callable this error message is referencing? We'd like to figure out what's not functioning as expected and get that data reporting. Specifically in the logs where you've redacted it to say: <address.to.request.handler.here>

Is that piece of code a function, a functools.partial, a callable object, a classmethod, etc?

If the log messages are bothering you and you'd like to temporarily disable the new feature you can use this setting to temporarily disable it.

@altonotch
Copy link
Author

What we have is a class, a request handler, that is decorated with a function that returns a configured handler, with changed type.

From the error message, it looks like the part that causes the failure in the agent is the decorator.

Basically this part, see example code, specifically this:

app = Application([
    (r'/user/(.*)', ProfileHandler, dict(database=database)),
    ])

Let's say you have:

@configure_handler(configs=some_configs_obj)
class SomeHandler(RequestHandler):
    ...

and configure_handler is something like this:

def configure_handler(config: GenericHandlerConfig) \
        -> Callable[[GenericHandlerClassType], GenericHandlerClassType]:
    def inner_configure(cls: GenericHandlerClassType) -> GenericHandlerClassType:
        return type("GenericHandler_configured", (cls,), dict(_is_debug=config.is_debug))
    return inner_configure

And the error in the agent is for "GenericHandler_configured".

Hope this helps.

@stale
Copy link

stale bot commented Jun 13, 2022

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 stale bot added the stale label Jun 13, 2022
@hmstepanek
Copy link
Contributor

We have a fix coming for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants