pub(crate) enum Observation<'a> {
ProjectLoad,
ManifestRead(&'a str),
SourceRead(&'a str),
SourceParse(&'a str),
SiteVisit(&'a str),
ImportWalk(&'a str),
CapabilityProjection(&'a str),
#[cfg(feature = "resolution-test-support")]
DependencyChainExtension { history_entries_copied: usize },
#[cfg(feature = "semantic")]
SemanticWorkspaceLoad,
#[cfg(feature = "semantic")]
SemanticFileSetup(&'a str),
#[cfg(feature = "semantic")]
SemanticQuery(&'a str),
#[cfg(feature = "semantic")]
Promotion(&'a str),
}
#[cfg(feature = "resolution-test-support")]
pub(crate) fn record(event: Observation<'_>) {
super::probe::record(&event);
}
#[cfg(not(feature = "resolution-test-support"))]
pub(crate) fn record(event: Observation<'_>) {
event.discard();
}
#[cfg(not(feature = "resolution-test-support"))]
impl Observation<'_> {
fn discard(self) -> usize {
match self {
Self::ProjectLoad => 0,
#[cfg(feature = "semantic")]
Self::SemanticWorkspaceLoad => 0,
#[cfg(feature = "semantic")]
Self::SemanticFileSetup(path) | Self::SemanticQuery(path) | Self::Promotion(path) => {
path.len()
}
Self::ManifestRead(path)
| Self::SourceRead(path)
| Self::SourceParse(path)
| Self::SiteVisit(path)
| Self::ImportWalk(path)
| Self::CapabilityProjection(path) => path.len(),
}
}
}