TracingConfig

Struct TracingConfig 

Source
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: bool

Whether to include the SQL statement in spans. Default: false (for security - prevents accidental credential logging)

§log_parameters: bool

Whether to include query parameters in spans. Default: false (parameters may contain sensitive data)

§slow_query_threshold: Duration

Threshold for logging slow queries at WARN level. Queries exceeding this duration will be logged with additional context. Default: 500ms

§record_row_counts: bool

Whether to record the number of rows affected/returned. Default: true

§target: &'static str

Target 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

Source

pub fn new() -> Self

Create a new configuration with default values.

Source

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.

Source

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.

Source

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.

Source

pub fn with_row_count_recording(self, enabled: bool) -> Self

Enable or disable row count recording.

Source

pub fn with_target(self, target: &'static str) -> Self

Set a custom tracing target name.

Source

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.

Source

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.

Source

pub fn with_server_port(self, port: u16) -> Self

Set the server port for the database.

Source

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”.

Source

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.

Source

pub fn production() -> Self

Create a production-safe configuration with minimal overhead.

Trait Implementations§

Source§

impl Clone for TracingConfig

Source§

fn clone(&self) -> TracingConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TracingConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TracingConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more