# PHP - Missing trace when utilising createErrorFromThrowable

**URL:** <https://discuss.elastic.co/t/php-missing-trace-when-utilising-createerrorfromthrowable/378678>\
**Category:** Elastic Observability\
**Created:** [May 29, 2025, 4:42am UTC](https://discuss.elastic.co/t/php-missing-trace-when-utilising-createerrorfromthrowable/378678 "2025-05-29T04:42:24Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![oliverkuchies](https://avatars.discourse-cdn.com/v4/letter/o/e68b1a/32.png) [@oliverkuchies](https://discuss.elastic.co/u/oliverkuchies)\
**Post date:** [May 29, 2025, 4:42am UTC](https://discuss.elastic.co/t/php-missing-trace-when-utilising-createerrorfromthrowable/378678/1 "2025-05-29T04:42:24Z")

</div>

Hi there,  
It seems when utilising `createErrorFromThrowable` the exception itself is being registered in ElasticAPM which is great.  
However, its missing the stack trace.  
I can see that other transactions have a trace sample attached (which means the Agent is registered correctly), but when it comes to capturing errors it is missing.

Any idea how i can enhance my observability to support the stack trace when capturing errors manually?

We are using the debian agent.

---

<div class="post-metadata">

**Author:** ![oliverkuchies](https://avatars.discourse-cdn.com/v4/letter/o/e68b1a/32.png) [@oliverkuchies](https://discuss.elastic.co/u/oliverkuchies)\
**Post date:** [August 11, 2025, 7:09am UTC](https://discuss.elastic.co/t/php-missing-trace-when-utilising-createerrorfromthrowable/378678/2 "2025-08-11T07:09:43Z")

</div>

Bumping for visibility

---

<div class="post-metadata">

**Author:** ![Rafa\_Silva](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rafa_silva/32/147814_2.png) [@Rafa\_Silva](https://discuss.elastic.co/u/Rafa_Silva)\
**Post date:** [August 12, 2025, 2:11pm UTC](https://discuss.elastic.co/t/php-missing-trace-when-utilising-createerrorfromthrowable/378678/3 "2025-08-12T14:11:15Z")

</div>

> [@oliverkuchies](#):
>
> Hi there,  
> It seems when utilising `createErrorFromThrowable` the exception itself is being registered in ElasticAPM which is great.  
> However, its missing the stack trace.  
> I can see that other transactions have a trace sample attached (which means the Agent is registered correctly), but when it comes to capturing errors it is missing.
> 
> Any idea how i can enhance my observability to support the stack trace when capturing errors manually?
> 
> We are using the debian agent.

Try using `Elastic\Apm\ElasticApm::captureThrowable($e)` instead of `createErrorFromThrowable($e)`, and set `elastic_apm.stack_trace_limit = -1` in your agent config. Restart PHP after the change and check if the stack trace appears in the error document.

---

<div class="post-metadata">

**Author:** ![oliverkuchies](https://avatars.discourse-cdn.com/v4/letter/o/e68b1a/32.png) [@oliverkuchies](https://discuss.elastic.co/u/oliverkuchies)\
**Post date:** [September 1, 2025, 11:19pm UTC](https://discuss.elastic.co/t/php-missing-trace-when-utilising-createerrorfromthrowable/378678/4 "2025-09-01T23:19:23Z")

</div>

Hi Rafa, this method does not exist.

> **[Build software better, together](https://github.com/search?q=repo%3Aelastic%2Fapm-agent-php%20captureThrowable&type=code)**
>
> GitHub is where people build software. More than 150 million people use GitHub to discover, fork, and contribute to over 420 million projects.

---

<div class="post-metadata">

**Author:** ![Rafa\_Silva](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rafa_silva/32/147814_2.png) [@Rafa\_Silva](https://discuss.elastic.co/u/Rafa_Silva)\
**Post date:** [September 2, 2025, 5:14pm UTC](https://discuss.elastic.co/t/php-missing-trace-when-utilising-createerrorfromthrowable/378678/5 "2025-09-02T17:14:27Z")

</div>

Got it in that case you can stick with createErrorFromThrowable($e) but make sure you send it with ElasticApm::captureError() or attach it to a transaction/span.

Also check your config:

> elastic\_apm.stack\_trace\_limit = -1

Without that, the agent won’t include the stack trace even if the error is captured.

What’s your PHP agent version? Some older builds didn’t include full stack traces with createErrorFromThrowable.

---

<div class="post-metadata">

**Author:** ![oliverkuchies](https://avatars.discourse-cdn.com/v4/letter/o/e68b1a/32.png) [@oliverkuchies](https://discuss.elastic.co/u/oliverkuchies)\
**Post date:** [September 4, 2025, 1:08am UTC](https://discuss.elastic.co/t/php-missing-trace-when-utilising-createerrorfromthrowable/378678/6 "2025-09-04T01:08:10Z")

</div>

Hi Rafa and other readers.

I’ve did additional debugging, i pulled the source of the PHP lib on my machine and integrated it into our app.

It appears the Stack trace is making its way through the entire library, all the way to the event sink, and to the elastic\_apm\_send\_to\_server method.

Debug data:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/4/c49a0f0d848e4a84091f0d6841f1d2956143069f.png)

Something is going wrong, either in the C extension or on a UI level.

The config above appears to be respected by the PHP extension, but it appears that the issue is occurring on the C agent level.

Thanks

---

<div class="post-metadata">

**Author:** ![oliverkuchies](https://avatars.discourse-cdn.com/v4/letter/o/e68b1a/32.png) [@oliverkuchies](https://discuss.elastic.co/u/oliverkuchies)\
**Post date:** [September 4, 2025, 1:09am UTC](https://discuss.elastic.co/t/php-missing-trace-when-utilising-createerrorfromthrowable/378678/7 "2025-09-04T01:09:04Z")

</div>

Here’s a sample visualisation of the issue i’m having

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/9/7/978116e9dddb22612956ef6e2b4cf1a7358fdd5e.png)

Note: we are using [https://github.com/elastic/apm-agent-php/releases/download/v1.15.0/apm-agent-php\_1.15.0\_amd64.deb](https://github.com/elastic/apm-agent-php/releases/download/v1.15.0/apm-agent-php_1.15.0_amd64.deb)

---

<div class="post-metadata">

**Author:** ![oliverkuchies](https://avatars.discourse-cdn.com/v4/letter/o/e68b1a/32.png) [@oliverkuchies](https://discuss.elastic.co/u/oliverkuchies)\
**Post date:** [September 4, 2025, 1:31am UTC](https://discuss.elastic.co/t/php-missing-trace-when-utilising-createerrorfromthrowable/378678/8 "2025-09-04T01:31:08Z")

</div>

> [@oliverkuchies](#):
>
> elastic\_apm\_send\_to\_server

Here’s another example.

The culprit, error id etc is coming through, but not displaying.

Note how **Culprit at the top box is N/A.**

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/5/0521e8a66be08236ed0045edfc5587cf6ee587b4.png)

---

<div class="post-metadata">

**Author:** ![Rafa\_Silva](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rafa_silva/32/147814_2.png) [@Rafa\_Silva](https://discuss.elastic.co/u/Rafa_Silva)\
**Post date:** [September 13, 2025, 12:50am UTC](https://discuss.elastic.co/t/php-missing-trace-when-utilising-createerrorfromthrowable/378678/9 "2025-09-13T00:50:20Z")

</div>

Hi Oliver, thanks for digging deeper and sharing the debug details.

If the stack trace is visible all the way to elastic\_apm\_send\_to\_server but disappears in Kibana, that strongly suggests it’s being dropped either by the C extension or on the UI side. Since you’re already on 1.15.0, I’d recommend:

Double-check elastic\_apm.stack\_trace\_limit is not set to 0.

Try upgrading to the latest release (\>= 1.15.1) there have been fixes around error payload serialization.

If it still happens, it might be worth opening a GitHub issue with the debug output, as this looks like an agent bug rather than configuration

Have you tried reproducing with a minimal script that just throws an exception and calls createErrorFromThrowable? That could help isolate if it’s something in the integration layer vs. the core agent.
