Finding Slow Code with Wrapture

(grahamdumpleton.me)

7 points | by lumpa 2 days ago

1 comments

  • simonw 38 minutes ago
    I'm really excited about this library.

    Wrapture is a new project from Graham, who previously developed wrapt (a 20+ year old Python monkey patching library) and built the first version of the New Relic Python agent - the library that instruments your app so New Relic can show you watt its doing.

    Wrapture provides the ability to both mock and instrument code in the same toolset. You can use it in tests for "did this method fire" or "when this method fires return this dummy data instead", and you can also use it to instrument your code to measure what's called and how long things take.

    It can instrument existing Python code without you modifying that code - you can instead define a TOML file saying which methods you want to instrument and Wrapture will live patch the code for you. This means you can instrument any Python code that you need to run without changing it, and export the results to OpenTelemetry.

    The linked article is part of a series of posts Graham wrote about it. I suggest starting here: https://grahamdumpleton.me/posts/2026/08/introducing-wraptur...

    Then hit the index post he just published that links to his others: https://grahamdumpleton.me/posts/2026/09/trying-out-wrapture...