m6web/xrequestuid-bundle

This package is abandoned and no longer maintained. No replacement package was suggested.
There is no license information available for the latest version (v3.0.1) of this package.

bundle sf2 allowing setting ids in headers propagated via guzzle

Installs: 90 903

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 35

Forks: 2

Open Issues: 0

Type:symfony-bundle

v3.0.1 2020-01-30 16:06 UTC

This package is auto-updated.

Last update: 2022-03-01 00:13:12 UTC


README

For implementation into a Symfony 3 or Symfony 4 application, please use the release v3.0.0 at least.

Why ?

"The cool thing in microservices is that you can generate 15 http calls in your infrastructure just with on client http call"

This situation leads to many difficulties to trace calls betweens APIs systems, especially when an internal call fails. This bundle provide a solution to generate ids for new requests and configure your guzzle services accordingly to uses those ids in sub http requests made by them.

The bundle will generate and/or forward those two headers : X-Request-Uid and X-Request-Parent-Uid.

How ?

When a request arrive, if a X-Request-Id exists, it is copied into the X-Request-Parent-Id. If it's dont exist we generate it throught the uniqId_service.

All your guzzle services are decorated with a proxy who will add the two headers in all the call made.

At the end both headers are added to the response for debugging purpose.

You can now add thoses two headers in your logs file and follow the calls.

Configuration

m6_web_x_request_uid:
    request_uid_header_name: X-Request-toto    # optionnal, X-Request-Uid by default
    request_parent_uid_header_name: X-Parent   # optionnal, X-Request-Parent-Uid by default 
    uniqId_service: myservice                  # optionnal, a service implementing UniqIdInterface 
    services:                                  # list of guzzle services to decorate 
        - test.guzzle1

services:
    test.guzzle1:
        class: 'GuzzleHttp\Client'

If you have other bundles creating guzzle services, be sure to add the bundle after them in your AppKernel file.

You can define you own uniqId service or juste use the one provided in the bundle (wich do a basic php uniqid).

Related

Todo

  • add more tests
  • add more docs