feat(observability): wire init_observability into all 5 remaining services
Replace direct tracing_subscriber::fmt::init() calls with the unified common::observability::init_observability() in api_gateway, web-gateway, data_acquisition_service, broker_gateway_service, and trading_agent_service. All 8 services now emit JSON logs + OTLP traces to Tempo. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -21,7 +21,12 @@ pub struct RequestId(pub String);
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
tracing_subscriber::fmt::init();
|
||||
// Initialize observability (JSON logging + OpenTelemetry tracing via OTLP)
|
||||
let otlp_endpoint = std::env::var("OTEL_EXPORTER_OTLP_ENDPOINT")
|
||||
.unwrap_or_else(|_| "http://localhost:4317".to_string());
|
||||
if let Err(e) = common::observability::init_observability("web_gateway", &otlp_endpoint).await {
|
||||
eprintln!("Failed to initialize observability: {}", e);
|
||||
}
|
||||
|
||||
let config = GatewayConfig::from_env();
|
||||
|
||||
|
||||
@@ -53,8 +53,12 @@ struct Args {
|
||||
async fn main() -> Result<()> {
|
||||
let args = Args::parse();
|
||||
|
||||
// Initialize basic logging
|
||||
tracing_subscriber::fmt::init();
|
||||
// Initialize observability (JSON logging + OpenTelemetry tracing via OTLP)
|
||||
let otlp_endpoint = std::env::var("OTEL_EXPORTER_OTLP_ENDPOINT")
|
||||
.unwrap_or_else(|_| "http://localhost:4317".to_string());
|
||||
if let Err(e) = common::observability::init_observability("api_gateway", &otlp_endpoint).await {
|
||||
eprintln!("Failed to initialize observability: {}", e);
|
||||
}
|
||||
|
||||
info!("Starting Foxhunt API Gateway Service");
|
||||
info!("Bind address: {}", args.bind_addr);
|
||||
|
||||
@@ -19,14 +19,12 @@ const DEFAULT_METRICS_PORT: u16 = 9096;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
// Initialize logging
|
||||
tracing_subscriber::fmt()
|
||||
.with_env_filter(
|
||||
tracing_subscriber::EnvFilter::try_from_default_env()
|
||||
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info")),
|
||||
)
|
||||
.json()
|
||||
.init();
|
||||
// Initialize observability (JSON logging + OpenTelemetry tracing via OTLP)
|
||||
let otlp_endpoint = std::env::var("OTEL_EXPORTER_OTLP_ENDPOINT")
|
||||
.unwrap_or_else(|_| "http://localhost:4317".to_string());
|
||||
if let Err(e) = common::observability::init_observability("broker_gateway", &otlp_endpoint).await {
|
||||
eprintln!("Failed to initialize observability: {}", e);
|
||||
}
|
||||
|
||||
info!("🚀 Starting Foxhunt Broker Gateway Service...");
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ struct Args {
|
||||
#[arg(long, default_value = "8095", env = "DATA_ACQUISITION_HEALTH_PORT")]
|
||||
health_port: u16,
|
||||
|
||||
/// Enable debug logging
|
||||
/// Enable debug logging (set RUST_LOG env for fine-grained control)
|
||||
#[arg(long, default_value = "false")]
|
||||
debug: bool,
|
||||
}
|
||||
@@ -32,14 +32,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Parse command-line arguments
|
||||
let args = Args::parse();
|
||||
|
||||
// Initialize tracing
|
||||
let log_level = if args.debug { "debug" } else { "info" };
|
||||
tracing_subscriber::fmt()
|
||||
.with_env_filter(
|
||||
tracing_subscriber::EnvFilter::try_from_default_env()
|
||||
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new(log_level)),
|
||||
)
|
||||
.init();
|
||||
// Initialize observability (JSON logging + OpenTelemetry tracing via OTLP)
|
||||
let otlp_endpoint = std::env::var("OTEL_EXPORTER_OTLP_ENDPOINT")
|
||||
.unwrap_or_else(|_| "http://localhost:4317".to_string());
|
||||
if let Err(e) = common::observability::init_observability("data_acquisition", &otlp_endpoint).await {
|
||||
eprintln!("Failed to initialize observability: {}", e);
|
||||
}
|
||||
|
||||
info!("Starting Data Acquisition Service...");
|
||||
info!("gRPC port: {}", args.port);
|
||||
|
||||
@@ -26,11 +26,12 @@ const DEFAULT_METRICS_PORT: u16 = 9095;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
// Initialize logging
|
||||
tracing_subscriber::fmt()
|
||||
.with_env_filter("trading_agent_service=debug,warn")
|
||||
.json()
|
||||
.init();
|
||||
// Initialize observability (JSON logging + OpenTelemetry tracing via OTLP)
|
||||
let otlp_endpoint = std::env::var("OTEL_EXPORTER_OTLP_ENDPOINT")
|
||||
.unwrap_or_else(|_| "http://localhost:4317".to_string());
|
||||
if let Err(e) = common::observability::init_observability("trading_agent", &otlp_endpoint).await {
|
||||
eprintln!("Failed to initialize observability: {}", e);
|
||||
}
|
||||
|
||||
info!("Starting Trading Agent Service...");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user