Skip to content

Commit

Permalink
console-api,console-subscriber,tokio-console: implement stack traces …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
jswrenn committed Jul 21, 2022
1 parent d08391c commit bb94af6
Show file tree
Hide file tree
Showing 22 changed files with 742 additions and 78 deletions.
144 changes: 119 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion console-api/proto/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ message Span {
repeated Field fields = 3;
// Timestamp for the span.
google.protobuf.Timestamp at = 4;
// An Id that uniquely identifies this span's parent (if any).
optional SpanId parent_id = 5;
}

// Any new metadata that was registered since the last update.
Expand Down Expand Up @@ -197,4 +199,4 @@ message Attribute {
// Some values carry a unit of measurement. For example, a duration
// carries an associated unit of time, such as "ms" for milliseconds.
optional string unit = 2;
}
}
53 changes: 53 additions & 0 deletions console-api/proto/consequences.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
syntax = "proto3";

package rs.tokio.console.consequences;

import "common.proto";

message Causality {
oneof update {
Extant extant = 1;
OpenDirect open_direct = 2;
NewIndirect new_indirect = 3;
CloseDirect close_direct = 4;
CloseIndirect close_indirect = 5;
CloseCyclic close_cyclic = 6;
}
}

message Span {
common.SpanId span_id = 1;
common.MetaId metadata_id = 2;
}

message Extant {
Span cause = 1;
repeated Span direct_consequences = 2;
repeated Span indirect_consequences = 3;
}

message OpenDirect {
Span cause = 1;
Span direct_consequences = 2;
}

message NewIndirect {
Span cause = 1;
Span indirect_consequences = 3;
}

message CloseDirect {
Span span = 1;
optional Span direct_cause = 2;
}

message CloseIndirect {
Span span = 1;
repeated Span indirect_causes = 3;
}

message CloseCyclic {
Span span = 1;
optional Span direct_cause = 2;
repeated Span indirect_causes = 3;
}
4 changes: 4 additions & 0 deletions console-api/proto/tasks.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package rs.tokio.console.tasks;

import "google/protobuf/timestamp.proto";
import "google/protobuf/duration.proto";
import "consequences.proto";
import "common.proto";

// A task state update.
Expand Down Expand Up @@ -49,6 +50,9 @@ message TaskDetails {

// HdrHistogram.rs `Histogram` serialized to binary in the V2 format
optional bytes poll_times_histogram = 3;

// What the task is currently busy doing.
repeated consequences.Causality causality = 4;
}

// Data recorded when a new task is spawned.
Expand Down
1 change: 1 addition & 0 deletions console-api/src/consequences.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include!("generated/rs.tokio.console.consequences.rs");
3 changes: 3 additions & 0 deletions console-api/src/generated/rs.tokio.console.common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ pub struct Span {
/// Timestamp for the span.
#[prost(message, optional, tag="4")]
pub at: ::core::option::Option<::prost_types::Timestamp>,
/// An Id that uniquely identifies this span's parent (if any).
#[prost(message, optional, tag="5")]
pub parent_id: ::core::option::Option<SpanId>,
}
/// Any new metadata that was registered since the last update.
#[derive(Clone, PartialEq, ::prost::Message)]
Expand Down

0 comments on commit bb94af6

Please sign in to comment.