question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add option to record tracebacks alongside query or cache records

See original GitHub issue

In our quite large projects we sometimes have troubles understanding where a query or cache operation comes from. We sometimes record perf-rec on a whole self.client.get() operation which may include template rendering and so on. We sometimes spend a lot of times to debug this, leading sometimes in monkeypatching django to find where the incriminating query comes from 🙄.

I thought we could have that information directly in our records, for debug purpose only of course.

So I worked on a small POC to allow the user to define a pattern in the settings, when an operation matches that pattern, it stores the current traceback alongside the other info (sql, or keys and operation…) and displays it in the yaml record.

If you find it interesting and would like for me to work on it further to integrate the feature in django-perf-rec that’d be great 😃

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
adamchainzcommented, Nov 4, 2020

🎉 Released in version 4.9.0, from PR #299.

Thanks for your work and persistence on this @nadege , definitely a useful addition!

1reaction
nadegecommented, Aug 28, 2020

Hello again 😃

Now that the refactor is done, I’m looking into this again. Could you give me more detail on the callback idea you had, if you remember ? What I understand/imagine is: a function written in the user codebase, its path passed to django-perf-rec via a settings. The setting default value would be a function returning false, so we don’t record the traceback by default. The callback would be called inside the on_op function, with the operation as parameter.

Like this:

    def on_op(self, op):
        op_record = {op.name: op.query}

        callback = import_function(settings.TRACEBACK_CALLBACK)
        if callback(op):
            op_record["traceback"] = traceback.StackSummary.from_list(op.tb).format()

        self.record.append(op_record)

Or was it something else?

Read more comments on GitHub >

github_iconTop Results From Across the Web

15.00 - Example: Complete Function Traceback Scenario
The following CREATE FUNCTION request, returned by a SHOW FUNCTION request submitting using BTEQ, defines the traceback UDF that was used for this...
Read more >
Reading and writing data to the cache - Apollo GraphQL Docs
You can read and write data directly to the Apollo Client cache, without communicating with your GraphQL server. You can interact with data...
Read more >
Python Logging Guide - Best Practices and Hands-on Examples
Handlers send the log records (created by loggers) to the ... prints and possible tracebacks, to syslog with the app name attached:.
Read more >
8. Configuration Reference — BIND 9 9.18.8 documentation
One common configuration to share a cache is to allow all views to share a single cache. This can be done by specifying...
Read more >
Making queries | Django documentation
Once you've created your data models, Django automatically gives you a database-abstraction API that lets you create, retrieve, update and delete objects.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found