/plushcap/analysis/bandwidth/bandwidth-a-recipe-for-adding-correlation-ids-in-java-microservices

A recipe for adding correlation IDs in Java Microservices

What's this blog post about?

Microservices are gaining popularity in software development due to their numerous advantages for medium or large systems. One challenge with microservices is tracking requests across logs from different services contributing to a single business transaction. A correlation ID can be used as a common reference token passed along in chained calls to each service. To keep the IDs out of service URLs and method signatures, it's recommended to use an HTTP header like "X-Correlation-ID". Using Java servlet filters and logback's MDC capability can help implement this approach easily. When generating a correlation ID, consider using a random Long instead of a GUID or a simple integer to avoid hash collisions. Base 62 encoding can be used to shorten the length of the ID while maintaining its uniqueness.

Company
Bandwidth

Date published
March 29, 2016

Author(s)
Larry Reeder

Word count
1015

Hacker News points
None found.

Language
English


By Matt Makai. 2021-2024.