# Using capture\_span with TRANSACTIONS\_IGNORE\_PATTERNS

**URL:** <https://discuss.elastic.co/t/using-capture-span-with-transactions-ignore-patterns/145992>\
**Category:** APM\
**Created:** [August 24, 2018, 11:25pm UTC](https://discuss.elastic.co/t/using-capture-span-with-transactions-ignore-patterns/145992 "2018-08-24T23:25:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![scuerda](https://avatars.discourse-cdn.com/v4/letter/s/74df32/32.png) [@scuerda](https://discuss.elastic.co/u/scuerda)\
**Post date:** [August 24, 2018, 11:25pm UTC](https://discuss.elastic.co/t/using-capture-span-with-transactions-ignore-patterns/145992/1 "2018-08-24T23:25:24Z")

</div>

I am working on setting up APM for a Django Rest API. We would like to use feature flags and query params to explore and toggle transaction capturing while at the same time excluding the bulk of our views from capture via the `TRANSACTIONS_IGNORE_PATTERNS` setting. Is this possible?

I set up a generic decorator that I am using to wrap DRF view methods and then calling using the capture\_space context manager but it looks like the `TransactionStore._should_ignore` method is still returning `True` resulting in the capture being filtered out. Is there a way to override that behavior? I suppose I could see if could have the custom decorator rename the wrapped function on the fly in a way the causes the ignored\_transaction\_pattern matching to overlook the function, but that seems rather messy?

---

<div class="post-metadata">

**Author:** ![beniwohli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/beniwohli/32/21256_2.png) [@beniwohli](https://discuss.elastic.co/u/beniwohli)\
**Post date:** [August 27, 2018, 9:46am UTC](https://discuss.elastic.co/t/using-capture-span-with-transactions-ignore-patterns/145992/2 "2018-08-27T09:46:41Z")

</div>

Hi Sasha

that's an interesting use case, but I'm afraid we don't have direct support for it. It seems like the idea you bring up with a decorator could work, but instead of renaming the view function, you could set the transaction name yourself, using [`elasticapm.set_transaction_name()`](https://www.elastic.co/guide/en/apm/agent/python/master/api.html#api-set-transaction-name). I don't think that would be too messy 🙂

---

<div class="post-metadata">

**Author:** ![scuerda](https://avatars.discourse-cdn.com/v4/letter/s/74df32/32.png) [@scuerda](https://discuss.elastic.co/u/scuerda)\
**Post date:** [August 27, 2018, 11:43am UTC](https://discuss.elastic.co/t/using-capture-span-with-transactions-ignore-patterns/145992/3 "2018-08-27T11:43:53Z")

</div>

Ah, perfect! That worked exactly as expected. It does feel a bit awkward to call, but only because it seems to assume the presence of a local transaction and in the context of a class-based view you just have to know that the transaction starts at at the start of the request-cycle. That said, I think that I can abstract that awkwardness away in our local implementation. Thanks for the quick reply.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 17, 2018, 7:43am UTC](https://discuss.elastic.co/t/using-capture-span-with-transactions-ignore-patterns/145992/4 "2018-09-17T07:43:55Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
