eonx-com/easy-request-id

Uniquely identify each request across multiple projects

Installs: 19 625

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 4

Forks: 0

Open Issues: 0

Type:symfony-bundle

3.4.7 2021-10-15 03:24 UTC

README

---eonx_docs--- title: Introduction weight: 0 ---eonx_docs---

Microservices infrastructures are common, one request can involve N different applications sending requests to each other, and it can be hard to link events occurring across them. This package objective is to create a standard way in PHP projects to resolve/share IDs across projects so linking requests becomes easier!

It is based on 2 different IDs:

  • request_id: ID of request specific to each project
  • correlation_id: shared ID across projects for the same initial request

On the top of resolving those IDs for you, this package also comes with bridges to different packages to automatically include those IDs in your:


Dependencies

This package has dependencies on the following packages, please see their documentation directly:


Require package (Composer)

The recommended way to install this package is to use Composer:

$ composer require eonx-com/easy-request-id

Usage

This package is based on a single service providing the requestId and correlationId anywhere you need them:

// src/Controller/MyController.php

namespace App\Controller;

use EonX\EasyRequestId\Interfaces\RequestIdServiceInterface;

final class MyController
{
    /**
     * @var \EonX\EasyRequestId\Interfaces\RequestIdServiceInterface
     */
    private $requestIdService;

    public function __construct(RequestIdServiceInterface $requestIdService)
    {
        $this->requestIdService = $requestIdService; 
    }

    public function __invoke()
    {
        $requestId = $this->requestIdService->getRequestId();
        $correlationId = $this->requestIdService->getCorrelationId();

        // Use the IDs in your logic...
    }
}