pub struct TracingConfig {
pub log_statements: bool,
pub log_parameters: bool,
pub slow_query_threshold: Duration,
pub record_row_counts: bool,
pub target: &'static str,
pub database_name: Option<String>,
pub server_address: Option<String>,
pub server_port: Option<u16>,
pub peer_service: Option<String>,
}Expand description
Configuration options for database tracing.
§Example
use sea_orm_tracing::TracingConfig;
use std::time::Duration;
let config = TracingConfig::default()
.with_statement_logging(true)
.with_slow_query_threshold(Duration::from_millis(100));Fields§
§log_statements: boolWhether to include the SQL statement in spans.
Default: false (for security - prevents accidental credential logging)
log_parameters: boolWhether to include query parameters in spans.
Default: false (parameters may contain sensitive data)
slow_query_threshold: DurationThreshold for logging slow queries at WARN level. Queries exceeding this duration will be logged with additional context. Default: 500ms
record_row_counts: boolWhether to record the number of rows affected/returned.
Default: true
target: &'static strTarget name for tracing events. Default: “sea_orm_tracing”
database_name: Option<String>Custom database name to include in spans (useful for multi-database setups).
Default: None
server_address: Option<String>Server address (hostname) for the database.
Used by X-Ray and other APM tools to show the database as a separate node on the service map.
Default: None
server_port: Option<u16>Server port for the database.
Default: None
peer_service: Option<String>Peer service name for the database.
This is used by X-Ray to display the database as a named node on the trace map.
If not set, X-Ray will use server_address if available.
Default: None
Implementations§
Source§impl TracingConfig
impl TracingConfig
Sourcepub fn with_statement_logging(self, enabled: bool) -> Self
pub fn with_statement_logging(self, enabled: bool) -> Self
Enable or disable SQL statement logging in spans.
Security Warning: Enabling this may expose sensitive data in your traces if your queries contain credentials or PII in the SQL text itself.
Sourcepub fn with_parameter_logging(self, enabled: bool) -> Self
pub fn with_parameter_logging(self, enabled: bool) -> Self
Enable or disable parameter logging in spans.
Security Warning: Query parameters often contain user input and potentially sensitive data. Only enable in development or controlled environments.
Sourcepub fn with_slow_query_threshold(self, threshold: Duration) -> Self
pub fn with_slow_query_threshold(self, threshold: Duration) -> Self
Set the threshold for slow query warnings.
Queries taking longer than this duration will be logged at WARN level
with the slow_query field set to true.
Sourcepub fn with_row_count_recording(self, enabled: bool) -> Self
pub fn with_row_count_recording(self, enabled: bool) -> Self
Enable or disable row count recording.
Sourcepub fn with_target(self, target: &'static str) -> Self
pub fn with_target(self, target: &'static str) -> Self
Set a custom tracing target name.
Sourcepub fn with_database_name(self, name: impl Into<String>) -> Self
pub fn with_database_name(self, name: impl Into<String>) -> Self
Set a database name to include in spans.
Useful when your application connects to multiple databases.
Sourcepub fn with_server_address(self, address: impl Into<String>) -> Self
pub fn with_server_address(self, address: impl Into<String>) -> Self
Set the server address (hostname) for the database.
This enables APM tools like AWS X-Ray to show the database as a separate node on the service/trace map.
Sourcepub fn with_server_port(self, port: u16) -> Self
pub fn with_server_port(self, port: u16) -> Self
Set the server port for the database.
Sourcepub fn with_peer_service(self, name: impl Into<String>) -> Self
pub fn with_peer_service(self, name: impl Into<String>) -> Self
Set the peer service name for the database.
This is used by AWS X-Ray and other APM tools to display the database as a named node on the trace map. Common values: “postgresql”, “mysql”, or a custom name like “users-db”.
Sourcepub fn development() -> Self
pub fn development() -> Self
Create a development-friendly configuration with full logging enabled.
Warning: Do not use in production as it logs all SQL and parameters.
Sourcepub fn production() -> Self
pub fn production() -> Self
Create a production-safe configuration with minimal overhead.
Trait Implementations§
Source§impl Clone for TracingConfig
impl Clone for TracingConfig
Source§fn clone(&self) -> TracingConfig
fn clone(&self) -> TracingConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more