mirror of
https://github.com/pesde-pkg/pesde.git
synced 2025-01-10 01:39:10 +00:00
feat: add more tracing info
This commit is contained in:
parent
d9d27cf45b
commit
9535175a45
5 changed files with 303 additions and 284 deletions
|
@ -13,7 +13,7 @@ use std::{
|
|||
collections::HashSet,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
use tracing::instrument;
|
||||
use tracing::{instrument, Instrument};
|
||||
|
||||
type MultithreadedGraph = Arc<Mutex<DownloadedGraph>>;
|
||||
|
||||
|
@ -71,13 +71,20 @@ impl Project {
|
|||
let version_id = version_id.clone();
|
||||
let node = node.clone();
|
||||
|
||||
let span = tracing::debug_span!(
|
||||
"download",
|
||||
name = name.to_string(),
|
||||
version_id = version_id.to_string()
|
||||
);
|
||||
|
||||
let project = project.clone();
|
||||
let reqwest = reqwest.clone();
|
||||
let downloaded_graph = downloaded_graph.clone();
|
||||
|
||||
let package_dir = self.package_dir().to_path_buf();
|
||||
|
||||
tokio::spawn(async move {
|
||||
tokio::spawn(
|
||||
async move {
|
||||
let source = node.pkg_ref.source();
|
||||
|
||||
let container_folder = node.container_folder(
|
||||
|
@ -100,7 +107,7 @@ impl Project {
|
|||
|
||||
let project = project.clone();
|
||||
|
||||
tracing::debug!("downloading {name}@{version_id}");
|
||||
tracing::debug!("downloading");
|
||||
|
||||
let (fs, target) =
|
||||
match source.download(&node.pkg_ref, &project, &reqwest).await {
|
||||
|
@ -111,7 +118,7 @@ impl Project {
|
|||
}
|
||||
};
|
||||
|
||||
tracing::debug!("downloaded {name}@{version_id}");
|
||||
tracing::debug!("downloaded");
|
||||
|
||||
if write {
|
||||
if !prod || node.resolved_ty != DependencyType::Dev {
|
||||
|
@ -125,7 +132,9 @@ impl Project {
|
|||
}
|
||||
};
|
||||
} else {
|
||||
tracing::debug!("skipping writing {name}@{version_id} to disk, dev dependency in prod mode");
|
||||
tracing::debug!(
|
||||
"skipping write to disk, dev dependency in prod mode"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,7 +149,9 @@ impl Project {
|
|||
}
|
||||
|
||||
tx.send(Ok(display_name)).await.unwrap();
|
||||
});
|
||||
}
|
||||
.instrument(span),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -117,18 +117,10 @@ pub fn get_lib_require_path(
|
|||
) -> Result<String, errors::GetLibRequirePath> {
|
||||
let path = pathdiff::diff_paths(destination_dir, base_dir).unwrap();
|
||||
let path = if use_new_structure {
|
||||
tracing::debug!(
|
||||
"using new structure for require path with {:?} of {}",
|
||||
lib_file,
|
||||
container_dir.display()
|
||||
);
|
||||
tracing::debug!("using new structure for require path with {lib_file:?}");
|
||||
lib_file.to_path(path)
|
||||
} else {
|
||||
tracing::debug!(
|
||||
"using old structure for require path with {:?} of {}",
|
||||
lib_file,
|
||||
container_dir.display()
|
||||
);
|
||||
tracing::debug!("using old structure for require path with {lib_file:?}");
|
||||
path
|
||||
};
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ use std::{
|
|||
sync::Arc,
|
||||
};
|
||||
use tokio::task::spawn_blocking;
|
||||
use tracing::instrument;
|
||||
use tracing::{instrument, Instrument};
|
||||
|
||||
/// Generates linking modules for a project
|
||||
pub mod generator;
|
||||
|
@ -112,7 +112,7 @@ impl Project {
|
|||
}
|
||||
};
|
||||
|
||||
tracing::debug!("{name}@{version_id} has {} exported types", types.len());
|
||||
tracing::debug!("contains {} exported types", types.len());
|
||||
|
||||
types
|
||||
} else {
|
||||
|
@ -145,7 +145,7 @@ impl Project {
|
|||
}
|
||||
|
||||
Ok((version_id, types))
|
||||
}))
|
||||
}.instrument(tracing::debug_span!("extract types", name = name.to_string(), version_id = version_id.to_string()))))
|
||||
.await?
|
||||
.into_iter()
|
||||
.collect::<HashMap<_, _>>(),
|
||||
|
@ -252,6 +252,12 @@ impl Project {
|
|||
let manifest = manifest.clone();
|
||||
let package_types = package_types.clone();
|
||||
|
||||
let span = tracing::debug_span!(
|
||||
"link",
|
||||
name = name.to_string(),
|
||||
version_id = version_id.to_string()
|
||||
);
|
||||
|
||||
async move {
|
||||
let (node_container_folder, node_packages_folder) = {
|
||||
let base_folder = create_and_canonicalize(
|
||||
|
@ -340,6 +346,7 @@ impl Project {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
.instrument(span)
|
||||
})
|
||||
}))
|
||||
.await
|
||||
|
|
|
@ -151,6 +151,7 @@ async fn run() -> anyhow::Result<()> {
|
|||
.with(tracing_env_filter)
|
||||
.with(
|
||||
tracing_subscriber::fmt::layer()
|
||||
.pretty()
|
||||
.with_writer(indicatif_layer.get_stderr_writer())
|
||||
.with_timer(uptime()),
|
||||
)
|
||||
|
|
|
@ -12,7 +12,7 @@ use crate::{
|
|||
Project, DEFAULT_INDEX_NAME,
|
||||
};
|
||||
use std::collections::{btree_map::Entry, HashMap, HashSet, VecDeque};
|
||||
use tracing::instrument;
|
||||
use tracing::{instrument, Instrument};
|
||||
|
||||
fn insert_node(
|
||||
graph: &mut DependencyGraph,
|
||||
|
@ -84,7 +84,7 @@ impl Project {
|
|||
if let Some(previous_graph) = previous_graph {
|
||||
for (name, versions) in previous_graph {
|
||||
for (version, node) in versions {
|
||||
let Some((_, specifier, source_ty)) = &node.direct else {
|
||||
let Some((old_alias, specifier, source_ty)) = &node.direct else {
|
||||
// this is not a direct dependency, will be added if it's still being used later
|
||||
continue;
|
||||
};
|
||||
|
@ -97,11 +97,14 @@ impl Project {
|
|||
let Some(alias) = all_specifiers.remove(&(specifier.clone(), *source_ty))
|
||||
else {
|
||||
tracing::debug!(
|
||||
"dependency {name}@{version} from old dependency graph is no longer in the manifest",
|
||||
"dependency {name}@{version} (old alias {old_alias}) from old dependency graph is no longer in the manifest",
|
||||
);
|
||||
continue;
|
||||
};
|
||||
|
||||
let span = tracing::debug_span!("resolve from old graph", alias);
|
||||
let _guard = span.enter();
|
||||
|
||||
tracing::debug!("resolved {}@{} from old dependency graph", name, version);
|
||||
insert_node(
|
||||
&mut graph,
|
||||
|
@ -117,22 +120,24 @@ impl Project {
|
|||
let mut queue = node
|
||||
.dependencies
|
||||
.iter()
|
||||
.map(|(name, (version, _))| (name, version, 0usize))
|
||||
.map(|(name, (version, dep_alias))| {
|
||||
(
|
||||
name,
|
||||
version,
|
||||
vec![alias.to_string(), dep_alias.to_string()],
|
||||
)
|
||||
})
|
||||
.collect::<VecDeque<_>>();
|
||||
|
||||
while let Some((dep_name, dep_version, depth)) = queue.pop_front() {
|
||||
while let Some((dep_name, dep_version, path)) = queue.pop_front() {
|
||||
let inner_span =
|
||||
tracing::debug_span!("resolve dependency", path = path.join(">"));
|
||||
let _inner_guard = inner_span.enter();
|
||||
if let Some(dep_node) = previous_graph
|
||||
.get(dep_name)
|
||||
.and_then(|v| v.get(dep_version))
|
||||
{
|
||||
tracing::debug!(
|
||||
"{}resolved dependency {}@{} from {}@{}",
|
||||
"\t".repeat(depth),
|
||||
dep_name,
|
||||
dep_version,
|
||||
name,
|
||||
version
|
||||
);
|
||||
tracing::debug!("resolved sub-dependency {dep_name}@{dep_version}");
|
||||
insert_node(
|
||||
&mut graph,
|
||||
dep_name.clone(),
|
||||
|
@ -144,15 +149,20 @@ impl Project {
|
|||
dep_node
|
||||
.dependencies
|
||||
.iter()
|
||||
.map(|(name, (version, _))| (name, version, depth + 1))
|
||||
.map(|(name, (version, alias))| {
|
||||
(
|
||||
name,
|
||||
version,
|
||||
path.iter()
|
||||
.cloned()
|
||||
.chain(std::iter::once(alias.to_string()))
|
||||
.collect(),
|
||||
)
|
||||
})
|
||||
.for_each(|dep| queue.push_back(dep));
|
||||
} else {
|
||||
tracing::warn!(
|
||||
"dependency {}@{} from {}@{} not found in previous graph",
|
||||
dep_name,
|
||||
dep_version,
|
||||
name,
|
||||
version
|
||||
"dependency {dep_name}@{dep_version} not found in previous graph"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -175,14 +185,11 @@ impl Project {
|
|||
.collect::<VecDeque<_>>();
|
||||
|
||||
while let Some((specifier, ty, dependant, path, overridden, target)) = queue.pop_front() {
|
||||
async {
|
||||
let alias = path.last().unwrap().clone();
|
||||
let depth = path.len() - 1;
|
||||
|
||||
tracing::debug!(
|
||||
"{}resolving {specifier} ({ty:?}) from {}",
|
||||
"\t".repeat(depth),
|
||||
path.join(">")
|
||||
);
|
||||
tracing::debug!("resolving {specifier} ({ty:?})");
|
||||
let source = match &specifier {
|
||||
DependencySpecifiers::Pesde(specifier) => {
|
||||
let index_url = if !is_published_package && (depth == 0 || overridden) {
|
||||
|
@ -289,8 +296,7 @@ impl Project {
|
|||
.and_then(|versions| versions.get_mut(&target_version_id))
|
||||
{
|
||||
tracing::debug!(
|
||||
"{}{}@{} already resolved",
|
||||
"\t".repeat(depth),
|
||||
"{}@{} already resolved",
|
||||
name,
|
||||
target_version_id
|
||||
);
|
||||
|
@ -299,8 +305,7 @@ impl Project {
|
|||
!= std::mem::discriminant(pkg_ref)
|
||||
{
|
||||
tracing::warn!(
|
||||
"resolved package {name}@{target_version_id} has a different source than the previously resolved one at {}, this may cause issues",
|
||||
path.join(">")
|
||||
"resolved package {name}@{target_version_id} has a different source than previously resolved one, this may cause issues",
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -316,7 +321,7 @@ impl Project {
|
|||
already_resolved.direct = Some((alias.clone(), specifier.clone(), ty));
|
||||
}
|
||||
|
||||
continue;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let node = DependencyGraphNode {
|
||||
|
@ -343,8 +348,7 @@ impl Project {
|
|||
);
|
||||
|
||||
tracing::debug!(
|
||||
"{}resolved {}@{} from new dependency graph",
|
||||
"\t".repeat(depth),
|
||||
"resolved {}@{} from new dependency graph",
|
||||
name,
|
||||
target_version_id
|
||||
);
|
||||
|
@ -371,8 +375,7 @@ impl Project {
|
|||
|
||||
if overridden.is_some() {
|
||||
tracing::debug!(
|
||||
"{}overridden specifier found for {} ({dependency_spec})",
|
||||
"\t".repeat(depth),
|
||||
"overridden specifier found for {} ({dependency_spec})",
|
||||
path.iter()
|
||||
.map(|s| s.as_str())
|
||||
.chain(std::iter::once(dependency_alias.as_str()))
|
||||
|
@ -393,6 +396,11 @@ impl Project {
|
|||
*target_version_id.target(),
|
||||
));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
.instrument(tracing::debug_span!("resolve new/changed", path = path.join(">")))
|
||||
.await?;
|
||||
}
|
||||
|
||||
for (name, versions) in &mut graph {
|
||||
|
|
Loading…
Reference in a new issue