Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

bad-logic/distributed-tracing

Open more actions menu

Repository files navigation

DISTRIBUTED TRACING

In distributed systems, a single operation may traverse across multiple software components. each software components may produce traces/logs that are uniquely identifiable across the participating systems. so it is very difficult to correlate those traces/logs.

In order to correlate those traces/logs, they must share a context that tells them that they are part of a specific transaction/operation.

Trace context is something that can be passed along with the request, that tells the participating system that it is a part of a specific operation.

Trace context is split into two individual propagation fields supporting interoperability and vendor-specific extensibility:

traceparent header : represents the incoming request in a tracing system in a common format, understood by all vendors.

Format: {version}-{trace_id}-{parent_id}-{trace_flags}

version => 2 HEXDIGLC (Hexadecimal digits lowercase)

The current specification assumes the version is set to 00. Version ff is forbidden

trace_id => 32 HEXDIGLC (16 bytes array identifier. All zeroes forbidden)

All traces belonging to the same transaction will have same trace_id. it is a unique identifier across the distributed system.

how to generate trace_id ?

parent_id => 16 HEXDIGLC (8 bytes array identifier. All zeroes forbidden)

It is the id of the caller. In some tracing system it may also be known as the span_id.

trace_flags => 2 HEXDIGLC (8 bit flags.)

The current version of this specification (00) only supports a single flag called sampled.

static final byte FLAG_SAMPLED = 1; // 00000001
boolean sampled = (traceFlags & FLAG_SAMPLED) == FLAG_SAMPLED;

Ex:

00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01
base16(version) = 00
base16(trace-id) = 4bf92f3577b34da6a3ce929d0e0e4736
base16(parent-id) = 00f067aa0ba902b7
base16(trace-flags) = 01  // sampled
00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-00
base16(version) = 00
base16(trace-id) = 4bf92f3577b34da6a3ce929d0e0e4736
base16(parent-id) = 00f067aa0ba902b7
base16(trace-flags) = 00  // not sampled

tracestate header (optional): includes the parent in a potentially vendor-specific format

Read more...

How to run application !!!

First run kafka

docker-compose -f deploy/kafka-compose.yaml up -d

Run logging containers

docker-compose -f deploy/logs-compose.yaml up -d

Run application containers

docker-compose -f deploy/docker-compose.yaml up

OR

Run with script

$ chmod +x run.sh
$ ./run.sh

Running Migrations

$ chmod +x migrations.sh
$ ./migrations.sh run

Running Applications
product microservice localhost:8082/product
order microservice localhost:8083/order/
kafka ui localhost:8080
Zipkin localhost:9411
Jaeger localhost:16686
consumer node
consumer cpp

Morty Proxy This is a proxified and sanitized view of the page, visit original site.