Crates.io | correlationvector-rust |
lib.rs | correlationvector-rust |
version | 0.2.0 |
source | src |
created_at | 2024-11-13 09:32:09.491062 |
updated_at | 2024-11-13 09:32:09.491062 |
description | A rust implementation of the Correlation Vector |
homepage | |
repository | https://github.com/TransientError/CorrelationVector-rust |
max_upload_size | |
id | 1446263 |
size | 17,424 |
CorrelationVector-Rust provides the Rust implementation of the CorrelationVector protocol for tracing and correlation of events through a distributed system.
Correlation Vector (a.k.a. cV) is a format and protocol standard for tracing and correlation of events through a distributed system based on a light weight vector clock. The standard is widely used internally at Microsoft for first party applications and services and supported across multiple logging libraries and platforms (Services, Clients - Native, Managed, Js, iOS, Android etc). The standard powers a variety of different data processing needs ranging from distributed tracing & debugging to system and business intelligence, in various business organizations.
For more on the correlation vector specification and the scenarios it supports, please refer to the specification repo.
Generates a new correlation vector.
CorrelationVector::new();
This adds a new counter in the vector clock.
let mut cv = CorrelationVector::new();
cv.extend();
This increments the latest counter in the vector clock.
let mut cv = CorrelationVector::new();
cv.increment();
This is the most complex function of the CorrelationVector. Spin changes the correlation vector such that the result should be unique and monotonically increasing without locking/atomic operations. It is used when the parent span is not able to atomically increment the vector clock for each child span.
let mut cv = CorrelationVector::new();
cv.spin();
The CorrelationVector contains a base-64 encoded uuid and a vector clock. The uuid is used to identify the vector clock and the vector clock is used to track the sequence of events.
sequenceDiagram
participant A as Service A
participant B as Service B
participant C as Service C
A -> A: A generates a correlation vector seed e.g. c3xEQzjqRlmr7zcQx9sBiQ.0
A ->> B: A sends the message to B
B -> B: B extends the correlation vector seed with a new event e.g. c3xEQzjqRlmr7zcQx9sBiQ.0.1
B ->> C: B sends first message to C
B -> B: B increments the cV when calling C again e.g. c3xEQzjqRlmr7zcQx9sBiQ.0.2
B ->> C: B sends second message to C
This allows us to track the sequence of events in a complex distributed system.
I work for Microsoft and use CorrelationVectors but am not associated with the CorrelationVector team. This repo should not be considered a reference implementation of the CorrelationVector specification.