Skip to content

Commit bb94af6

Browse files
committed
console-api,console-subscriber,tokio-console: implement stack traces for tasks
The task detail view of console now shows the tree of extant consequences stemming from that task; i.e., which spans are open beneath the task. The leaves of the task, in a sense, reflect what the task is busy doing at that moment.
1 parent d08391c commit bb94af6

22 files changed

+742
-78
lines changed

Cargo.lock

Lines changed: 119 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

console-api/proto/common.proto

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ message Span {
7878
repeated Field fields = 3;
7979
// Timestamp for the span.
8080
google.protobuf.Timestamp at = 4;
81+
// An Id that uniquely identifies this span's parent (if any).
82+
optional SpanId parent_id = 5;
8183
}
8284

8385
// Any new metadata that was registered since the last update.
@@ -197,4 +199,4 @@ message Attribute {
197199
// Some values carry a unit of measurement. For example, a duration
198200
// carries an associated unit of time, such as "ms" for milliseconds.
199201
optional string unit = 2;
200-
}
202+
}

console-api/proto/consequences.proto

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
syntax = "proto3";
2+
3+
package rs.tokio.console.consequences;
4+
5+
import "common.proto";
6+
7+
message Causality {
8+
oneof update {
9+
Extant extant = 1;
10+
OpenDirect open_direct = 2;
11+
NewIndirect new_indirect = 3;
12+
CloseDirect close_direct = 4;
13+
CloseIndirect close_indirect = 5;
14+
CloseCyclic close_cyclic = 6;
15+
}
16+
}
17+
18+
message Span {
19+
common.SpanId span_id = 1;
20+
common.MetaId metadata_id = 2;
21+
}
22+
23+
message Extant {
24+
Span cause = 1;
25+
repeated Span direct_consequences = 2;
26+
repeated Span indirect_consequences = 3;
27+
}
28+
29+
message OpenDirect {
30+
Span cause = 1;
31+
Span direct_consequences = 2;
32+
}
33+
34+
message NewIndirect {
35+
Span cause = 1;
36+
Span indirect_consequences = 3;
37+
}
38+
39+
message CloseDirect {
40+
Span span = 1;
41+
optional Span direct_cause = 2;
42+
}
43+
44+
message CloseIndirect {
45+
Span span = 1;
46+
repeated Span indirect_causes = 3;
47+
}
48+
49+
message CloseCyclic {
50+
Span span = 1;
51+
optional Span direct_cause = 2;
52+
repeated Span indirect_causes = 3;
53+
}

console-api/proto/tasks.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package rs.tokio.console.tasks;
44

55
import "google/protobuf/timestamp.proto";
66
import "google/protobuf/duration.proto";
7+
import "consequences.proto";
78
import "common.proto";
89

910
// A task state update.
@@ -49,6 +50,9 @@ message TaskDetails {
4950

5051
// HdrHistogram.rs `Histogram` serialized to binary in the V2 format
5152
optional bytes poll_times_histogram = 3;
53+
54+
// What the task is currently busy doing.
55+
repeated consequences.Causality causality = 4;
5256
}
5357

5458
// Data recorded when a new task is spawned.

console-api/src/consequences.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include!("generated/rs.tokio.console.consequences.rs");

console-api/src/generated/rs.tokio.console.common.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ pub struct Span {
106106
/// Timestamp for the span.
107107
#[prost(message, optional, tag="4")]
108108
pub at: ::core::option::Option<::prost_types::Timestamp>,
109+
/// An Id that uniquely identifies this span's parent (if any).
110+
#[prost(message, optional, tag="5")]
111+
pub parent_id: ::core::option::Option<SpanId>,
109112
}
110113
/// Any new metadata that was registered since the last update.
111114
#[derive(Clone, PartialEq, ::prost::Message)]

0 commit comments

Comments
 (0)