[model-gateway] reorganize metrics, logging, and otel to its own module (#14590)
This commit is contained in:
@@ -659,7 +659,7 @@ impl Router {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn start(&self) -> PyResult<()> {
|
fn start(&self) -> PyResult<()> {
|
||||||
use metrics::PrometheusConfig;
|
use observability::metrics::PrometheusConfig;
|
||||||
|
|
||||||
let router_config = self.to_router_config().map_err(|e| {
|
let router_config = self.to_router_config().map_err(|e| {
|
||||||
pyo3::exceptions::PyValueError::new_err(format!("Configuration error: {}", e))
|
pyo3::exceptions::PyValueError::new_err(format!("Configuration error: {}", e))
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ use crate::{
|
|||||||
WorkflowContext, WorkflowEngine, WorkflowId, WorkflowInstanceId, WorkflowStatus,
|
WorkflowContext, WorkflowEngine, WorkflowId, WorkflowInstanceId, WorkflowStatus,
|
||||||
},
|
},
|
||||||
mcp::McpConfig,
|
mcp::McpConfig,
|
||||||
metrics::RouterMetrics,
|
observability::metrics::RouterMetrics,
|
||||||
protocols::worker_spec::{JobStatus, WorkerConfigRequest},
|
protocols::worker_spec::{JobStatus, WorkerConfigRequest},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ use super::{
|
|||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
core::{BasicWorkerBuilder, CircuitState, DPAwareWorkerBuilder},
|
core::{BasicWorkerBuilder, CircuitState, DPAwareWorkerBuilder},
|
||||||
metrics::RouterMetrics,
|
observability::metrics::RouterMetrics,
|
||||||
protocols::worker_spec::WorkerInfo,
|
protocols::worker_spec::WorkerInfo,
|
||||||
routers::grpc::client::GrpcClient,
|
routers::grpc::client::GrpcClient,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,15 +1,12 @@
|
|||||||
pub mod app_context;
|
pub mod app_context;
|
||||||
pub mod config;
|
pub mod config;
|
||||||
pub mod logging;
|
|
||||||
|
|
||||||
pub mod core;
|
pub mod core;
|
||||||
pub mod data_connector;
|
pub mod data_connector;
|
||||||
pub mod grpc_client;
|
pub mod grpc_client;
|
||||||
pub mod mcp;
|
pub mod mcp;
|
||||||
pub mod metrics;
|
|
||||||
pub mod middleware;
|
pub mod middleware;
|
||||||
pub mod multimodal;
|
pub mod multimodal;
|
||||||
pub mod otel_trace;
|
pub mod observability;
|
||||||
pub mod policies;
|
pub mod policies;
|
||||||
pub mod protocols;
|
pub mod protocols;
|
||||||
pub mod reasoning_parser;
|
pub mod reasoning_parser;
|
||||||
|
|||||||
@@ -8,8 +8,10 @@ use sgl_model_gateway::{
|
|||||||
RouterConfig, RoutingMode, TokenizerCacheConfig, TraceConfig,
|
RouterConfig, RoutingMode, TokenizerCacheConfig, TraceConfig,
|
||||||
},
|
},
|
||||||
core::ConnectionMode,
|
core::ConnectionMode,
|
||||||
metrics::PrometheusConfig,
|
observability::{
|
||||||
otel_trace::{is_otel_enabled, shutdown_otel},
|
metrics::PrometheusConfig,
|
||||||
|
otel_trace::{is_otel_enabled, shutdown_otel},
|
||||||
|
},
|
||||||
server::{self, ServerConfig},
|
server::{self, ServerConfig},
|
||||||
service_discovery::ServiceDiscoveryConfig,
|
service_discovery::ServiceDiscoveryConfig,
|
||||||
version,
|
version,
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ use tracing::{debug, error, field::Empty, info, info_span, warn, Span};
|
|||||||
|
|
||||||
pub use crate::core::token_bucket::TokenBucket;
|
pub use crate::core::token_bucket::TokenBucket;
|
||||||
use crate::{
|
use crate::{
|
||||||
metrics::RouterMetrics,
|
observability::metrics::RouterMetrics,
|
||||||
server::AppState,
|
server::AppState,
|
||||||
wasm::{
|
wasm::{
|
||||||
module::{MiddlewareAttachPoint, WasmModuleAttachPoint},
|
module::{MiddlewareAttachPoint, WasmModuleAttachPoint},
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use tracing::{debug, event, Level};
|
use tracing::{debug, event, Level};
|
||||||
|
|
||||||
use crate::otel_trace::is_otel_enabled;
|
use crate::observability::otel_trace::is_otel_enabled;
|
||||||
|
|
||||||
pub fn get_module_path() -> &'static str {
|
pub fn get_module_path() -> &'static str {
|
||||||
module_path!()
|
module_path!()
|
||||||
@@ -10,7 +10,8 @@ use tracing_subscriber::{
|
|||||||
fmt::time::ChronoUtc, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Layer,
|
fmt::time::ChronoUtc, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Layer,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{config::TraceConfig, otel_trace::get_otel_layer};
|
use super::otel_trace::get_otel_layer;
|
||||||
|
use crate::config::TraceConfig;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct LoggingConfig {
|
pub struct LoggingConfig {
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
//! Observability utilities for logging, metrics, and tracing.
|
||||||
|
|
||||||
|
pub mod events;
|
||||||
|
pub mod logging;
|
||||||
|
pub mod metrics;
|
||||||
|
pub mod otel_trace;
|
||||||
+1
-1
@@ -25,7 +25,7 @@ use tracing_subscriber::{
|
|||||||
Layer,
|
Layer,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::routers::http::events::get_module_path as http_router_get_module_path;
|
use super::events::get_module_path as http_router_get_module_path;
|
||||||
|
|
||||||
static ENABLED: AtomicBool = AtomicBool::new(false);
|
static ENABLED: AtomicBool = AtomicBool::new(false);
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ use rand::Rng;
|
|||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
use super::{get_healthy_worker_indices, tree::Tree, CacheAwareConfig, LoadBalancingPolicy};
|
use super::{get_healthy_worker_indices, tree::Tree, CacheAwareConfig, LoadBalancingPolicy};
|
||||||
use crate::{core::Worker, metrics::RouterMetrics};
|
use crate::{core::Worker, observability::metrics::RouterMetrics};
|
||||||
|
|
||||||
/// Cache-aware routing policy
|
/// Cache-aware routing policy
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use rand::Rng;
|
|||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|
||||||
use super::{get_healthy_worker_indices, LoadBalancingPolicy};
|
use super::{get_healthy_worker_indices, LoadBalancingPolicy};
|
||||||
use crate::{core::Worker, metrics::RouterMetrics};
|
use crate::{core::Worker, observability::metrics::RouterMetrics};
|
||||||
|
|
||||||
/// Power-of-two choices policy
|
/// Power-of-two choices policy
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use std::sync::Arc;
|
|||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
|
||||||
use super::{get_healthy_worker_indices, LoadBalancingPolicy};
|
use super::{get_healthy_worker_indices, LoadBalancingPolicy};
|
||||||
use crate::{core::Worker, metrics::RouterMetrics};
|
use crate::{core::Worker, observability::metrics::RouterMetrics};
|
||||||
|
|
||||||
/// Random selection policy
|
/// Random selection policy
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use std::sync::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::{get_healthy_worker_indices, LoadBalancingPolicy};
|
use super::{get_healthy_worker_indices, LoadBalancingPolicy};
|
||||||
use crate::{core::Worker, metrics::RouterMetrics};
|
use crate::{core::Worker, observability::metrics::RouterMetrics};
|
||||||
|
|
||||||
/// Round-robin selection policy
|
/// Round-robin selection policy
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
//! HTTP router implementations
|
//! HTTP router implementations
|
||||||
|
|
||||||
pub mod events;
|
|
||||||
pub mod pd_router;
|
pub mod pd_router;
|
||||||
pub mod pd_types;
|
pub mod pd_types;
|
||||||
pub mod router;
|
pub mod router;
|
||||||
|
|||||||
@@ -14,17 +14,17 @@ use serde_json::{json, Value};
|
|||||||
use tokio_stream::wrappers::UnboundedReceiverStream;
|
use tokio_stream::wrappers::UnboundedReceiverStream;
|
||||||
use tracing::{debug, error, warn};
|
use tracing::{debug, error, warn};
|
||||||
|
|
||||||
use super::{
|
use super::pd_types::api_path;
|
||||||
events::{self, Event},
|
|
||||||
pd_types::api_path,
|
|
||||||
};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config::types::RetryConfig,
|
config::types::RetryConfig,
|
||||||
core::{
|
core::{
|
||||||
is_retryable_status, RetryExecutor, Worker, WorkerLoadGuard, WorkerRegistry, WorkerType,
|
is_retryable_status, RetryExecutor, Worker, WorkerLoadGuard, WorkerRegistry, WorkerType,
|
||||||
},
|
},
|
||||||
metrics::RouterMetrics,
|
observability::{
|
||||||
otel_trace::inject_trace_context_http,
|
events::{self, Event},
|
||||||
|
metrics::RouterMetrics,
|
||||||
|
otel_trace::inject_trace_context_http,
|
||||||
|
},
|
||||||
policies::{LoadBalancingPolicy, PolicyRegistry},
|
policies::{LoadBalancingPolicy, PolicyRegistry},
|
||||||
protocols::{
|
protocols::{
|
||||||
chat::{ChatCompletionRequest, ChatMessage, MessageContent},
|
chat::{ChatCompletionRequest, ChatMessage, MessageContent},
|
||||||
|
|||||||
@@ -15,14 +15,16 @@ use reqwest::Client;
|
|||||||
use tokio_stream::wrappers::UnboundedReceiverStream;
|
use tokio_stream::wrappers::UnboundedReceiverStream;
|
||||||
use tracing::{debug, error};
|
use tracing::{debug, error};
|
||||||
|
|
||||||
use super::events::{self, Event};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config::types::RetryConfig,
|
config::types::RetryConfig,
|
||||||
core::{
|
core::{
|
||||||
is_retryable_status, ConnectionMode, RetryExecutor, Worker, WorkerRegistry, WorkerType,
|
is_retryable_status, ConnectionMode, RetryExecutor, Worker, WorkerRegistry, WorkerType,
|
||||||
},
|
},
|
||||||
metrics::RouterMetrics,
|
observability::{
|
||||||
otel_trace::inject_trace_context_http,
|
events::{self, Event},
|
||||||
|
metrics::RouterMetrics,
|
||||||
|
otel_trace::inject_trace_context_http,
|
||||||
|
},
|
||||||
policies::PolicyRegistry,
|
policies::PolicyRegistry,
|
||||||
protocols::{
|
protocols::{
|
||||||
chat::ChatCompletionRequest,
|
chat::ChatCompletionRequest,
|
||||||
|
|||||||
@@ -32,10 +32,12 @@ use crate::{
|
|||||||
},
|
},
|
||||||
Job, JobQueue, JobQueueConfig, WorkerManager, WorkerType,
|
Job, JobQueue, JobQueueConfig, WorkerManager, WorkerType,
|
||||||
},
|
},
|
||||||
logging::{self, LoggingConfig},
|
|
||||||
metrics::{self, PrometheusConfig},
|
|
||||||
middleware::{self, AuthConfig, QueuedRequest},
|
middleware::{self, AuthConfig, QueuedRequest},
|
||||||
otel_trace,
|
observability::{
|
||||||
|
logging::{self, LoggingConfig},
|
||||||
|
metrics::{self, PrometheusConfig},
|
||||||
|
otel_trace,
|
||||||
|
},
|
||||||
protocols::{
|
protocols::{
|
||||||
chat::ChatCompletionRequest,
|
chat::ChatCompletionRequest,
|
||||||
classify::ClassifyRequest,
|
classify::ClassifyRequest,
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ use serial_test::serial;
|
|||||||
use sgl_model_gateway::{
|
use sgl_model_gateway::{
|
||||||
config::{RouterConfig, TraceConfig},
|
config::{RouterConfig, TraceConfig},
|
||||||
core::Job,
|
core::Job,
|
||||||
logging, otel_trace,
|
observability::{logging, otel_trace},
|
||||||
routers::RouterFactory,
|
routers::RouterFactory,
|
||||||
};
|
};
|
||||||
use tokio::sync::oneshot;
|
use tokio::sync::oneshot;
|
||||||
|
|||||||
Reference in New Issue
Block a user