Skip to content

Commit cb91ed4

Browse files
authored
fix: trace incoming packet responses (#623)
* fix: trace incoming packet responses * fix(node): remove extra in_current_span call * docs(logging): add info about logging
1 parent 14ad532 commit cb91ed4

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

crates/ilp-node/src/instrumentation/trace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub async fn trace_incoming<A: Account>(
3838
);
3939
let _details_scope = details_span.enter();
4040

41-
next.handle_request(request).in_current_span().await
41+
trace_response(next.handle_request(request).in_current_span().await)
4242
}
4343

4444
/// Add tracing context when the incoming request is

crates/ilp-node/src/node.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,7 @@ impl InterledgerNode {
391391
if #[cfg(feature = "monitoring")] {
392392
let outgoing_service_fwd = outgoing_service
393393
.clone()
394-
.wrap(trace_forwarding)
395-
.in_current_span();
394+
.wrap(trace_forwarding);
396395
} else {
397396
let outgoing_service_fwd = outgoing_service.clone();
398397
}

docs/logging.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Logging
2+
3+
Logs are created via the `tracing` crates. We define various _scopes_ depending on the operation we want to trace at various debug levels. The log level can be set via the `RUST_LOG` environment variable, and via the `/tracing-level` at runtime by the node operator.
4+
5+
For each request we track various information depending on the error log lvel:
6+
- **Incoming**:
7+
- `ERROR`:
8+
- `request.id`: a randomly generated uuid for that specific request
9+
- `prepare.destination`: the destination of the prepare packet inside the request
10+
- `prepare.amount`: the amount in the prepare packet inside the request
11+
- `from.id`: the request sender's account uuid
12+
- `DEBUG`:
13+
- `from.username`: the request sender's username
14+
- `from.ilp_address`: the request sender's ilp address
15+
- `from.asset_code`: the request sender's asset code
16+
- `from.asset_scale`: the request sender's asset scale
17+
- **Forwarding** (this is shown when an incoming request is turned into an outgoing request and is being forwarded to a peer):
18+
- `ERROR`:
19+
- `prepare.amount`: the amount in the prepare packet inside the request
20+
- `from.id`: the request sender's account uuid
21+
- `DEBUG`:
22+
- `to.username`: the request receiver's username
23+
- `to.ilp_address`: the request receiver's ilp address
24+
- `to.asset_code`: the request receiver's asset code
25+
- `to.asset_scale`: the request receiver's asset scale
26+
- **Outgoing**:
27+
- `ERROR`:
28+
- `request.id`: a randomly generated uuid for that specific request
29+
- `prepare.destination`: the destination of the prepare packet inside the request
30+
- `from.id`: the request sender's account uuid
31+
- `to.id`: the request receiver's account uuid
32+
- `DEBUG`:
33+
- `from.username`: the request sender's username
34+
- `from.ilp_address`: the request sender's ilp address
35+
- `from.asset_code`: the request sender's asset code
36+
- `from.asset_scale`: the request sender's asset scale
37+
- `to.username`: the request receiver's username
38+
- `to.ilp_address`: the request receiver's ilp address
39+
- `to.asset_code`: the request receiver's asset code
40+
- `to.asset_scale`: the request receiver's asset scale
41+
42+
Then, depending on the response received for the request, we add additional information to that log:
43+
- `Fulfill`: We add a scope `"result = fulfill"` at the `DEBUG` level
44+
- `fulfillment`: the fulfill packet's fulfillment condition
45+
- `Reject`: We add a scope `"result = "reject"` at the INFO level
46+
- `reject.code`: the reject packet's error code field
47+
- `reject.message`: the reject packet's message field
48+
- `reject.triggered_by`: the reject packet's triggered_by field

0 commit comments

Comments
 (0)