Git Product home page Git Product logo

correlation-id's Introduction

Correlation ID

Software License Scrutinizer Coverage Code Quality

An implementation of a Correlation ID and a framework agnostic PSR 15-HTTP middlware.

A Correlation ID, also known as a Transit ID, is a unique identifier value that is attached to requests and messages that allow reference to a particular transaction or event chain. The Correlation Pattern, which depends on the use of Correlation ID is a well documented Enterprise Integration Pattern.

Documentation

The Correlation ID Value Object

The correlation ID is a singleton class that will always return the same ID for the current life-cycle of the request.

Calling CorrelationID::toString() will return a string and will return the same string for the whole live cycle of the application. You can compare a string to the Correlation ID by calling CorrelationID::sameAs('your-string').

By default it uses its internal implementation to generate a UUID v4 as value of the Correlation ID. If you are using ramsey/uuid, it will use it automatically.

PSR 15 HTTP Middleware

The middleware will automatically put the correlation ID into your request object as attribute and header value. By default both use the CorrelationID name.

$middleware = new CorrelationIDMiddleware(
    CorrelationID::toString()
);

Response

Since there is no standard for where this needs to be done, just add the correlation ID to your response where it suits your architecture or framework the best.

$response->withHeader('CorrelationID', CorrelationId::toString());

For Symfony there is a bundle available that will automatically make the Correlation ID available in the request and response object.

Copyright & License

Licensed under the MIT license.

Copyright (c) Phauthentic / Florian Krämer

correlation-id's People

Contributors

burzum avatar floriankraemer avatar vanbrabantf avatar

Watchers

 avatar  avatar

Forkers

vanbrabantf

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.