setModule method
Set module name for end-to-end application tracing.
Sets the current application module name that appears in V$SESSION. Used to identify which part of your application is executing operations.
Parameters:
module: Module name (e.g., 'OrderProcessing', 'ReportGenerator')
Example - Module Tracking:
// In order processing module
await connection.setModule('OrderProcessing');
await connection.setAction('CreateOrder');
await connection.executeUpdate('INSERT INTO orders ...');
// Switch to inventory module
await connection.setModule('InventoryManagement');
await connection.setAction('UpdateStock');
await connection.executeUpdate('UPDATE inventory ...');
// DBA can monitor:
// SELECT module, action, sql_text FROM v$session WHERE ...
Example - Performance Monitoring:
Future<void> generateReport(String reportType) async {
await connection.setModule('ReportGenerator');
await connection.setAction('Generate_$reportType');
// Execute report queries
final data = await connection.query('SELECT ...');
// Clear action when done
await connection.setAction('Idle');
}
Use Cases:
- Performance monitoring by application module
- Resource usage tracking per feature
- Troubleshooting slow operations
- Identifying bottlenecks in specific modules
See also:
- setAction to set the action within a module
- setClientIdentifier to identify the end user
- setDbOp to set the database operation name
Implementation
Future<void> setModule(String module) async {
_ensureConnected();
final (moduleNative, moduleLen) = StringUtils.toNativeUtf8WithLength(module, _memoryManager);
final result = _dpiOracle.dpiConn_setModule(
_connectionPtr.value,
moduleNative,
moduleLen,
);
if (result == DPI_FAILURE) {
throw OracleConnectionException('Failed to set module');
}
}