connTraceWrapProviderClient function
Wraps the provider stack's HTTP client. canInstallObserver tells the
wrapper it may swap in the observed dart:io client — true only when the
caller built a plain default client (no host-injected factory product).
Always returns a client whose requests are REGISTERED for the sentinel (while stallSentinelEnabled); the trace lines only appear while connTraceEnabled. Pure: the observed client comes from the injected connTraceObservedClientFactory (io side), never built here.
Implementation
http.Client connTraceWrapProviderClient(
http.Client inner, {
required bool canInstallObserver,
}) {
if (!connTraceEnabled) {
return ConnTracedClient._(inner, tracing: false);
}
if (canInstallObserver) {
final observed = connTraceObservedClientFactory?.call();
if (observed != null) {
return ConnTracedClient._(observed, tracing: true);
}
}
return ConnTracedClient._(inner, tracing: true);
}