# How services see each other: a service map built from test traffic

> An architecture diagram shows what the team believes. A service map drawn from the traces your tests cause shows which services actually called which, how much of each one's code ran, and where a request's chain stopped. Here is how CoverOps builds it and how to read it after the first run.

Published 2026-11-18 · Updated 2026-11-18 · Melih Sakarya
Canonical: https://coverops.ai/blog/service-map-from-test-traffic

Short answer: the most honest picture of a distributed system is the one its own requests draw. When every service runs a CoverOps agent with tracing on, each request a test sends leaves a chain of hops behind it: gateway, then orders, then pricing, then the inventory consumer that handled the resulting Kafka event. CoverOps sums those hops into a service map. Each edge is a call that really happened, each node carries the line coverage of the code that ran in it, and a service that should be connected but is not shows up as a missing edge. That makes the map the first thing to read after a functional test run, before you trust any per-test number.

## Why draw the map from traffic

Most teams have a diagram of their services. It was right when someone drew it. Since then a call was added in a hurry, a consumer was moved to another service, and a client was swapped for one that does not forward headers. None of that changes the diagram.

A map built from traces cannot drift that way, because it is not a description of the system. It is a sum of what requests did. In a test environment, those requests are your functional tests, so the map answers a second question at the same time: which parts of the system does the suite actually exercise, and which ones does it only reach by accident or not at all?

## How a request becomes edges

Inside one service, the first instrumented method a request reaches opens its chain; for a Spring MVC service that is the controller method. When the service calls another one, the agent writes the chain onward in the X-CoverageOps-Trace header, next to the three test headers, so the next agent continues the same chain instead of starting a new one. Each service the request crosses is a hop, and two consecutive hops in different services are an edge on the map.

POST /orders                        (test: checkout::buys a desk)
  gateway     OrderController.create
  orders      OrderService.place       ← X-CoverageOps-Trace, X-CoverageOps-Test
  pricing     PriceService.quote
  inventory   ReservationListener.on   ← Kafka record headers

On the JVM this needs no code for the usual clients: the JDK's HTTP clients, Apache HttpClient 4 and 5, OkHttp, and on the messaging side the Kafka producer and consumer, Spring Kafka listeners, RabbitMQ publish and Spring AMQP listeners. A consumed message is adopted like an inbound request, so the consumer appears on the map as the next hop after the producer. Node.js forwards on http, https and fetch by itself, Go with one line on its HTTP client, and Python, .NET and PHP with the agent's outbound-headers helper. Message hops outside the JVM are carried by hand. The Kafka and message queue posts in this series go through those cases.

Sampling does not hide edges. An agent can record the methods of only one request in N, but a request that was not sampled still appears as a hop, marked sampled: false. The edge is counted; only the method detail is missing.

## What the map shows

The map lives under Analyse → Code graph, on the Services tab, over a window of 7, 30 or 90 days. Traffic and hops are summed from daily roll-ups, so a 90-day window is as complete as a 7-day one.

- Modes. Colour the nodes by coverage (red at 0%, amber at 50%, green at 100%), by traffic, or by p95 latency.

- Layout. The cards view puts callers above callees by call depth. Arrow thickness is call volume. Services with no recorded hop sit below a dashed line labelled "No recorded hops".

- Summary. Nodes, edges, weighted coverage across every drawn service, and the frames and runs the window holds.

- Node detail. For the selected service: coverage, calls, p95, fan-in and fan-out, a criticality score, the five hottest methods and the eight busiest hops in and out with their average time. Criticality is up to 60 points for traffic relative to the busiest service plus 8 points per hop, capped at 40, so a quiet service that many others depend on still ranks.

Coverage per service is the line coverage of the files its traced methods live in, from the newest coverage of each file in the window. It is the number a team can act on: this is how much of the code we know is in the request path actually ran.

## Code against traces

When the project has a code map, the Services tab lays the static structure over the traced one in a panel called Code against traces:

- In code, never traced: references from one service's files into another's that no trace followed. These are integrations the code allows and no test exercised.

- Traced, no code reference: hops that happen over the network, with no reference in the code that would reveal them. These are the calls a reader of one repository cannot see.

The first list is a test gap you can name. The second is the part of the architecture that only exists at runtime, which is exactly what a hand-drawn diagram misses.

## Reading the map after the first run

Run the functional suite once with every service on its agent and tracing on, then open the map and go through it in this order:

- Is every service there? A service the suite should reach but that is not on the map has no agent, or its agent reports under another name. Two applications reporting the same service name merge into one node, so names matter.

- Is anything below the dashed line? A service with no recorded hop received traffic but is connected to nothing. If you expected it to be called by another service, the hop in between did not carry the context.

- Is an edge missing? Orders publishes to Kafka, but there is no edge to inventory: the consumer did not adopt the message's context, or the message was handled by a client the agent does not follow. Per-test attribution stops at that hop, so fix it before reading per-test coverage.

- Which nodes are red? A busy service with low coverage is where the suite passes through without testing much.

- What is in "In code, never traced"? Each entry is a candidate for a new functional test.

A missing edge is the cheapest finding of the whole exercise: it costs one look at the map and saves you from trusting per-test numbers that silently stop at a broken hop.

## Watching it fill in

You do not have to wait for the run to end. While a run is collecting, its page streams each hop as agents report it, labelled with the service and its methods. Watching the feed during the first run tells you within minutes whether the hops you expect are arriving; the real-time coverage post covers that screen.

## The same map for an assistant

The map is also an MCP tool, service_map. At service level it returns the services, the hops between them, and coverage, traffic and p95 per node, plus the code overlay: what each service is made of, the links that exist in code but were never traced, and the traced hops with no code reference. At method level it returns the network between methods instead, which the screen does not draw. A coding assistant can ask it which services a change sits between before it writes a test.

## Limits

- The map has only what agents saw. Databases, brokers and third-party APIs are not nodes; a service without an agent is not on it.

- Timers and background jobs that no request or carried message started are not traced.

- A hop that does not carry the context breaks the chain there. The map shows the break; it does not repair it.

- The screen draws services only. Method-level detail is in the Code tab and in the MCP tool.

- The map sums all traced traffic in the project's monitored services, not only test traffic. In a shared staging environment, other traffic draws edges too.

The series starts with functional test coverage in distributed systems. Once the map is complete, per-test coverage across microservices shows what each test did along those edges. The code graph guide describes every panel, and the integration test coverage page has the product summary.
