diff options
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/shirabe/Cargo.toml | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/console/application.rs | 1 | ||||
| -rw-r--r-- | crates/shirabe/src/dependency_resolver/pool_builder.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/dependency_resolver/pool_optimizer.rs | 5 | ||||
| -rw-r--r-- | crates/shirabe/src/dependency_resolver/security_advisory_pool_filter.rs | 1 | ||||
| -rw-r--r-- | crates/shirabe/src/dependency_resolver/solver.rs | 1 | ||||
| -rw-r--r-- | crates/shirabe/src/factory.rs | 1 | ||||
| -rw-r--r-- | crates/shirabe/src/installer.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/main.rs | 28 | ||||
| -rw-r--r-- | crates/shirabe/src/package/loader/array_loader.rs | 1 | ||||
| -rw-r--r-- | crates/shirabe/src/package/locker.rs | 1 | ||||
| -rw-r--r-- | crates/shirabe/src/repository/composer_repository.rs | 3 | ||||
| -rw-r--r-- | crates/shirabe/src/repository/platform_repository.rs | 1 | ||||
| -rw-r--r-- | crates/shirabe/src/repository/repository_set.rs | 1 |
14 files changed, 50 insertions, 0 deletions
diff --git a/crates/shirabe/Cargo.toml b/crates/shirabe/Cargo.toml index 00ce5211..22112cbe 100644 --- a/crates/shirabe/Cargo.toml +++ b/crates/shirabe/Cargo.toml @@ -25,6 +25,8 @@ serde.workspace = true serde_json.workspace = true sha1.workspace = true tokio.workspace = true +tracing.workspace = true +tracing-subscriber.workspace = true url.workspace = true [dev-dependencies] diff --git a/crates/shirabe/src/console/application.rs b/crates/shirabe/src/console/application.rs index 577d8704..6febdf95 100644 --- a/crates/shirabe/src/console/application.rs +++ b/crates/shirabe/src/console/application.rs @@ -1891,6 +1891,7 @@ impl ApplicationHandle { self.base_run(input, output) } + #[tracing::instrument(skip_all)] pub fn do_run( &self, input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, diff --git a/crates/shirabe/src/dependency_resolver/pool_builder.rs b/crates/shirabe/src/dependency_resolver/pool_builder.rs index 15cac540..83307d8c 100644 --- a/crates/shirabe/src/dependency_resolver/pool_builder.rs +++ b/crates/shirabe/src/dependency_resolver/pool_builder.rs @@ -126,6 +126,7 @@ impl PoolBuilder { self.allowed_types = types; } + #[tracing::instrument(skip_all)] pub fn build_pool( &mut self, repositories: Vec<RepositoryInterfaceHandle>, @@ -428,6 +429,7 @@ impl PoolBuilder { self.loaded_packages.shift_remove(name); } + #[tracing::instrument(skip_all)] fn load_packages_marked_for_loading( &mut self, request: &mut Request, diff --git a/crates/shirabe/src/dependency_resolver/pool_optimizer.rs b/crates/shirabe/src/dependency_resolver/pool_optimizer.rs index 789d0aed..f188d1b8 100644 --- a/crates/shirabe/src/dependency_resolver/pool_optimizer.rs +++ b/crates/shirabe/src/dependency_resolver/pool_optimizer.rs @@ -57,6 +57,7 @@ impl PoolOptimizer { } } + #[tracing::instrument(skip_all)] pub fn optimize(&mut self, request: &Request, pool: &Pool) -> Pool { self.prepare(request, pool); @@ -81,6 +82,7 @@ impl PoolOptimizer { optimized_pool } + #[tracing::instrument(skip_all)] fn prepare(&mut self, request: &Request, pool: &Pool) { let mut irremovable_package_constraint_groups: IndexMap<String, Vec<AnyConstraint>> = IndexMap::new(); @@ -184,6 +186,7 @@ impl PoolOptimizer { } /// @return Pool Optimized pool + #[tracing::instrument(skip_all)] fn apply_removals_to_pool(&self, pool: &Pool) -> Pool { let mut packages: Vec<BasePackageHandle> = vec![]; let mut removed_versions: IndexMap<String, IndexMap<String, String>> = IndexMap::new(); @@ -211,6 +214,7 @@ impl PoolOptimizer { ) } + #[tracing::instrument(skip_all)] fn optimize_by_identical_dependencies(&mut self, _request: &Request, pool: &Pool) { let mut identical_definitions_per_package: IndexMap< String, @@ -536,6 +540,7 @@ impl PoolOptimizer { /// Use the list of locked packages to constrain the loaded packages /// This will reduce packages with significant numbers of historical versions to a smaller number /// and reduce the resulting rule set that is generated + #[tracing::instrument(skip_all)] fn optimize_impossible_packages_away(&mut self, request: &Request, pool: &Pool) { if request.get_locked_packages().is_empty() { return; diff --git a/crates/shirabe/src/dependency_resolver/security_advisory_pool_filter.rs b/crates/shirabe/src/dependency_resolver/security_advisory_pool_filter.rs index 933e1d0f..59acad89 100644 --- a/crates/shirabe/src/dependency_resolver/security_advisory_pool_filter.rs +++ b/crates/shirabe/src/dependency_resolver/security_advisory_pool_filter.rs @@ -26,6 +26,7 @@ impl SecurityAdvisoryPoolFilter { } } + #[tracing::instrument(skip_all)] pub fn filter( &self, pool: Pool, diff --git a/crates/shirabe/src/dependency_resolver/solver.rs b/crates/shirabe/src/dependency_resolver/solver.rs index 960cd7a6..09a51ef8 100644 --- a/crates/shirabe/src/dependency_resolver/solver.rs +++ b/crates/shirabe/src/dependency_resolver/solver.rs @@ -220,6 +220,7 @@ impl Solver { Ok(()) } + #[tracing::instrument(skip_all)] pub fn solve( &mut self, request: &Request, diff --git a/crates/shirabe/src/factory.rs b/crates/shirabe/src/factory.rs index 52894b26..13697a4e 100644 --- a/crates/shirabe/src/factory.rs +++ b/crates/shirabe/src/factory.rs @@ -424,6 +424,7 @@ impl Factory { } /// Creates a Composer instance + #[tracing::instrument(skip_all)] pub fn create_composer( &self, io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, diff --git a/crates/shirabe/src/installer.rs b/crates/shirabe/src/installer.rs index 3cdb046b..883ee134 100644 --- a/crates/shirabe/src/installer.rs +++ b/crates/shirabe/src/installer.rs @@ -216,6 +216,7 @@ impl Installer { } /// Run installation (or update) + #[tracing::instrument(skip_all)] pub fn run(&mut self) -> anyhow::Result<i64> { // Disable GC to save CPU cycles, as the dependency solver can create hundreds of thousands // of PHP objects, the GC can spend quite some time walking the tree of references looking @@ -560,6 +561,7 @@ impl Installer { Ok(0) } + #[tracing::instrument(skip_all)] pub(crate) fn do_update( &mut self, local_repo: crate::repository::RepositoryInterfaceHandle, diff --git a/crates/shirabe/src/main.rs b/crates/shirabe/src/main.rs index 6eb8e4cb..49ee61f3 100644 --- a/crates/shirabe/src/main.rs +++ b/crates/shirabe/src/main.rs @@ -1,6 +1,32 @@ //! ref: composer/bin/composer use shirabe_php_shim::{PHP_ENV, PHP_SERVER}; +use std::io::IsTerminal as _; + +/// Initialize a tracing subscriber from the environment variable `$SHIRABE_TRACING`. +fn init_tracing() { + let Ok(directives) = std::env::var("SHIRABE_TRACING") else { + return; + }; + if directives.is_empty() { + return; + } + + let env_filter = match tracing_subscriber::EnvFilter::builder().parse(&directives) { + Ok(env_filter) => env_filter, + Err(e) => { + eprintln!("SHIRABE_TRACING: invalid filter directives {directives:?}: {e}"); + return; + } + }; + + tracing_subscriber::fmt() + .with_env_filter(env_filter) + .with_writer(std::io::stderr) + .with_ansi(std::io::stderr().is_terminal()) + .with_span_events(tracing_subscriber::fmt::format::FmtSpan::CLOSE) + .init(); +} fn main() { // TODO(phase-c): PHP: `$xdebug = new XdebugHandler('Composer'); $xdebug->check(); unset($xdebug);` @@ -28,6 +54,8 @@ fn main() { .expect("failed to build the top-level tokio runtime"); let _runtime_guard = runtime.enter(); + init_tracing(); + let result = shirabe::run(std::env::args().collect()); let exit_code = match result { Ok(exit_code) => exit_code, diff --git a/crates/shirabe/src/package/loader/array_loader.rs b/crates/shirabe/src/package/loader/array_loader.rs index 3a78ff76..3ebdc488 100644 --- a/crates/shirabe/src/package/loader/array_loader.rs +++ b/crates/shirabe/src/package/loader/array_loader.rs @@ -192,6 +192,7 @@ impl ArrayLoader { /// @param array<array<mixed>> $versions /// /// @return list<CompletePackage|CompleteAliasPackage> + #[tracing::instrument(skip_all)] pub fn load_packages( &self, versions: Vec<IndexMap<String, PhpMixed>>, diff --git a/crates/shirabe/src/package/locker.rs b/crates/shirabe/src/package/locker.rs index 535b5fdf..a2f3c0c9 100644 --- a/crates/shirabe/src/package/locker.rs +++ b/crates/shirabe/src/package/locker.rs @@ -460,6 +460,7 @@ impl Locker { /// Locks provided data into lockfile. #[allow(clippy::too_many_arguments, reason = "to keep PHP signature")] + #[tracing::instrument(skip_all)] pub fn set_lock_data( &mut self, packages: Vec<PackageInterfaceHandle>, diff --git a/crates/shirabe/src/repository/composer_repository.rs b/crates/shirabe/src/repository/composer_repository.rs index 84d8fbf7..fbee87d7 100644 --- a/crates/shirabe/src/repository/composer_repository.rs +++ b/crates/shirabe/src/repository/composer_repository.rs @@ -1707,6 +1707,7 @@ impl ComposerRepository { } /// @param packageNames array of package name => ConstraintInterface|null - if a constraint is provided, only packages matching it will be loaded + #[tracing::instrument(skip_all)] fn load_async_packages( &mut self, mut package_names: IndexMap<String, Option<AnyConstraint>>, @@ -1951,6 +1952,7 @@ impl ComposerRepository { }) } + #[tracing::instrument(skip_all)] async fn start_cached_async_download( &self, file_name: &str, @@ -2659,6 +2661,7 @@ impl ComposerRepository { Ok(packages) } + #[tracing::instrument(skip_all)] fn create_packages( &mut self, packages: Vec<IndexMap<String, PhpMixed>>, diff --git a/crates/shirabe/src/repository/platform_repository.rs b/crates/shirabe/src/repository/platform_repository.rs index 0d63940c..2b198c88 100644 --- a/crates/shirabe/src/repository/platform_repository.rs +++ b/crates/shirabe/src/repository/platform_repository.rs @@ -129,6 +129,7 @@ impl PlatformRepository { Ok(()) } + #[tracing::instrument(skip_all)] pub(crate) fn initialize(&mut self) -> anyhow::Result<()> { self.inner.initialize(); diff --git a/crates/shirabe/src/repository/repository_set.rs b/crates/shirabe/src/repository/repository_set.rs index b858151c..c407a1ce 100644 --- a/crates/shirabe/src/repository/repository_set.rs +++ b/crates/shirabe/src/repository/repository_set.rs @@ -297,6 +297,7 @@ impl RepositorySet { /// @param PackageInterface[] $packages /// @return ($allowPartialAdvisories is true ? array{advisories: array<string, array<PartialSecurityAdvisory|SecurityAdvisory>>, unreachableRepos: array<string>} : array{advisories: array<string, array<SecurityAdvisory>>, unreachableRepos: array<string>}) + #[tracing::instrument(skip_all)] pub fn get_matching_security_advisories( &self, packages: Vec<PackageInterfaceHandle>, |
