# Http transaction is success although error

**URL:** <https://discuss.elastic.co/t/http-transaction-is-success-although-error/327075>\
**Category:** APM\
**Tags:** python\
**Created:** [March 6, 2023, 12:38pm UTC](https://discuss.elastic.co/t/http-transaction-is-success-although-error/327075 "2023-03-06T12:38:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![avlachopoulos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/avlachopoulos/32/118085_2.png) [@avlachopoulos](https://discuss.elastic.co/u/avlachopoulos)\
**Post date:** [March 6, 2023, 12:38pm UTC](https://discuss.elastic.co/t/http-transaction-is-success-although-error/327075/1 "2023-03-06T12:38:30Z")

</div>

I have a simple web transaction using fast api to test APM. The code is the following:

```auto
app.get("/critical", status_code=500)
def critcal_failure():
    try:
        print("Doing something critical")
        raise Exception("something went wrong")
    except Exception as e:
        apm_client.capture_exception(exc_info=True)
        raise HTTPException(status_code=500, detail=f"{e}")

```

I would expect this to have the "events.outcome" field set to failure. Instead I see it to be "success". Am I missing something?  
ELK stack version is 7.17.9

---

<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:** [March 7, 2023, 12:28pm UTC](https://discuss.elastic.co/t/http-transaction-is-success-although-error/327075/2 "2023-03-07T12:28:11Z")

</div>

Hi @avlachopoulos

I copied your example code verbatim (except for adding the missing `@` in front of `app`), and `outcome` is set to `failure` as expected.

Could you share the output of `pip freeze`? Maybe it's a version problem.

Also, note that your handling of the exception and calling `capture_exception` isn't necessary, the agent should capture unhandled exceptions automatically.

---

<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:** [March 28, 2023, 8:28am UTC](https://discuss.elastic.co/t/http-transaction-is-success-although-error/327075/3 "2023-03-28T08:28:54Z")

</div>

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