-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose active traces through telemetry server #87
Conversation
2b1290a
to
2e03391
Compare
Tracks currently-active spans in a low-overhead manner (relative to the general overhead of tracing, at least). This is particularly useful because even unsampled traces are available to be viewed here. The model for this functionality is https://pkg.go.dev/golang.org/x/net/trace although there is no built-in viewer here, we expect you to use Chrome's about:tracing or anything that supports the same JSON log format.
2e03391
to
10fec1b
Compare
is_sampled, | ||
} | ||
} | ||
} | ||
|
||
impl SharedSpan { | ||
pub(crate) fn into_span(self) -> Arc<parking_lot::RwLock<Span>> { | ||
Arc::clone(&self.inner) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Since you consume
self
, you shouldn't need to clone - Doesn't this return an
Arc<LiveReferenceHandle<...>>
iftelemetry-server
is enabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I attempted to reconcile this magical behaviour by defining a newtype struct in a new commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that definitely helps make clear what happens here.
escape(name), | ||
escape(category), | ||
match event_type { | ||
TraceEventType::Begin => "B", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async events (those with id
) apparently use lowercase "b" and "e" for ph
: https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/edit?tab=t.0#heading=h.jh64i9l3vwa1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Despite the name, async events don't have the right semantics for what we want to express here. Regular events are enough for the visualisation.
timestamp_us: u64, | ||
) { | ||
self.out.push_str(&format!( | ||
"{{\"pid\":1,\"name\":\"{}\",\"cat\":\"{}\",\"ph\":\"{}\",\"ts\":{},\"id\":\"{}\"}},", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to also emit the trace tags as args
, but I understand if you don't have time to implement this right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tags are typed, so we'd need to generate JSON objects with serde or something rather than this quick and dirty approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, let's leave that for a future iteration
Using a different named type for SharedSpanInner depending on features causes unclear behaviour due to auto-deref. Instead, define a newtype with common methods in both feature variants.
Nice! |
Required for InspectableSpan trait.
1e16b5a
to
0a60af5
Compare
Tracks currently-active spans in a low-overhead manner (relative to the general overhead of tracing, at least). This is particularly useful because even unsampled traces are available to be viewed here.
The model for this functionality is https://pkg.go.dev/golang.org/x/net/trace although there is no built-in viewer here, we expect you to use Chrome's about:tracing or anything that supports the same JSON log format.
This requires more functionality in our rustracing fork so we can get data set on the spans: cloudflare/rustracing#4