# APM + Flask + Multiprocessing = No Spans

**URL:** <https://discuss.elastic.co/t/apm-flask-multiprocessing-no-spans/161879>\
**Category:** APM\
**Created:** [December 21, 2018, 4:51pm UTC](https://discuss.elastic.co/t/apm-flask-multiprocessing-no-spans/161879 "2018-12-21T16:51:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nagellack](https://avatars.discourse-cdn.com/v4/letter/n/3e96dc/32.png) [@nagellack](https://discuss.elastic.co/u/nagellack)\
**Post date:** [December 21, 2018, 4:51pm UTC](https://discuss.elastic.co/t/apm-flask-multiprocessing-no-spans/161879/1 "2018-12-21T16:51:19Z")

</div>

I am trying to capture some spans in my Python Flask app using the decorator:  
`@elasticapm.capture_span()`

This works perfectly, until I execute a couple of functions in parallel using python's multiprocessing module. These spans are then never captured (the spans set in the main process are still captured). Within these functions, I am also not able to send an error or message (`apm.capture_message()`).

I use `multiprocessing.Process` and `multiprocessing.Pipe` to parallelize the execution of a list of functions.

I would love for each of these functions to be captured as individual spans within the request transaction.

Does anyone have experience with capturing parallel spans using Flask and Elastic APM?

---

<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:** [January 2, 2019, 8:35am UTC](https://discuss.elastic.co/t/apm-flask-multiprocessing-no-spans/161879/2 "2019-01-02T08:35:41Z")

</div>

Hi @nagellack

unfortunately, this is not something we currently support. The information about ongoing transactions/spans is stored in a thread local (on Python 3.7 it's in a `contextvar` variable, but that amounts to to more or less the same thing in this case).

I will look into ways to achieve this, but it's a non-trivial problem and I can't say when we might support this use case.

---

<div class="post-metadata">

**Author:** ![nagellack](https://avatars.discourse-cdn.com/v4/letter/n/3e96dc/32.png) [@nagellack](https://discuss.elastic.co/u/nagellack)\
**Post date:** [January 9, 2019, 8:03pm UTC](https://discuss.elastic.co/t/apm-flask-multiprocessing-no-spans/161879/3 "2019-01-09T20:03:35Z")

</div>

Hey - Thanks for the response.

I look forward to it - possibly - being supported!

---

<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:** [January 30, 2019, 4:03pm UTC](https://discuss.elastic.co/t/apm-flask-multiprocessing-no-spans/161879/4 "2019-01-30T16:03:40Z")

</div>

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