Semantic Web and Web 3.0 · class 07 · demo

Three signals, one request

The system of the class — gateway, orders, catalogue and payments — running inside this server. Send an order and follow it through the three signals: the trace says where the time went, the log lines say what happened, the metrics say how often and how fast for every request at once. The correlation id is what lets the three meet.

1. Send a request

The slide

An order of three keyboards (product 17). Payments waits 410 ms for the card provider.

Payments fixed

The same order, with the card provider answering in 41 ms — «Try this» 1 of example 04.

A failure

Three wireless mice (product 23), out of stock. Which service said no, and how long does it take you to find it?

2. The average hides the tail

The catalogue, GET /products/{id}, over the last 1 000 requests →

79.4 ms
average
26 ms
95th percentile
3.85 s
99th percentile

3. The raw signals

/metricsthe counter and the histogram per route, in the Prometheus text format — what the collector exposes in the challenge
/logsevery log line kept, one JSON object per line; ?correlation=, ?service=, ?level= filter it
/healthfor the server that publishes this page

Latest traces

Time (UTC)TraceCorrelationStatusTotalWhere the time went
13:16:2739040ca8b55b53c8… c-f8b1201469 ms payments, 87%

How it is built

SignalHereFrom the class
Logginglog/slog in JSON, fixed messages, values in fields, log.Filter for the card numberexamples/01-structured-logging
CorrelationX-Correlation, generated at the gateway, propagated by the HTTP client's transportexamples/02-correlation
Metricsa counter and a histogram per route pattern, never per pathexamples/03-metrics
Tracingtraceparent in and out, one span per service, written by handexamples/04-tracing

Time is simulated — nothing sleeps — so a thousand requests take milliseconds. Kept in memory: the last 50 traces (now 1), the last 2 000 log lines (now 19), the last 10 000 durations of each of the 5 series.