Skip to content

Commit 602952f

Browse files
authored
Merge pull request #5 from cardano-foundation/anviking/cardano-tracer
Add `cardano-tracer` and `tracer-sidecar` images
2 parents 0747467 + 3970e1c commit 602952f

21 files changed

+1282
-25
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*.hs]
4+
indent_size = 4
5+
max_line_length = 80
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
indent_style = space

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
*~
33
*.swp
44
*.swo
5+
*.swl
6+
*.swm
7+
*.swn
8+
59

610
# compose
711
compose/.testnet.yaml
12+
\#*
13+
14+
# haskell
15+
dist-newstyle

compose/Makefile

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ help:
4444
@echo " make anti testnet=example_10.2.1 password='password1234'"
4545
@echo
4646

47-
build: TESTNET build-image build-config build-sidecar ## Build cardano-node, config and sidecar container image
47+
build: TESTNET build-image build-config build-sidecar build-tracer build-tracer-sidecar ## Build cardano-node, config, sidecar, and tracer images
4848

4949
build-image: TESTNET ## Build cardano-node container image
5050
ln -snf testnets/${testnet}/testnet.yaml .testnet.yaml ; cd testnets/${testnet} ; docker compose build
@@ -55,7 +55,13 @@ build-config: TESTNET ## Build config container image
5555
build-sidecar: TESTNET ## Build sidecar container image
5656
docker build -f sidecar/Dockerfile -t ${registry}${testnet}_sidecar:latest sidecar/
5757

58-
push: TESTNET push-image push-config push-sidecar ## Push cardano-node, config and sidecar container image
58+
build-tracer: TESTNET ## Build tracer container image
59+
docker build -f tracer/Dockerfile -t ${registry}${testnet}_tracer:latest tracer/
60+
61+
build-tracer-sidecar: TESTNET ## Build tracer container image
62+
docker build -f tracer-sidecar/Dockerfile -t ${registry}${testnet}_tracer-sidecar:latest tracer-sidecar/
63+
64+
push: TESTNET push-image push-config push-tracer push-sidecar push-tracer-sidecar ## Push cardano-node, config and sidecar container image
5965

6066
push-image: TESTNET ## Push cardano-node container image
6167
docker push ${registry}${testnet}:latest
@@ -66,6 +72,12 @@ push-config: TESTNET ## Push config container image
6672
push-sidecar: TESTNET ## Push sidecar container image
6773
docker push ${registry}${testnet}_sidecar:latest
6874

75+
push-tracer: TESTNET ## Push tracer container image
76+
docker push ${registry}${testnet}_tracer:latest
77+
78+
push-tracer-sidecar: TESTNET ## Push tracer container image
79+
docker push ${registry}${testnet}_tracer-sidecar:latest
80+
6981
up: TESTNET ## Start Run local Docker Compose
7082
cd testnets/${testnet} ; docker compose up --detach
7183

@@ -84,7 +96,7 @@ anti: TESTNET ## Run Antithesis job
8496
--arg description '${description}' \
8597
--arg duration '${duration}' \
8698
--arg config_image '${testnet}_config:latest' \
87-
--arg images '${testnet}:latest;${testnet}_sidecar:latest' \
99+
--arg images '${testnet}:latest;${testnet}_sidecar:latest;${testnet}_tracer:latest;${testnet}_tracer-sidecar:latest' \
88100
--arg recipients '${recipients}' \
89101
'{params: {"antithesis.description": $$description,"custom.duration": $$duration,"antithesis.config_image": $$config_image,"antithesis.images": $$images,"antithesis.report.recipients": $$recipients}}')"
90102

compose/README.md

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Docker and `make` are the only requirement to build and run your own testnets.
7575

7676
### Local
7777

78-
- Build the `cardano-node`, `config` and `sidecar` container images
78+
- Build the `cardano-node`, `cardano-tracer`, `config` and `sidecar` container images
7979

8080
```
8181
make build testnet=example_10.2.1
@@ -86,14 +86,15 @@ Docker and `make` are the only requirement to build and run your own testnets.
8686
8787
### Antithesis
8888

89-
- Build the `cardano-node`, `config` and `sidecar` container images for the Antithesis container registry
89+
- Build the `cardano-node`, `cardano-tracer`, `config` and `sidecar` container images for the Antithesis container registry
9090

9191
```
9292
make build testnet=example_10.2.1 registry=us-central1-docker.pkg.dev/molten-verve-216720/cardano-repository/
9393
```
9494

9595
> [!IMPORTANT]
9696
> Always supply the registry argument when building for Antithesis.
97+
> It's not necessary to log into the registry for building, but it is necessary for running antithesis tests.
9798
9899
## Run
99100

@@ -191,7 +192,7 @@ Docker and `make` are the only requirement to build and run your own testnets.
191192
cat credentials.json | docker login -u _json_key https://us-central1-docker.pkg.dev --password-stdin
192193
```
193194

194-
- Push the `cardano-node`, `config` and `sidecar` container images
195+
- Push the `cardano-node`, `cardano-tracer`, `config` and `sidecar` container images
195196

196197
```
197198
make push testnet=example_10.2.1 registry=us-central1-docker.pkg.dev/molten-verve-216720/cardano-repository/
@@ -230,6 +231,67 @@ Docker and `make` are the only requirement to build and run your own testnets.
230231
> [!TIP]
231232
> The commands above assume a testnet of 3 pools, increase the `{1..3}` if needed.
232233
234+
### Logging & Metrics
235+
236+
The `tracer` container which runs alongside the Cardano cluster aggregates logs and metrics for each of the running nodes. The details of the configuration are out of scope for this document, please checkout the [cardano-tracer](https://github.com/IntersectMBO/cardano-node/tree/master/cardano-tracer) and [new tracing system](https://developers.cardano.org/docs/get-started/cardano-node/new-tracing-system/new-tracing-system) documentation. The default example configuration aggregates some interesting logs and expose Prometheus metrics on port 4000.
237+
238+
- Query prometheus metrics (each node has its own path for metrics):
239+
240+
```bash
241+
curl -s http://localhost:4000/p1example-3001 | grep block
242+
```
243+
244+
```
245+
# TYPE cardano_node_metrics_served_block_latest_int gauge
246+
cardano_node_metrics_served_block_latest_int 4
247+
# TYPE cardano_node_metrics_blockfetchclient_blocksize_int gauge
248+
cardano_node_metrics_blockfetchclient_blocksize_int 862
249+
# TYPE cardano_node_metrics_blocksForged_int gauge
250+
cardano_node_metrics_blocksForged_int 2
251+
cardano_node_metrics_blockfetchclient_blockdelay_real 4.574799e-3
252+
# TYPE cardano_node_metrics_blockNum_int gauge
253+
cardano_node_metrics_blockNum_int 4
254+
# TYPE cardano_node_metrics_served_block_counter counter
255+
cardano_node_metrics_served_block_counter 4
256+
```
257+
258+
- List available logs (logs from each node are dumped into a file on a shared volume, the name of the file contains timestamp):
259+
260+
```bash
261+
docker exec -ti tracer ls -l /opt/cardano-tracer
262+
```
263+
264+
```
265+
drwxr-xr-x 2 cardano cardano 4096 Apr 13 07:42 p1.example_3001
266+
drwxr-xr-x 2 cardano cardano 4096 Apr 13 07:42 p2.example_3001
267+
drwxr-xr-x 2 cardano cardano 4096 Apr 13 07:42 p3.example_3001
268+
srwxr-xr-x 1 cardano cardano 0 Apr 13 07:42 tracer.socket
269+
```
270+
271+
```bash
272+
for i in {1..3}; do docker exec -ti tracer ls -l /opt/cardano-tracer/p${i}.example_3001/ ; done
273+
```
274+
275+
```
276+
total 404
277+
-rw-r--r-- 1 cardano cardano 411911 Apr 13 07:49 node-2025-04-13T07-42-11.json
278+
total 376
279+
-rw-r--r-- 1 cardano cardano 379328 Apr 13 07:49 node-2025-04-13T07-42-11.json
280+
total 380
281+
-rw-r--r-- 1 cardano cardano 384804 Apr 13 07:49 node-2025-04-13T07-42-10.json
282+
```
283+
284+
- Follow logs from a specific node:
285+
286+
```
287+
$ docker exec -ti tracer tail -f /opt/cardano-tracer/p2.example_3001/node-2025-04-13T07-42-11.json
288+
{"at":"2025-04-13T07:47:57.001449232Z","ns":["Forge","Loop","NodeNotLeader"],"data":{"kind":"TraceNodeNotLeader","slot":417},"sev":"Info","thread":"41","host":"p2.example"}
289+
{"at":"2025-04-13T07:47:58.001200722Z","ns":["Forge","Loop","StartLeadershipCheckPlus"],"data":{"chainDensity":3.7974683544303798610197731022708467207849025726318359375e-2,"delegMapSize":3,"kind":"TraceStartLeadershipCheck","slot":418,"utxoSize":3},"sev":"Info","thread":"41","host":"p2.example"}
290+
{"at":"2025-04-13T07:47:58.001427133Z","ns":["Forge","StateInfo","StateInfo"],"data":{"credentials":"Cardano","endPeriod":0,"evolution":62,"kind":"KESInfo","startPeriod":0},"sev":"Info","thread":"41","host":"p2.example"}
291+
{"at":"2025-04-13T07:47:58.001722819Z","ns":["Forge","Loop","NodeNotLeader"],"data":{"kind":"TraceNodeNotLeader","slot":418},"sev":"Info","thread":"41","host":"p2.example"}
292+
...
293+
```
294+
233295
## Appendix
234296

235297
- [Antithesis Documentation](https://antithesis.com/docs/)

compose/cardano-node.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ assemble_command() {
167167
cmd+=(run)
168168
cmd+=(--database-path ${DATABASE_PATH})
169169
cmd+=(--socket-path ${SOCKET_PATH})
170+
cmd+=(--tracer-socket-path-connect /opt/cardano-tracer/tracer.socket)
170171

171172
# TYPE
172173
if [ "${TYPE,,}" = "bp" ]; then
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Description
2+
3+
Example 3 pool testnet with pre-compiled cardano-node version 10.2.1.
4+
5+
## Cardano-Node
6+
7+
- **Version**: 10.2.1
8+
- **Branch**: -
9+
- **Source/Compiled**: Compiled
10+
11+
## Testnet
12+
13+
- **Pools**: 3
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
3+
x-base: &base
4+
image: ${registry}${testnet}:latest
5+
restart: on-failure
6+
build:
7+
context: "../../"
8+
dockerfile: "Dockerfile.compiled"
9+
args:
10+
CARDANO_NODE_VERSION: "10.2.1"
11+
12+
x-env: &env
13+
POOL_ID: "0" # Placeholder required for override
14+
15+
services:
16+
tracer:
17+
image: ${registry}${testnet}_tracer:latest
18+
restart: on-failure
19+
hostname: tracer.example
20+
container_name: tracer
21+
volumes:
22+
- tracer:/opt/cardano-tracer
23+
ports:
24+
- "4000:4000"
25+
command:
26+
- "--config"
27+
- "tracer-config.yaml"
28+
build:
29+
context: "../../tracer"
30+
dockerfile: "Dockerfile"
31+
32+
p1:
33+
<<: *base
34+
container_name: p1
35+
hostname: p1.example
36+
volumes:
37+
- p1:/opt/cardano-node/data
38+
- tracer:/opt/cardano-tracer
39+
ports:
40+
- "3001:3001"
41+
environment:
42+
<<: *env
43+
POOL_ID: "1"
44+
45+
p2:
46+
<<: *base
47+
container_name: p2
48+
hostname: p2.example
49+
volumes:
50+
- p2:/opt/cardano-node/data
51+
- tracer:/opt/cardano-tracer
52+
ports:
53+
- "3002:3001"
54+
environment:
55+
<<: *env
56+
POOL_ID: "2"
57+
PEER_SHARING: "false"
58+
59+
p3:
60+
<<: *base
61+
container_name: p3
62+
hostname: p3.example
63+
volumes:
64+
- p3:/opt/cardano-node/data
65+
- tracer:/opt/cardano-tracer
66+
ports:
67+
- "3003:3001"
68+
environment:
69+
<<: *env
70+
POOL_ID: "3"
71+
72+
s1:
73+
image: ${registry}${testnet}_sidecar:latest
74+
restart: on-failure
75+
container_name: s1
76+
hostname: s1.example
77+
environment:
78+
POOLS: "3"
79+
tracer-sidecar:
80+
image: ${registry}${testnet}_tracer-sidecar:latest
81+
restart: on-failure
82+
container_name: tracer-sidecar
83+
hostname: tracer-sidecar.example
84+
environment:
85+
POOLS: "3"
86+
volumes:
87+
- tracer:/opt/cardano-tracer
88+
89+
volumes:
90+
tracer:
91+
p1:
92+
p2:
93+
p3:

0 commit comments

Comments
 (0)