<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/live-tracing-with-wrapture-6xkqkaede" -->

---
title: Live tracing with wrapture | daily.dev
description: Wrapture's bindings, originally introduced for unit testing, turn out to double as a live tracing mechanism: the same objects that record calls onto a test...
canonical: https://daily.dev/posts/live-tracing-with-wrapture-6xkqkaede
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Live tracing with wrapture | daily.dev
og:description: Wrapture's bindings, originally introduced for unit testing, turn out to double as a live tracing mechanism: the same objects that record calls onto a test...
og:url: https://daily.dev/posts/live-tracing-with-wrapture-6xkqkaede
og:image: https://api.daily.dev/og/posts/6xkqkaeDE.png
og:image:alt: Live tracing with wrapture
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Live tracing with wrapture

**[Planet Python](https://daily.dev/sources/planetpython)** · 8 min read · 0 upvotes · 0 comments

## Summary

Wrapture's bindings, originally introduced for unit testing, turn out to double as a live tracing mechanism: the same objects that record calls onto a test tape can instead stream events to a sink while a program runs. Using an example order service (gateway charge, ledger record, notifier send), the post shows binding three methods and registering a Printer sink that prints nested call/return/exception events with timings, no timeline() required. It covers redacting sensitive arguments (card numbers) with redact(), the near-zero cost of bindings when no sink is listening (~0.5us dispatch overhead), and narrowing noisy traces via sink combinators like Depth(1, ...) or binding-level when= predicates and tree=True to suppress an entire declined call's subtree, plus filtered_calls counters to account for skipped events.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://grahamdumpleton.me/posts/2026/09/live-tracing-with-wrapture>

## Questions this post answers

### How can I trace a running Python program's method calls without adding log lines everywhere?

Apply wrapture bindings to the methods you care about and register a sink such as Printer instead of a test timeline; the binding emits start, return, and exception events with real arguments and timing as the program runs. Nesting is shown via indentation, returns use a -> marker, and exceptions use a !! marker, all without editing the traced code's logic.

_Developers instrumenting live services for debugging can compare tracing approaches like this on daily.dev._

### How do I prevent sensitive arguments like card numbers from appearing in a Python trace or log?

Use a redact() capture policy on the binding, for example wrapture.binding(Gateway, "charge", capture=wrapture.redact("card")), which replaces the specified argument with a placeholder like '<redacted>' in every emitted event while leaving all other captured data unchanged.

_Anyone hardening logging or tracing pipelines against leaking secrets can track techniques like this on daily.dev._

### What is the performance overhead of leaving tracing bindings applied in production when nothing is listening?

An applied binding with no active listener constructs no event at all, so the wrapped method only pays for wrapt's own dispatch overhead, measured at about half a microsecond per call. This near-zero cost is what makes it practical to leave bindings on interesting methods permanently and let a sink decide at runtime whether anything gets recorded.

_Engineers weighing always-on instrumentation costs can follow performance tradeoffs like this on daily.dev._

## Similar posts on daily.dev

- [Recording calls with wrapture](https://daily.dev/posts/recording-calls-with-wrapture-hkpb9gqvx) · Planet Python · 0 upvotes · 1 comments
- [Zero-code tracing with wrapture](https://daily.dev/posts/zero-code-tracing-with-wrapture-yy6qgb3me) · Planet Python · 1 upvotes · 0 comments
- [Beyond callables in wrapture](https://daily.dev/posts/beyond-callables-in-wrapture-a41yd6lmi) · Planet Python · 0 upvotes · 0 comments
- [Introducing wrapture](https://daily.dev/posts/introducing-wrapture-ohj3cvcws) · Planet Python · 1 upvotes · 1 comments

---

Tags: [#python](https://daily.dev/tags/python), [#testing](https://daily.dev/tags/testing), [#observability](https://daily.dev/tags/observability)

[View this post on daily.dev](https://daily.dev/posts/live-tracing-with-wrapture-6xkqkaede)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Live tracing with wrapture","url":"https://daily.dev/posts/live-tracing-with-wrapture-6xkqkaede","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/live-tracing-with-wrapture-6xkqkaede"},"datePublished":"2026-09-07T01:51:16.486Z","dateModified":"2026-09-14T06:21:23.824Z","description":"Wrapture's bindings, originally introduced for unit testing, turn out to double as a live tracing mechanism: the same objects that record calls onto a test...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7a1d7bde792a5a18588e34ad23d338ca?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7a1d7bde792a5a18588e34ad23d338ca?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Planet Python","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Planet Python","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/eac3cc584cb043b5a242d13752bd3d0c","url":"https://daily.dev/sources/planetpython"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/live-tracing-with-wrapture-6xkqkaede","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"python,testing,observability","timeRequired":"PT8M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Planet Python","item":"https://daily.dev/sources/planetpython"},{"@type":"ListItem","position":3,"name":"Live tracing with wrapture"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/live-tracing-with-wrapture-6xkqkaede#faq","mainEntity":[{"@type":"Question","name":"How can I trace a running Python program's method calls without adding log lines everywhere?","acceptedAnswer":{"@type":"Answer","text":"Apply wrapture bindings to the methods you care about and register a sink such as Printer instead of a test timeline; the binding emits start, return, and exception events with real arguments and timing as the program runs. Nesting is shown via indentation, returns use a -\u003e marker, and exceptions use a !! marker, all without editing the traced code's logic. Developers instrumenting live services for debugging can compare tracing approaches like this on daily.dev."}},{"@type":"Question","name":"How do I prevent sensitive arguments like card numbers from appearing in a Python trace or log?","acceptedAnswer":{"@type":"Answer","text":"Use a redact() capture policy on the binding, for example wrapture.binding(Gateway, \"charge\", capture=wrapture.redact(\"card\")), which replaces the specified argument with a placeholder like '\u003credacted\u003e' in every emitted event while leaving all other captured data unchanged. Anyone hardening logging or tracing pipelines against leaking secrets can track techniques like this on daily.dev."}},{"@type":"Question","name":"What is the performance overhead of leaving tracing bindings applied in production when nothing is listening?","acceptedAnswer":{"@type":"Answer","text":"An applied binding with no active listener constructs no event at all, so the wrapped method only pays for wrapt's own dispatch overhead, measured at about half a microsecond per call. This near-zero cost is what makes it practical to leave bindings on interesting methods permanently and let a sink decide at runtime whether anything gets recorded. Engineers weighing always-on instrumentation costs can follow performance tradeoffs like this on daily.dev."}}]}
```

