PHPackages                             umbrellio/jaravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. umbrellio/jaravel

ActiveLibrary[API Development](/categories/api)

umbrellio/jaravel
=================

Library for integration Laravel and Jaeger.

3.0.2(3y ago)825.4k1MITPHPPHP ^7.4|^8.0

Since May 28Pushed 3y ago4 watchersCompare

[ Source](https://github.com/umbrellio/jaravel)[ Packagist](https://packagist.org/packages/umbrellio/jaravel)[ RSS](/packages/umbrellio-jaravel/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (8)Versions (20)Used By (0)

Jaravel
=======

[](#jaravel)

[![Github Status](https://github.com/umbrellio/jaravel/workflows/CI/badge.svg)](https://github.com/umbrellio/jaravel/actions)[![Latest Stable Version](https://camo.githubusercontent.com/dc2af42a363bf841ad0bc86a1da0557d9acf5296df6cb3fcf3e7e5f14208b763/68747470733a2f2f706f7365722e707567782e6f72672f756d6272656c6c696f2f6a61726176656c2f76)](//packagist.org/packages/umbrellio/jaravel)[![Coverage Status](https://camo.githubusercontent.com/6252373676c42c7a09dd3db8ad83ac8a115c213f713beece3e0da6154101088a/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f756d6272656c6c696f2f6a61726176656c2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/umbrellio/jaravel?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/2dbbcdd3a52e3253dede7c735a99ed8f8e58aeb20ad3a50ea649a6eb3755e524/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f756d6272656c6c696f2f6a61726176656c2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/umbrellio/jaravel/?branch=master)

###### Library that allows easy integrate your Laravel application with Jaeger (OpenTracing).

[](#library-that-allows-easy-integrate-your-laravel-application-with-jaeger-opentracing)

Installation
------------

[](#installation)

Installation can be done with composer

```
composer require umbrellio/jaravel

```

Usage
-----

[](#usage)

Jaravel is able to trace your incoming http requests, console command, your guzzle requests to other services and event your queued jobs.

You can check your configuration in jaravel.php. All configuration is described in comment blocks.

You can configure span name or tags for every type of span:

```
// config/jaravel.php
...
'http' => [
        'span_name' => fn (Request $request) => 'App: ' . $request->path(),
        'tags' => fn (Request $request, Response $response) => [
            'type' => 'http',
            'request_host' => $request->getHost(),
            'request_path' => $path = $request->path(),
            'request_method' => $request->method(),
            'response_status' => $response->getStatusCode(),
            'error' => !$response->isSuccessful() && !$response->isRedirection(),
        ],
...
    'guzzle' => [
        'span_name' => Umbrellio\Jaravel\Configurations\Guzzle\SpanNameResolver::class,
        'tags' => Umbrellio\Jaravel\Configurations\Guzzle\TagsResolver::class,
    ],
...
```

You can use any callable or fully qualified class name, that points to class having `__invoke` method (it will be initialized via Service Container, so you can inject anything that you want in constructor). It`s preferred way, if you  are using `config:cache` Artisan command, because closures can't be serialized. Params passed to callable depends on what type of span (http, console, etc).

### Tracing incoming http requests

[](#tracing-incoming-http-requests)

To enable tracing incoming http requests, you need to add middleware `HttpTracingMiddleware`to specific routes or globally, for example.

Requests can be filtered via 'allow\_request' or 'deny\_request' callables. If 'allow\_request' is defined, http request will be traced only if this callable will return true. After 'allow\_request' Jaravel checks 'deny\_request' callable, and doesn`t make a trace, if it returns false. If you dont want to filter any requests, you can skip this settings.

For example, if you want to trace only requests having '/api' in the path:

```
// config/jaravel.php
...
'http' => [
        'allow_request' => fn (Request $request) => str_contains($request->path(), '/api'),
...
```

If `'trace_id_header'` is configured, header with trace id will be added to response. field.

### Tracing console commands

[](#tracing-console-commands)

Enabled by default.

It`s able to filter commands via 'filter\_commands', that will not be traced:

```
// config/jaravel.php
...
'console' => [
        'filter_commands' => ['schedule:run'],
...
```

### Tracing jobs

[](#tracing-jobs)

To start tracing your jobs and even relate it with parent span, you need just add `JobTracingMiddleware` to jobs:

```
