|
1 | 1 | // SPDX-License-Identifier: MIT
|
2 | 2 | // SPDX-FileCopyrightText: Copyright (c) 2020 Thoren Paulson
|
3 |
| -//! This file is taken unmodified from the following link, except for file attributes and |
4 |
| -//! `extern crate` at the top. |
| 3 | +//! This file was initially taken from the following link, the changes that were made to the |
| 4 | +//! original file can be found in git history (`git log -- path/to/tracing_chrome.rs`): |
5 | 5 | //! https://github.com/thoren-d/tracing-chrome/blob/7e2625ab4aeeef2f0ef9bde9d6258dd181c04472/src/lib.rs
|
6 | 6 | //! Depending on the tracing-chrome crate from crates.io is unfortunately not possible, since it
|
7 | 7 | //! depends on `tracing_core` which conflicts with rustc_private's `tracing_core` (meaning it would
|
@@ -497,31 +497,36 @@ where
|
497 | 497 | }
|
498 | 498 | }
|
499 | 499 |
|
500 |
| - fn get_root_id(span: SpanRef<S>) -> u64 { |
501 |
| - span.scope() |
502 |
| - .from_root() |
503 |
| - .take(1) |
504 |
| - .next() |
505 |
| - .unwrap_or(span) |
506 |
| - .id() |
507 |
| - .into_u64() |
| 500 | + fn get_root_id(&self, span: SpanRef<S>) -> Option<u64> { |
| 501 | + match self.trace_style { |
| 502 | + TraceStyle::Async => Some( |
| 503 | + span.scope() |
| 504 | + .from_root() |
| 505 | + .take(1) |
| 506 | + .next() |
| 507 | + .unwrap_or(span) |
| 508 | + .id() |
| 509 | + .into_u64() |
| 510 | + ), |
| 511 | + _ => if span.metadata().name() == "frame" { |
| 512 | + // "frame" spans indicate stack frames in the interpreted program: |
| 513 | + // let's make them appear on a separate trace line than other spans. |
| 514 | + Some(1) |
| 515 | + } else { |
| 516 | + None |
| 517 | + }, |
| 518 | + } |
508 | 519 | }
|
509 | 520 |
|
510 | 521 | fn enter_span(&self, span: SpanRef<S>, ts: f64) {
|
511 | 522 | let callsite = self.get_callsite(EventOrSpan::Span(&span));
|
512 |
| - let root_id = match self.trace_style { |
513 |
| - TraceStyle::Async => Some(ChromeLayer::get_root_id(span)), |
514 |
| - _ => None, |
515 |
| - }; |
| 523 | + let root_id = self.get_root_id(span); |
516 | 524 | self.send_message(Message::Enter(ts, callsite, root_id));
|
517 | 525 | }
|
518 | 526 |
|
519 | 527 | fn exit_span(&self, span: SpanRef<S>, ts: f64) {
|
520 | 528 | let callsite = self.get_callsite(EventOrSpan::Span(&span));
|
521 |
| - let root_id = match self.trace_style { |
522 |
| - TraceStyle::Async => Some(ChromeLayer::get_root_id(span)), |
523 |
| - _ => None, |
524 |
| - }; |
| 529 | + let root_id = self.get_root_id(span); |
525 | 530 | self.send_message(Message::Exit(ts, callsite, root_id));
|
526 | 531 | }
|
527 | 532 |
|
|
0 commit comments