Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APM] Improved PHP stack trace formatting #80949

Closed
SergeyKleyman opened this issue Oct 18, 2020 · 2 comments · Fixed by #149122
Closed

[APM] Improved PHP stack trace formatting #80949

SergeyKleyman opened this issue Oct 18, 2020 · 2 comments · Fixed by #149122
Assignees
Labels
apm:errors-page apm:test-plan-done Pull request that was successfully tested during the test plan good first issue low hanging fruit Team:APM All issues that need APM UI Team support

Comments

@SergeyKleyman
Copy link
Contributor

SergeyKleyman commented Oct 18, 2020

The way to format stack trace that is idiomatic to PHP (for example it's the way stack trace is formatted by PHP's debug_print_backtrace()):

#<index> <function> called at [<filename>:<lineno>]

and for exceptions (for example it's the way stack trace is formatted by PHP's Throwable::getTraceAsString()):

#<index> <filename>(<lineno>): <function>

An example of stack trace for a method:



#0    MyNamespace\ClassWithStaticMethod::MyNamespace\{closure}() called at [C:\Elastic\Dev\PHP_Agent\MiSC\samples\stack_trace_for_method.php:41]


#1    MyNamespace\ClassWithStaticMethod::myStaticMethod() called at [C:\Elastic\Dev\PHP_Agent\MiSC\samples\stack_trace_for_method.php:49]


#2    MyNamespace\ClassWithInstanceMethod->myInstanceMethod() called at [C:\Elastic\Dev\PHP_Agent\MiSC\samples\stack_trace_for_method.php:58]


#3    MyNamespace\ClassWithClosureInConstructor->MyNamespace\{closure}() called at [C:\Elastic\Dev\PHP_Agent\MiSC\samples\stack_trace_for_method.php:61]


#4    MyNamespace\ClassWithClosureInConstructor->__construct() called at [C:\Elastic\Dev\PHP_Agent\MiSC\samples\stack_trace_for_method.php:67]
elastic/kibana#5   MyNamespace\myFreeStandingFunc() called at [C:\Elastic\Dev\PHP_Agent\MiSC\samples\stack_trace_for_method.php:70]

An example of stack trace for an exception:

MyNamespace\MyException: My exception message (arg1: 1, arg2: my arg2) in /mnt/hgfs/Elastic_Dev/PHP_Agent/MiSC/samples/formatted_stack_trace.php:19
Stack trace:


#0   /mnt/hgfs/Elastic_Dev/PHP_Agent/MiSC/samples/formatted_stack_trace.php(27): MyNamespace\MyClassA::methodA()
elastic/kibana#1  /mnt/hgfs/Elastic_Dev/PHP_Agent/MiSC/samples/formatted_stack_trace.php(36): MyNamespace\MyClassB->methodB()
elastic/kibana#2  /mnt/hgfs/Elastic_Dev/PHP_Agent/MiSC/samples/formatted_stack_trace.php(53): MyNamespace\MyClassC->methodC()
elastic/kibana#3  /mnt/hgfs/Elastic_Dev/PHP_Agent/MiSC/samples/formatted_stack_trace.php(56): MyNamespace\myFreeStandingFunc()
elastic/kibana#4  {main}

References

@SergeyKleyman SergeyKleyman transferred this issue from elastic/apm-agent-php Oct 19, 2020
@SergeyKleyman SergeyKleyman added the Team:APM All issues that need APM UI Team support label Oct 19, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:apm)

@sorenlouv sorenlouv changed the title Kibana's APM UI should format stack trace from PHP Agent in the way idiomatic to PHP [APM] Improved PHP stack trace formatting Nov 17, 2020
@sorenlouv sorenlouv added v7.13.0 and removed v7.12.0 labels Jan 13, 2021
@sorenlouv sorenlouv added v7.15.0 and removed v7.13.0 labels May 25, 2021
@sorenlouv sorenlouv removed the v7.16.0 label Oct 26, 2021
@sorenlouv
Copy link
Member

For the next person who picks this up: The various language-specific renderers are defined here:

switch (codeLanguage?.toString().toLowerCase()) {
case 'c#':
Renderer = CSharpFrameHeadingRenderer;
break;
case 'java':
Renderer = JavaFrameHeadingRenderer;
break;
case 'javascript':
Renderer = JavaScriptFrameHeadingRenderer;
break;
case 'ruby':
Renderer = RubyFrameHeadingRenderer;
break;
default:
Renderer = DefaultFrameHeadingRenderer;
break;
}

achyutjhunjhunwala added a commit that referenced this issue Jan 25, 2023
Closes #80949

## Summary

This PR adds support for displaying Language specific Stacktrace for
PHP.

## PHP

**Before changes -**

<img width="1681" alt="image"
src="https://user-images.githubusercontent.com/7416358/213389631-f8dd808d-3a38-4663-b2dc-c777d87795a6.png">

**After changes the Stackttrace will look like this**

<img width="1681" alt="image"
src="https://user-images.githubusercontent.com/7416358/213192049-e4bc56b0-49ba-40a3-85c1-218be917ba71.png">
@achyutjhunjhunwala achyutjhunjhunwala added the apm:test-plan-done Pull request that was successfully tested during the test plan label Feb 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apm:errors-page apm:test-plan-done Pull request that was successfully tested during the test plan good first issue low hanging fruit Team:APM All issues that need APM UI Team support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants