feat: add tracing integration behind tracing feature flag
Add optional structured logging via the tracing crate: - info-level spans on all optimize* methods (direction, n_trials/duration) - info events for trial completed, new best value, trial pruned - debug events for trial failed and parameter sampled - Zero overhead when the feature is disabled
This commit is contained in:
+12
-1
@@ -262,7 +262,11 @@ impl Trial {
|
||||
return false;
|
||||
};
|
||||
let history_guard = history.read();
|
||||
pruner.should_prune(self.id, step, &self.intermediate_values, &history_guard)
|
||||
let prune = pruner.should_prune(self.id, step, &self.intermediate_values, &history_guard);
|
||||
if prune {
|
||||
trace_info!(trial_id = self.id, step, "pruner recommends stopping");
|
||||
}
|
||||
prune
|
||||
}
|
||||
|
||||
/// Returns all intermediate values reported so far.
|
||||
@@ -367,6 +371,13 @@ impl Trial {
|
||||
|
||||
let result = param.cast_param_value(&value)?;
|
||||
|
||||
trace_debug!(
|
||||
trial_id = self.id,
|
||||
param = %param.label(),
|
||||
value = %value,
|
||||
"parameter sampled"
|
||||
);
|
||||
|
||||
// Store distribution, value, and label
|
||||
self.distributions.insert(param_id, distribution);
|
||||
self.params.insert(param_id, value);
|
||||
|
||||
Reference in New Issue
Block a user