# Elastic APM Custom Transactions using Python

**URL:** https://discuss.elastic.co/t/elastic-apm-custom-transactions-using-python/260262
**Category:** APM
**Tags:** python
**Created:** [January 5, 2021, 10:47pm UTC](https://discuss.elastic.co/t/elastic-apm-custom-transactions-using-python/260262 "2021-01-05T22:47:27Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jquintero](https://avatars.discourse-cdn.com/v4/letter/j/ba9def/32.png) [@jquintero](https://discuss.elastic.co/u/jquintero)
#### Post date: [January 5, 2021, 10:47pm UTC](https://discuss.elastic.co/t/elastic-apm-custom-transactions-using-python/260262/1 "2021-01-05T22:47:27Z")

</div>

I have not been able to find any documentation for custom transactions in Python. For those of you who were able to find success could you document how this is done in Python?

---

<div class="post-metadata">

### Author: ![basepi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/basepi/32/53056_2.png) [@basepi](https://discuss.elastic.co/u/basepi)
#### Post date: [January 6, 2021, 3:56pm UTC](https://discuss.elastic.co/t/elastic-apm-custom-transactions-using-python/260262/2 "2021-01-06T15:56:48Z")

</div>

Hey @jquintero! You can find documentation on creating your own transactions [here](https://www.elastic.co/guide/en/apm/agent/python/current/instrumenting-custom-code.html#instrumenting-custom-code-transactions).

Hope that helps!

---

<div class="post-metadata">

### Author: ![jquintero](https://avatars.discourse-cdn.com/v4/letter/j/ba9def/32.png) [@jquintero](https://discuss.elastic.co/u/jquintero)
#### Post date: [January 7, 2021, 8:33pm UTC](https://discuss.elastic.co/t/elastic-apm-custom-transactions-using-python/260262/3 "2021-01-07T20:33:25Z")

</div>

Thank you for the info, it was very informative. However, I am unsure if that use case applies. In that case it combines two spans into one transaction, I am trying to create a custom transaction to measure AWS requests and uploads that are not being captured by Elastic APM currently. Furthermore, if I create a new custom transaction will I need an instance of APM or can I set it statically like "set\_user\_context"?

Also, I am curious what the use case is for "set\_transaction\_name" or "set\_transaction\_result"?

---

<div class="post-metadata">

### Author: ![basepi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/basepi/32/53056_2.png) [@basepi](https://discuss.elastic.co/u/basepi)
#### Post date: [January 11, 2021, 10:11pm UTC](https://discuss.elastic.co/t/elastic-apm-custom-transactions-using-python/260262/4 "2021-01-11T22:11:56Z")

</div>

To clarify, you have AWS requests/uploads that are happening outside of your web app that you would like to capture as transactions? If you control the code on those requests, you should be able to create transactions using the pattern in the documentation I linked.

Otherwise, you might need to give me more details because I'm not sure I follow your use case.

`set_transaction_name` and `set_transaction_result` are used to set the transaction name and result. 🙂 You can also set the name and result using `client.end_transaction`, but usually you don't actually call that method, it's called for you (if you're using a supported framework). `set_transaction_name` and `set_transaction_result` are convenience methods that find the current transaction and set those fields for you so you don't have to keep track of the current transaction.

---

<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: [February 1, 2021, 6:11pm UTC](https://discuss.elastic.co/t/elastic-apm-custom-transactions-using-python/260262/5 "2021-02-01T18:11:58Z")

</div>

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