{"id":19133968,"url":"https://github.com/umbrellio/jaravel","last_synced_at":"2025-07-15T10:09:59.211Z","repository":{"id":45446762,"uuid":"371627489","full_name":"umbrellio/jaravel","owner":"umbrellio","description":"Integration Laravel application and Jaeger.","archived":false,"fork":false,"pushed_at":"2023-04-24T18:48:01.000Z","size":325,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-07-11T01:56:13.719Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/umbrellio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-28T08:07:09.000Z","updated_at":"2023-04-19T13:45:48.000Z","dependencies_parsed_at":"2024-11-09T06:25:47.229Z","dependency_job_id":"532519c2-349f-49f8-a0cc-f5b440addb95","html_url":"https://github.com/umbrellio/jaravel","commit_stats":{"total_commits":23,"total_committers":5,"mean_commits":4.6,"dds":0.3913043478260869,"last_synced_commit":"7e69c71a151b48b9d00e04e13872a1beeb454940"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/umbrellio/jaravel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umbrellio%2Fjaravel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umbrellio%2Fjaravel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umbrellio%2Fjaravel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umbrellio%2Fjaravel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/umbrellio","download_url":"https://codeload.github.com/umbrellio/jaravel/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umbrellio%2Fjaravel/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265427640,"owners_count":23763366,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T06:24:33.026Z","updated_at":"2025-07-15T10:09:59.185Z","avatar_url":"https://github.com/umbrellio.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jaravel\n\n[![Github Status](https://github.com/umbrellio/jaravel/workflows/CI/badge.svg)](https://github.com/umbrellio/jaravel/actions)\n[![Latest Stable Version](https://poser.pugx.org/umbrellio/jaravel/v)](//packagist.org/packages/umbrellio/jaravel)\n[![Coverage Status](https://coveralls.io/repos/github/umbrellio/jaravel/badge.svg?branch=master)](https://coveralls.io/github/umbrellio/jaravel?branch=master)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/umbrellio/jaravel/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/umbrellio/jaravel/?branch=master)\n\n###### Library that allows easy integrate your Laravel application with Jaeger (OpenTracing).\n## Installation\n\nInstallation can be done with composer\n```\ncomposer require umbrellio/jaravel\n```\n## Usage\nJaravel is able to trace your incoming http requests, console command, \nyour guzzle requests to other services and event your queued jobs. \n\nYou can check your configuration in jaravel.php. All configuration is described \nin comment blocks.\n\nYou can configure span name or tags for every type of span: \n```php\n// config/jaravel.php\n...\n'http' =\u003e [\n        'span_name' =\u003e fn (Request $request) =\u003e 'App: ' . $request-\u003epath(),\n        'tags' =\u003e fn (Request $request, Response $response) =\u003e [\n            'type' =\u003e 'http',\n            'request_host' =\u003e $request-\u003egetHost(),\n            'request_path' =\u003e $path = $request-\u003epath(),\n            'request_method' =\u003e $request-\u003emethod(),\n            'response_status' =\u003e $response-\u003egetStatusCode(),\n            'error' =\u003e !$response-\u003eisSuccessful() \u0026\u0026 !$response-\u003eisRedirection(),\n        ],\n...\n    'guzzle' =\u003e [\n        'span_name' =\u003e Umbrellio\\Jaravel\\Configurations\\Guzzle\\SpanNameResolver::class,\n        'tags' =\u003e Umbrellio\\Jaravel\\Configurations\\Guzzle\\TagsResolver::class,\n    ],\n...\n```\nYou can use any callable or fully qualified class name, that points to class \nhaving `__invoke` method (it will be initialized via Service Container, \nso you can inject anything that you want in constructor). It`s preferred way, if you \nare using `config:cache` Artisan command, because closures can't be serialized. \nParams passed to callable depends on what type of span (http, console, etc).\n\n### Tracing incoming http requests\n\nTo enable tracing incoming http requests, you need to add middleware `HttpTracingMiddleware` \nto specific routes or globally, for example. \n\nRequests can be filtered via 'allow_request' or 'deny_request' callables. \nIf 'allow_request' is defined, http request will be traced only if this \ncallable will return true. After 'allow_request' Jaravel checks 'deny_request' \ncallable, and doesn`t make a trace, if it returns false. If you dont want \nto filter any requests, you can skip this settings.\n\nFor example, if you want to trace only requests having '/api' in the path:\n```php\n// config/jaravel.php\n...\n'http' =\u003e [\n        'allow_request' =\u003e fn (Request $request) =\u003e str_contains($request-\u003epath(), '/api'),\n...\n```\n\nIf `'trace_id_header'` is configured, header with trace id will be added to response. \nfield.\n\n### Tracing console commands\n\nEnabled by default.\n\nIt`s able to filter commands via 'filter_commands', that will not be traced:\n```php\n// config/jaravel.php\n...\n'console' =\u003e [\n        'filter_commands' =\u003e ['schedule:run'],\n...\n```\n\n### Tracing jobs\n\nTo start tracing your jobs and even relate it with parent span, you need just \nadd `JobTracingMiddleware` to jobs:\n```php\n\u003c?php\ndeclare(strict_types=1);\n\nnamespace App\\Jobs;\n\nuse Illuminate\\Contracts\\Queue\\ShouldQueue;\nuse Illuminate\\Queue\\InteractsWithQueue;\nuse Umbrellio\\Jaravel\\Middleware\\JobTracingMiddleware;\n\nclass JaravelTestJob implements ShouldQueue\n{\n    use InteractsWithQueue;\n\n    public function handle()\n    {\n        ...\n    }\n\n    public function middleware()\n    {\n        return [new JobTracingMiddleware()];\n    }\n}\n```\n\nIt recommends to use `InteractsWithQueue` trait, because with this trait you can \nuse methods of `Job` instance while tagging span for job:\n\n```php\n// config/jaravel.php\n...\n'job' =\u003e [\n    'tags' =\u003e fn ($realJob, ?Job $job) =\u003e [\n        'type' =\u003e 'job',\n        'job_class' =\u003e get_class($realJob),\n        'job_id' =\u003e optional($job)\n            -\u003egetJobId(),\n        'job_connection_name' =\u003e optional($job)\n            -\u003egetConnectionName(),\n        'job_name' =\u003e optional($job)\n            -\u003egetName(),\n        'job_queue' =\u003e optional($job)\n            -\u003egetQueue(),\n        'job_attempts' =\u003e optional($job)\n            -\u003eattempts(),\n    ],\n],\n...\n```\n\n### Tracing outgoing http requests with Guzzle\n\nTo start tracing your Guzzle requests, you need just add middleware to your Guzzle \nclient: \n```php\nuse GuzzleHttp\\Client;\nuse GuzzleHttp\\HandlerStack;\nuse Umbrellio\\Jaravel\\HttpTracingMiddlewareFactory;\n\n$stack = HandlerStack::create();\n$stack-\u003epush(HttpTracingMiddlewareFactory::create());\n$client = new Client(['handler' =\u003e $stack]);\n```\n\n\u003e To add tracing to all your requests you can bind above client to `GuzzleHttp\\Client` in \n\u003e your Service Provider.\n\n### Making your own spans\n\nIf you need to make your own span, you can follow next example:\n\n```php\nuse App\\Services\\MyService;\nuse OpenTracing\\Tracer;\nuse Umbrellio\\Jaravel\\Services\\Span\\SpanCreator;\nuse Umbrellio\\Jaravel\\Services\\Span\\SpanTagHelper;\n\n// You should use dependency injection in your code, it`s just an example \n$spanCreator = app(SpanCreator::class);  \n$myService = app(MyService::class);\n$tracer = app(Tracer::class);\n\n// First you need to create a span. It will be a child of current active span, if active span exists\n$span = $spanCreator-\u003ecreate('Call MyService');\n\n// Do something \n$myService-\u003edoSomething();\n\n// Close active scope (span will be finished automatically) and flush tracer.\noptional($tracer-\u003egetScopeManager()-\u003egetActive())-\u003eclose();\n$tracer-\u003eflush();\n```\n\nIf you need to retrieve current trace id, you can use: \n`Umbrellio\\Jaravel\\Services\\Span\\ActiveSpanTraceIdRetriever::retrieve()`\n\n## License\n\nReleased under MIT License.\n\n## Authors\n\nCreated by Vitaliy Lazeev.\n\n## Contributing\n\n- Fork it ( https://github.com/umbrellio/jaravel )\n- Create your feature branch (`git checkout -b feature/my-new-feature`)\n- Commit your changes (`git commit -am 'Add some feature'`)\n- Push to the branch (`git push origin feature/my-new-feature`)\n- Create new Pull Request\n\n\u003ca href=\"https://github.com/umbrellio/\"\u003e\n\u003cimg style=\"float: left;\" src=\"https://umbrellio.github.io/Umbrellio/supported_by_umbrellio.svg\" alt=\"Supported by Umbrellio\" width=\"439\" height=\"72\"\u003e\n\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumbrellio%2Fjaravel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fumbrellio%2Fjaravel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumbrellio%2Fjaravel/lists"}