Files
foxhunt/crates/common
jgrusewski 64ca8f97ce fix(observability): dedicated OTLP runtime for sync training binaries
The batch span processor needs a tokio runtime for gRPC transport and
periodic flush. Async services already have one via #[tokio::main], but
sync training binaries (hyperopt, train, evaluate) don't.

Previous approach (making binaries async with #[tokio::main]) caused
"Cannot start a runtime from within a runtime" panics because the ML
crate's internal code creates its own tokio runtimes for block_on().

New approach: build_otel_tracer() detects runtime context via
Handle::try_current(). If absent, it creates a dedicated 1-worker
multi-thread runtime stored in a process-lifetime OnceLock. The worker
thread actively polls the OTLP batch export task.

Reverts training binaries to sync fn main() so internal runtime creation
(hyperopt adapters, DQN/PPO trainers) continues working as before.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 18:54:10 +01:00
..

common

Shared types, error handling, and utilities for the Foxhunt HFT ecosystem.

Key Types

  • FoxhuntError — unified error enum with Result alias
  • ModelType — canonical ML model enum (10 primary variants)
  • CircuitBreakerTrait — async circuit breaker interface
  • TlsProtocolVersion, ClientIdentity — TLS configuration types
  • Market data types (Tick, OrderBook) and order types (LimitOrder, MarketOrder)

Modules

  • model_types — canonical ModelType enum re-exported by ml/ and model_loader/
  • resilienceCircuitBreakerTrait async trait
  • tls — TLS types and configuration
  • questdb — QuestDB client configuration

Usage

use common::{FoxhuntError, ModelType};