Skip to content

Commit d923d62

Browse files
committed
Auto merge of #16394 - davidbarsky:david/add-more-tracing-spans, r=Veykril
internal: add some `tracing` to {Request, Notification}Dispatch Some of the tracing config would need to be changed in order to benefit more from this (especially `.with_span_events(FmtSpan::CLOSE)`), which provides span events like the following: ``` 2024-01-18T02:41:06.675779Z INFO request{method="textDocument/codeLens" request_id=RequestId(I32(17))}: rust_analyzer::dispatch: close time.busy=61.8µs time.idle=5.29µs ``` I dunno if y'all need `LoggerFormatter` in here, but if you don't, I'd be happy to yeet it out of rust-analyzer. In any case, this provided a pretty decent amount of information in the logs, and I can expand this as needed or we can land this PR and expand later.
2 parents 63123ab + e1ea7c8 commit d923d62

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+658
-825
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ itertools = "0.12.0"
113113
libc = "0.2.150"
114114
nohash-hasher = "0.2.0"
115115
rayon = "1.8.0"
116-
rust-analyzer-salsa = "0.17.0-pre.5"
116+
rust-analyzer-salsa = "0.17.0-pre.6"
117117
rustc-hash = "1.1.0"
118118
semver = "1.0.14"
119119
serde = { version = "1.0.192", features = ["derive"] }
@@ -128,9 +128,9 @@ text-size = "1.1.1"
128128
tracing = "0.1.40"
129129
tracing-tree = "0.3.0"
130130
tracing-subscriber = { version = "0.3.18", default-features = false, features = [
131-
"registry",
132-
"fmt",
133-
"tracing-log",
131+
"registry",
132+
"fmt",
133+
"tracing-log",
134134
] }
135135
triomphe = { version = "0.1.10", default-features = false, features = ["std"] }
136136
xshell = "0.2.5"

crates/base-db/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ rust-analyzer-salsa.workspace = true
1717
rustc-hash.workspace = true
1818
triomphe.workspace = true
1919
semver.workspace = true
20+
tracing.workspace = true
2021

2122
# local deps
2223
cfg.workspace = true
@@ -27,4 +28,4 @@ vfs.workspace = true
2728
span.workspace = true
2829

2930
[lints]
30-
workspace = true
31+
workspace = true

crates/base-db/src/change.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl FileChange {
5151
}
5252

5353
pub fn apply(self, db: &mut dyn SourceDatabaseExt) {
54-
let _p = profile::span("RootDatabase::apply_change");
54+
let _p = tracing::span!(tracing::Level::INFO, "RootDatabase::apply_change").entered();
5555
if let Some(roots) = self.roots {
5656
for (idx, root) in roots.into_iter().enumerate() {
5757
let root_id = SourceRootId(idx as u32);

crates/base-db/src/input.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ impl CrateGraph {
494494
from: CrateId,
495495
dep: Dependency,
496496
) -> Result<(), CyclicDependenciesError> {
497-
let _p = profile::span("add_dep");
497+
let _p = tracing::span!(tracing::Level::INFO, "add_dep").entered();
498498

499499
self.check_cycle_after_dependency(from, dep.crate_id)?;
500500

crates/base-db/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub trait SourceDatabase: FileLoader + std::fmt::Debug {
6565
}
6666

6767
fn parse(db: &dyn SourceDatabase, file_id: FileId) -> Parse<ast::SourceFile> {
68-
let _p = profile::span("parse_query").detail(|| format!("{file_id:?}"));
68+
let _p = tracing::span!(tracing::Level::INFO, "parse_query", ?file_id).entered();
6969
let text = db.file_text(file_id);
7070
SourceFile::parse(&text)
7171
}
@@ -116,7 +116,7 @@ impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> {
116116
}
117117

118118
fn relevant_crates(&self, file_id: FileId) -> Arc<[CrateId]> {
119-
let _p = profile::span("relevant_crates");
119+
let _p = tracing::span!(tracing::Level::INFO, "relevant_crates").entered();
120120
let source_root = self.0.file_source_root(file_id);
121121
self.0.source_root_crates(source_root)
122122
}

crates/hir-def/src/attr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl Attrs {
7575
db: &dyn DefDatabase,
7676
v: VariantId,
7777
) -> Arc<ArenaMap<LocalFieldId, Attrs>> {
78-
let _p = profile::span("fields_attrs_query");
78+
let _p = tracing::span!(tracing::Level::INFO, "fields_attrs_query").entered();
7979
// FIXME: There should be some proper form of mapping between item tree field ids and hir field ids
8080
let mut res = ArenaMap::default();
8181

@@ -322,7 +322,7 @@ impl AttrsWithOwner {
322322
}
323323

324324
pub(crate) fn attrs_query(db: &dyn DefDatabase, def: AttrDefId) -> Attrs {
325-
let _p = profile::span("attrs_query");
325+
let _p = tracing::span!(tracing::Level::INFO, "attrs_query").entered();
326326
// FIXME: this should use `Trace` to avoid duplication in `source_map` below
327327
let raw_attrs = match def {
328328
AttrDefId::ModuleId(module) => {

crates/hir-def/src/body.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl Body {
122122
db: &dyn DefDatabase,
123123
def: DefWithBodyId,
124124
) -> (Arc<Body>, Arc<BodySourceMap>) {
125-
let _p = profile::span("body_with_source_map_query");
125+
let _p = tracing::span!(tracing::Level::INFO, "body_with_source_map_query").entered();
126126
let mut params = None;
127127

128128
let mut is_async_fn = false;

crates/hir-def/src/data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ impl ImplData {
340340
db: &dyn DefDatabase,
341341
id: ImplId,
342342
) -> (Arc<ImplData>, DefDiagnostics) {
343-
let _p = profile::span("impl_data_with_diagnostics_query");
343+
let _p = tracing::span!(tracing::Level::INFO, "impl_data_with_diagnostics_query").entered();
344344
let ItemLoc { container: module_id, id: tree_id } = id.lookup(db);
345345

346346
let item_tree = tree_id.item_tree(db);

crates/hir-def/src/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ fn include_macro_invoc(db: &dyn DefDatabase, krate: CrateId) -> Vec<(MacroCallId
254254
}
255255

256256
fn crate_def_map_wait(db: &dyn DefDatabase, krate: CrateId) -> Arc<DefMap> {
257-
let _p = profile::span("crate_def_map:wait");
257+
let _p = tracing::span!(tracing::Level::INFO, "crate_def_map:wait").entered();
258258
db.crate_def_map_query(krate)
259259
}
260260

0 commit comments

Comments
 (0)