[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<()> {
|
||||
use metrics::PrometheusConfig;
|
||||
use observability::metrics::PrometheusConfig;
|
||||
|
||||
let router_config = self.to_router_config().map_err(|e| {
|
||||
pyo3::exceptions::PyValueError::new_err(format!("Configuration error: {}", e))
|
||||
|
||||
@@ -24,7 +24,7 @@ use crate::{
|
||||
WorkflowContext, WorkflowEngine, WorkflowId, WorkflowInstanceId, WorkflowStatus,
|
||||
},
|
||||
mcp::McpConfig,
|
||||
metrics::RouterMetrics,
|
||||
observability::metrics::RouterMetrics,
|
||||
protocols::worker_spec::{JobStatus, WorkerConfigRequest},
|
||||
};
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ use super::{
|
||||
};
|
||||
use crate::{
|
||||
core::{BasicWorkerBuilder, CircuitState, DPAwareWorkerBuilder},
|
||||
metrics::RouterMetrics,
|
||||
observability::metrics::RouterMetrics,
|
||||
protocols::worker_spec::WorkerInfo,
|
||||
routers::grpc::client::GrpcClient,
|
||||
};
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
pub mod app_context;
|
||||
pub mod config;
|
||||
pub mod logging;
|
||||
|
||||
pub mod core;
|
||||
pub mod data_connector;
|
||||
pub mod grpc_client;
|
||||
pub mod mcp;
|
||||
pub mod metrics;
|
||||
pub mod middleware;
|
||||
pub mod multimodal;
|
||||
pub mod otel_trace;
|
||||
pub mod observability;
|
||||
pub mod policies;
|
||||
pub mod protocols;
|
||||
pub mod reasoning_parser;
|
||||
|
||||
@@ -8,8 +8,10 @@ use sgl_model_gateway::{
|
||||
RouterConfig, RoutingMode, TokenizerCacheConfig, TraceConfig,
|
||||
},
|
||||
core::ConnectionMode,
|
||||
metrics::PrometheusConfig,
|
||||
otel_trace::{is_otel_enabled, shutdown_otel},
|
||||
observability::{
|
||||
metrics::PrometheusConfig,
|
||||
otel_trace::{is_otel_enabled, shutdown_otel},
|
||||
},
|
||||
server::{self, ServerConfig},
|
||||
service_discovery::ServiceDiscoveryConfig,
|
||||
version,
|
||||
|
||||
@@ -22,7 +22,7 @@ use tracing::{debug, error, field::Empty, info, info_span, warn, Span};
|
||||
|
||||
pub use crate::core::token_bucket::TokenBucket;
|
||||
use crate::{
|
||||
metrics::RouterMetrics,
|
||||
observability::metrics::RouterMetrics,
|
||||
server::AppState,
|
||||
wasm::{
|
||||
module::{MiddlewareAttachPoint, WasmModuleAttachPoint},
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
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 {
|
||||
module_path!()
|
||||
@@ -10,7 +10,8 @@ use tracing_subscriber::{
|
||||
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)]
|
||||
pub struct LoggingConfig {
|
||||
6
sgl-model-gateway/src/observability/mod.rs
Normal file
6
sgl-model-gateway/src/observability/mod.rs
Normal file
@@ -0,0 +1,6 @@
|
||||
//! Observability utilities for logging, metrics, and tracing.
|
||||
|
||||
pub mod events;
|
||||
pub mod logging;
|
||||
pub mod metrics;
|
||||
pub mod otel_trace;
|
||||
@@ -25,7 +25,7 @@ use tracing_subscriber::{
|
||||
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);
|
||||
|
||||
@@ -66,7 +66,7 @@ use rand::Rng;
|
||||
use tracing::debug;
|
||||
|
||||
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
|
||||
///
|
||||
|
||||
@@ -9,7 +9,7 @@ use rand::Rng;
|
||||
use tracing::info;
|
||||
|
||||
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
|
||||
///
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::sync::Arc;
|
||||
use rand::Rng;
|
||||
|
||||
use super::{get_healthy_worker_indices, LoadBalancingPolicy};
|
||||
use crate::{core::Worker, metrics::RouterMetrics};
|
||||
use crate::{core::Worker, observability::metrics::RouterMetrics};
|
||||
|
||||
/// Random selection policy
|
||||
///
|
||||
|
||||
@@ -6,7 +6,7 @@ use std::sync::{
|
||||
};
|
||||
|
||||
use super::{get_healthy_worker_indices, LoadBalancingPolicy};
|
||||
use crate::{core::Worker, metrics::RouterMetrics};
|
||||
use crate::{core::Worker, observability::metrics::RouterMetrics};
|
||||
|
||||
/// Round-robin selection policy
|
||||
///
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
//! HTTP router implementations
|
||||
|
||||
pub mod events;
|
||||
pub mod pd_router;
|
||||
pub mod pd_types;
|
||||
pub mod router;
|
||||
|
||||
@@ -14,17 +14,17 @@ use serde_json::{json, Value};
|
||||
use tokio_stream::wrappers::UnboundedReceiverStream;
|
||||
use tracing::{debug, error, warn};
|
||||
|
||||
use super::{
|
||||
events::{self, Event},
|
||||
pd_types::api_path,
|
||||
};
|
||||
use super::pd_types::api_path;
|
||||
use crate::{
|
||||
config::types::RetryConfig,
|
||||
core::{
|
||||
is_retryable_status, RetryExecutor, Worker, WorkerLoadGuard, WorkerRegistry, WorkerType,
|
||||
},
|
||||
metrics::RouterMetrics,
|
||||
otel_trace::inject_trace_context_http,
|
||||
observability::{
|
||||
events::{self, Event},
|
||||
metrics::RouterMetrics,
|
||||
otel_trace::inject_trace_context_http,
|
||||
},
|
||||
policies::{LoadBalancingPolicy, PolicyRegistry},
|
||||
protocols::{
|
||||
chat::{ChatCompletionRequest, ChatMessage, MessageContent},
|
||||
|
||||
@@ -15,14 +15,16 @@ use reqwest::Client;
|
||||
use tokio_stream::wrappers::UnboundedReceiverStream;
|
||||
use tracing::{debug, error};
|
||||
|
||||
use super::events::{self, Event};
|
||||
use crate::{
|
||||
config::types::RetryConfig,
|
||||
core::{
|
||||
is_retryable_status, ConnectionMode, RetryExecutor, Worker, WorkerRegistry, WorkerType,
|
||||
},
|
||||
metrics::RouterMetrics,
|
||||
otel_trace::inject_trace_context_http,
|
||||
observability::{
|
||||
events::{self, Event},
|
||||
metrics::RouterMetrics,
|
||||
otel_trace::inject_trace_context_http,
|
||||
},
|
||||
policies::PolicyRegistry,
|
||||
protocols::{
|
||||
chat::ChatCompletionRequest,
|
||||
|
||||
@@ -32,10 +32,12 @@ use crate::{
|
||||
},
|
||||
Job, JobQueue, JobQueueConfig, WorkerManager, WorkerType,
|
||||
},
|
||||
logging::{self, LoggingConfig},
|
||||
metrics::{self, PrometheusConfig},
|
||||
middleware::{self, AuthConfig, QueuedRequest},
|
||||
otel_trace,
|
||||
observability::{
|
||||
logging::{self, LoggingConfig},
|
||||
metrics::{self, PrometheusConfig},
|
||||
otel_trace,
|
||||
},
|
||||
protocols::{
|
||||
chat::ChatCompletionRequest,
|
||||
classify::ClassifyRequest,
|
||||
|
||||
@@ -20,7 +20,7 @@ use serial_test::serial;
|
||||
use sgl_model_gateway::{
|
||||
config::{RouterConfig, TraceConfig},
|
||||
core::Job,
|
||||
logging, otel_trace,
|
||||
observability::{logging, otel_trace},
|
||||
routers::RouterFactory,
|
||||
};
|
||||
use tokio::sync::oneshot;
|
||||
|
||||
Reference in New Issue
Block a user