Commit Graph

25 Commits

Author SHA1 Message Date
Durham Goode
5d66631598 tracing: fix recording on spans via TracingCollector layer
Summary:
EspanId and tracing::span::Id had From/Into implementations that allowed them to be treated as
equivalent when they shouldn't be. This allowed for a subtle but where TracingData::record was
receiving an EspanId where the id was some huge u64 from a tracing::span::Id, when instead that
huge u64 should've been mapped to the real EspanId via the id_map.

Ideally we'd treat EspanId and the tracing Id separately, but the TracingCollector Subscriber
implementation relies on this. Since it controls span creation it can guarantee that all Id's are safely
convertible to EspanId.

Reviewed By: quark-zju

Differential Revision: D29599901

fbshipit-source-id: 79d24d41d86c6098888b1747cc0b9bc2838493fa
2021-07-15 21:19:27 -07:00
Davide Cavalca
b82c5672fc Update several rust crate versions
Summary: Update versions for several of the crates we depend on.

Reviewed By: danobi

Differential Revision: D29165283

fbshipit-source-id: baaa9fa106b7dad000f93d2eefa95867ac46e5a1
2021-06-17 16:38:19 -07:00
Andres Suarez
6ccdc46775 third-party: update tracing-subscriber from 0.2.15 to 0.2.17
Reviewed By: dtolnay

Differential Revision: D27721151

fbshipit-source-id: 08a367662d506a48e0d639115c06cd4e714717b9
2021-04-12 19:24:10 -07:00
Alex Hornby
9fce86450a fix rust warnings
Summary: noticed these in passing while working on previous diff

Reviewed By: mitrandir77

Differential Revision: D27227682

fbshipit-source-id: e7858c81951b780722b0836ecf6ee72aeb1ffa09
2021-03-22 11:47:55 -07:00
Lukas Piatkowski
ad106958f2 eden/scm/lib: autogenerate all Cargo.toml files with autocargo
Summary: This diff removes the split between manually managed and autocargo managed Cargo.toml files in `eden/scm/lib`, now all files are autogenerated.

Reviewed By: quark-zju

Differential Revision: D26830884

fbshipit-source-id: 3a5d8409a61347c7650cc7d8192fa426c03733dc
2021-03-05 04:29:49 -08:00
Jun Wu
278d44ecd1 tracing-collector: stop forwarding to log eco-system
Summary:
Now we use tracing_subscriber for equivalent features (by setting EDENSCM_LOG).
It's no longer necessary to forward to log eco-system.

Reviewed By: sfilipco

Differential Revision: D26518018

fbshipit-source-id: 7cc080faa734ca40eed1ce250df3135ca2626c1f
2021-02-23 15:09:15 -08:00
Jun Wu
568e0d2258 tracing-collector: mark default_collector return LookupSpan
Summary:
`LookupSpan` is needed to chain the fmt logger:

  impl<S, N, E, W> Layer<S> for tracing_subscriber::fmt::Layer<S, N, E, W>
  where
      S: Subscriber + for<'a> LookupSpan<'a>,
      N: for<'writer> FormatFields<'writer> + 'static,
      E: FormatEvent<S, N> + 'static,
      W: MakeWriter + 'static,

Reviewed By: sfilipco

Differential Revision: D26518020

fbshipit-source-id: fda996683e2c68cede4778e653845bd23a1fcb1c
2021-02-19 15:22:06 -08:00
Jun Wu
b7e800f6f3 tracing-collector: limit the count a callsite can log
Summary:
Limit the span or event count that a callsite can log so we can handle highly
repetitive calls. This is similar to D23307793 (d8e775f423) but applies to the Rust tracing
APIs.

Reviewed By: sfilipco

Differential Revision: D26090876

fbshipit-source-id: 394f52d697fc5e9ba5b900cebc9405a9f29220ce
2021-01-28 12:32:56 -08:00
Jun Wu
efe510e4a0 tracing-collector: make id mapping editing private
Summary: Those APIs are internal details. Public APIs do not need them.

Reviewed By: sfilipco

Differential Revision: D26090877

fbshipit-source-id: b6e3ac76de719d1db71c2b57da3e8ef76015089e
2021-01-28 12:32:56 -08:00
Jun Wu
7656b5796e tracing-analyzer: aggregate logging data from tracing data
Summary:
This new crate is part of the new telemetry / logging effort.  Its input is
tracing data, and output is aggregated NoSQL table content.

This diff is only the start, setting up the direction.

Reviewed By: DurhamG

Differential Revision: D19797702

fbshipit-source-id: bdf34461c05b5eae5e59652bc82d8ee1857dbf1e
2021-01-22 12:31:16 -08:00
Stefan Filip
a76dffcb83 tracing: update base collector to Registry + Subscriber list
Summary:
This setup is more extendable than the TracingData focused approach. We can
more easily add new functionality using the Subscriber list.

The approach taken here to introduce the new collector tries to maintain
existing functionality. We can then move various logic to their own
Subscribers.

Reviewed By: quark-zju

Differential Revision: D25988580

fbshipit-source-id: 045cd355dbd499109e554a29a1439c2d490b7c40
2021-01-21 11:35:08 -08:00
David Tolnay
e62b176170 Prepare for rustfmt 2.0
Summary:
Generated by formatting with rustfmt 2.0.0-rc.2 and then a second time with fbsource's current rustfmt (1.4.14).

This results in formatting for which rustfmt 1.4 is idempotent but is closer to the style of rustfmt 2.0, reducing the amount of code that will need to change atomically in that upgrade.

 ---

*Why now?* **:** The 1.x branch is no longer being developed and fixes like https://github.com/rust-lang/rustfmt/issues/4159 (which we need in fbcode) only land to the 2.0 branch.

 ---

Reviewed By: zertosh

Differential Revision: D23568779

fbshipit-source-id: 477200f35b280a4f6471d8e574e37e5f57917baf
2020-09-07 20:47:59 -07:00
Jun Wu
d8e775f423 tracing-collector: limit maximum count of spans
Summary:
Some functions might be called very frequently. For example,
`phases.phasecache.loadphaserevs` might be called 100k+ times.
That makes the tracing data harder to process.

Limit the count of spans to 1k by default so the data is cheaper to process,
and some highly repetitive cases can now be reasoned about. Note the limit
is only put on static Span Ids. If a span uses dynamic metadata or ask for
different Span Ids each time, they will not be limited.

In debugshell,

  td = %trace repo.revs('smartlog()')
  len(td.serialize())

dropped from 6MB to 0.87MB.

It's also possible to reason about:

  td = %trace len(repo.revs('ancestors(.)'))

in debugshell (taking 30s, 98KB serialized, vs 21s without tracing), while
previously the result would be too large to show (`%trace` just hangs).

Reviewed By: DurhamG

Differential Revision: D23307793

fbshipit-source-id: 3c1e9885ce7a275c2abd8935a4e4539a4f14ce83
2020-08-27 18:14:29 -07:00
Jun Wu
3376363721 tracing-collector: add is_event to TreeSpan
Summary: Expose the is_event property via public APIs.

Reviewed By: DurhamG

Differential Revision: D19797705

fbshipit-source-id: f441825e98208964f7b3d6815a177b464430cbb7
2020-03-12 12:19:38 -07:00
Jun Wu
7a12c33163 dev-logger: a simple library to enable env_logger for testing
Summary:
The tracing / env_logger integration works for hg as a binary. However I'd also
like to use it in library tests. This crate makes it easier to do so.

Reviewed By: xavierd

Differential Revision: D20286507

fbshipit-source-id: f5bf3288ce950591ddfe64b524ad51ce21ee4099
2020-03-10 14:16:38 -07:00
Jun Wu
97d0a976fd tracing: make it write to the log eco-system
Summary:
This means crates like env_logger (which reads $RUST_LOG, and writes to stderr)
can be used for convenient debugging.

Reviewed By: xavierd

Differential Revision: D20286514

fbshipit-source-id: e3b80cc4830ba5cc6dbf7aa1cbb92a4f4f046a54
2020-03-10 14:16:37 -07:00
Jun Wu
796f199130 tracing: save static metadata from tracing to Spans
Summary:
Those metadata include module_path, target, line number, etc, in Rust native
format.  They will be used for the upcoming `log` integration.

Reviewed By: xavierd

Differential Revision: D20286510

fbshipit-source-id: 27019b941bef08c0bb3e505bbdae642282dcb141
2020-03-10 14:16:36 -07:00
Jun Wu
918672b106 tracing-collector: support owned strings in TreeSpans
Summary:
TreeSpans used to use `&str`, which adds a lifetime to the struct, making it
harder to be used in the Python land. Use a type parameter so TreeSpans<String>
can be used.

Reviewed By: DurhamG

Differential Revision: D19797708

fbshipit-source-id: c66429abfaf16d876151ca6f29da976bed91485d
2020-02-28 09:16:14 -08:00
Jun Wu
4cd7df6a01 tracing-collector: rename structs
Summary:
TreeSpan -> RawTreeSpan; TreeSpanWithMeta -> TreeSpanRef.

I'm going to add a non-reference version of TreeSpanRef.

Differential Revision: D19797701

fbshipit-source-id: 42b04c23d4d0ddbe821b94fa2ccb133ce9eafa05
2020-02-28 09:16:14 -08:00
Jun Wu
957617c8b8 tracing-collector: support filtering in TreeSpans
Summary:
The filtering interface allows callsite to select what they want. It's similar
to manifest walk with files or directory matchers in source control.

Reviewed By: DurhamG

Differential Revision: D19784467

fbshipit-source-id: 5cf6e4016d6fa1c90f8aeccc50809baccd4af5ab
2020-02-28 09:16:13 -08:00
Jun Wu
366e701239 tracing-collector: support Events in TreeSpans
Summary: The idea is that instants (events) can be a drop-in replacement for `ui.log`.

Reviewed By: DurhamG

Differential Revision: D19782897

fbshipit-source-id: 795bbba23d921e460f723f19ef529b203aea366a
2020-02-28 09:16:13 -08:00
Jun Wu
d205592d42 tracing-collector: extract logic finding parent span to a function
Summary: This function will be reused by the next diff.

Reviewed By: DurhamG

Differential Revision: D19782895

fbshipit-source-id: 1e636eabee9b0dffd287a1e6784a24ab2259f51f
2020-02-28 09:16:13 -08:00
Jun Wu
8b5fdc01fc tracing-collector: put treespans into a struct
Summary: This allows us to define methods on the treespans, such as filtering APIs.

Reviewed By: DurhamG

Differential Revision: D19782896

fbshipit-source-id: 2e7bd8344c0196e382728c26a8233abf944bbf29
2020-02-28 09:16:12 -08:00
Jun Wu
69aa37f23b tracing: limit column width on ASCII output
Summary: This makes the output more readable even if the "name" of a span is very long.

Reviewed By: DurhamG

Differential Revision: D19780536

fbshipit-source-id: dce0d3777409c32b0752db51341a572addb823ea
2020-02-06 15:46:53 -08:00
Adam Simpkins
ab3a7cb21f Move fb-mercurial sources into an eden/scm subdirectory.
Summary:
In preparation for merging fb-mercurial sources to the Eden repository,
move everything from the top-level directory into an `eden/scm`
subdirectory.
2019-11-13 16:04:48 -08:00