Fundamental support for the Laravel framework

September 23, 2020

Fundamental support for the Laravel framework

Laravel is one of the most beloved web framework for PHP. It was developed as an alternative to CodeIgniter and today is the most popular PHP project on GitHub based on the amount of stars it has received.

With the PHP tracing extension v1.8.0, Instana introduced full-featured support for the Laravel framework.

A distributed tracing centric view of Laravel Monitoring

Laravel is an MVC framework built around the concepts of controllers, actions, and routes. As a developer, your mental model of how requests are served is expressed in terms of controllers and actions, and which of these are involved largely depends on routes. Because of this, these concepts should be treated as first-class citizens in Instana and you should be able to use your knowledge of your codebase to navigate Instana’s views and drill down into the data it offers you.

Additionally, a large amount of Laravel’s doing in serving your web pages is rendering Blade templates. Understanding how many templates are rendered and which are slow is often key in troubleshooting sluggish performance of your Laravel applications.

What Laravel looks like in Instana

Short answer: it looks good! With Instana’s Unbounded Analytics functionality, it is straightforward to find all the important data about how your Laravel instances are servicing requests. For example, you can easily find every single call of interest to you (because Instana has all of them, no sampling!) segmenting calls by Laravel-specific tags:

Word Image 250

Segmenting calls by Laravel specific tags (Available with our upcoming SaaS release 184)

From there, one click brings you to detailed insights into how your application has served particular requests:

Word Image 251

Single View of the execution of a Laravel HTTP Controller

Routes

The support for Laravel extends to both detecting and categorizing calls by controller and by route. For example, a Laravel application will define HTTP routes like the following:

    Route::get(‘news/{category}/articles/{year}-{month}-{day}-{title}’, ‘[email protected]’);

Previously, in Instana these urls were mapped to separate endpoints such as:

    http://my-host.io/news/bogus-things/articles/2020-08-01-why-does-it-always-have-to-rain
    and
    http://my-host.io/news/australia/articles/1998-04-01-wild-roo-punches-man

Having requests to the same route spread across potentially very many endpoints made it harder to troubleshoot issues. It also made it harder to understand which Laravel controller is acting up or even involved in serving requests. So it could happen that wrongly mapped routes would go unnoticed, and the billing endpoint charges your customers unnoticed.

But those days are over: now, with the Laravel support in Instana, when you declare a route containing placeholders, we will group it by the path containing placeholders. For example, with the following route declared:

    Route::get("news/{category}/articles/{year}-{month}-{day}-{title}", "[email protected]")->name("news.show");

… in Instana it looks like this:

Word Image 252

See exactly which of those input parameters will make your application logic fail.

Blade

Blade is the canonical view engine for Laravel based applications.

In addition to Laravel support, the PHP extension version 1.8.0, traces the execution of Blade templates.

By tracing Blade templates, Instana allows you, out of the box, to track where your application spends its time when it should be spent on rendering a defined set of data.

For example, is there a relation loaded lazily that could have been loaded eagerly when interacting with your Eloquent model in the first place?

Word Image 253

The view is loading the “categories” relation lazily, a 100 times – easy find, fetch the relevant fields eagerly instead.

Or maybe the issue is that your templates invoke over and over the same database query? Easy as pie!

Word Image 254

With this level of insight, by applying some eager-loading when building out your application, we are able to immediately improve on the database calls:

Word Image 255

Happy tracing Laravel and Blade, folks!

Bonus: End User Monitoring

Ever wondered what trouble specific users had? Failed to reproduce a bug that your users reported? Since Instana does capture and store every single call to your application, it’s easy to spot erroneous calls – and when you add our end-user monitoring (EUM) JavaScript agent to your application default layout, you’ll be able get a comprehensive overview of all the calls involved in one pageview and even the option to inspect all the async calls to your endpoints to have a better understanding of the context.
To be able so segment your data by user, you can use the JavaScript Agent API (https://www.instana.com/docs/website_monitoring/api#identifying-users):

    <!-- after including the EUM script -->
    <script>
    @if(Auth::user() !== null)
    
    ineum('user', '{{ Auth::user()->id }}');
    
    @endif
    </script>

Play with Instana’s APM Observability Sandbox

Announcement, Conceptual, Developer, Engineering, Product
According to AWS: “[Graviton2 is] custom built by Amazon Web Services using 64-bit Arm Neoverse cores to deliver the best price performance for your cloud workloads running in Amazon EC2” At Instana...
|
Announcement, Developer, Product, Thought Leadership
Instana has previously announced automated tracing of AWS Lambda applications in Node.js and Python. We are extending our best-in-class distributed tracing to include AWS Lambda functions written in Java and Go. The...
|
Announcement, Developer, Product, Thought Leadership
To be successful in Observability, you must have the ability to observe the behavior of a system and derive its health state from it. But deriving the health state of any given...
|

Start your FREE TRIAL today!

Instana, an IBM company, provides an Enterprise Observability Platform with automated application monitoring capabilities to businesses operating complex, modern, cloud-native applications no matter where they reside – on-premises or in public and private clouds, including mobile devices or IBM Z.

Control hybrid modern applications with Instana’s AI-powered discovery of deep contextual dependencies inside hybrid applications. Instana also gives visibility into development pipelines to help enable closed-loop DevOps automation.

This provides actionable feedback needed for clients as they to optimize application performance, enable innovation and mitigate risk, helping Dev+Ops add value and efficiency to software delivery pipelines while meeting their service and business level objectives.

For further information, please visit instana.com.