DSMs

Dynamic Stability Modules™

A proprietary technology framework designed to enhance reliability and performance of enterprise systems.

LEARN MORE
Automation

AI and LLM

Enhancing software code automation with AI and LLM can significantly improve efficiency, accuracy, and productivity in software development.

LEARN MORE
Schedule

Opening Hours

  • Monday - Friday9.00 AM - 5.00 PM (MST)
  • Saturday Closed
  • Sunday Closed
  • National Holidays Closed
LEARN MORE

We Are Always Ready to Help

#

We maintain access to some of the most talented people in the industry

DSM Emergency Help

We stand by our DSM platform and can jump in at any time to help trouble shoot any of your applications

Application Diagnostics

As part of our DSM guarantee we can take the data generated and provide Diagnostics and help trouble shoot imposible issues on your application.

Application Health Check

As a customer of Nuvol 9, our DSM platform will provide you with a free application health check.

Dynamic Stability Modules (DSM)

#

A lightweight envelope system for .NET that wraps every operation result with structured telemetry: timing, error codes, caller context, and trace headers.

What Are DSMs?

DSM (Dynamic Stability Modules) is a proprietary technology framework designed to enhance reliability and performance of enterprise systems. At its core, DSM provides a generic wrapper DSMEnvelope<T> around data and execution metadata that enables:

Automatic Execution Tracking

Every operation is automatically timed with precise start time, end time, and execution duration measured in milliseconds.

Distributed Tracing

Unique identifiers and HTTP trace headers enable tracking requests across microservices and distributed systems.

Rich Error Context

Captures exception details, standardized error codes, caller information including class, method, file path, and line number.

Parent-Child Relationships

Link nested operations for complete request traces with automatic header propagation through the call stack.

How DSM Envelopes Work

The DSM lifecycle follows a simple, consistent pattern:

1. Initialize

Create an envelope using InitWithCaller() (recommended for async) or Init(). The envelope captures caller information and starts timing immediately.

var envelope = DSMEnvelope<PersonDto>
    .InitWithCaller(nameof(PersonController))
    .CaptureAndSetHeaders(HttpContext);

2. Capture Headers

Automatically capture HTTP headers for distributed tracing:

  • Api-Trace-Id: Tracks requests across services
  • Idempotency-Key-Id: Ensures operation idempotency

3. Execute

Perform your business logic, then mark the operation as successful or capture exceptions:

// Success
envelope.Success(result);

// Error
catch (Exception ex) {
    envelope.CaptureException(ex);
}

4. Freeze (Optional)

Lock parent envelopes in a failure state when inner operations fail, preventing status changes and ensuring error propagation through the stack.

What Gets Captured

Each DSMEnvelope captures comprehensive metadata about the operation:

Identifiers & Tracing

  • UniqueIEID: GUID + process ID for unique identification
  • RootEnvelopID: AppId + hostname + timestamp + UTC offset + PID
  • ParentEnvelopID: Links nested operations for full trace hierarchy
  • ApiTraceId: HTTP trace header for distributed systems
  • IdempotencyKeyId: Idempotency header for operation safety

Execution Context

  • StartTime: Operation start timestamp
  • EndTime: Operation completion timestamp
  • ExecutionTime: Duration in milliseconds
  • Code: Structured status code with message
  • DTOMessage: Human-readable status message
  • CodeBlockInfo: Class, method, file path, and line number

Error Handling & Validation

DSM includes a comprehensive error code system and structured validation handling:

Standardized Error Codes

DSMEnvelopeCodeEnum defines codes for different error categories:

  • GEN_COMMON_00000: Success
  • API_COMMON_010XX: Security errors
  • API_APPVLD_020XX: Application validation errors (HTTP 400)
  • API_DATABASE_030XX: Database errors

Validation Error Collection

The ValidationErrorCollector provides fluent API for collecting field-level errors:

var validator = new ValidationErrorCollector()
    .ValidateRequired(request.Email, "email")
    .ValidateEmail(request.Email, "email")
    .ValidateLength(request.Name, "name", 2, 100);

if (validator.HasErrors()) {
    return envelope.ValidationFailed(validator);
}

Validation errors are structured as a dictionary mapping field names to error message lists, perfect for API responses.

Distributed Tracing & Nested Operations

DSM provides powerful capabilities for tracking operations across service boundaries:

DSMEnvelopeManager

A singleton stack-based manager for handling nested envelopes with automatic parent-child relationships:

// Initialize and push onto stack
var envelope = DSMEnvelopeManager.Instance
    .InitEnvelopeWithCaller<PersonDto>(
        nameof(PersonController), 
        httpContext: HttpContext
    );

// Headers automatically propagate to child operations
var childResult = await _service.GetData();

// Pop when done
DSMEnvelopeManager.Instance.PopEnvelope();

Freeze Stack on Error

When an error occurs in a nested operation, freeze the entire stack to prevent inconsistent states:

catch (Exception ex) {
    envelope.CaptureException(ex);
    DSMEnvelopeManager.Instance.FreezeStackWith(envelope);
}

AI/MCP/MLM Readiness

DSM envelopes create a high-fidelity event stream describing low-level execution, timing, error states, and call context. This structured data can be fed to AI/agent systems or Model Context Protocol (MCP) monitoring to:

  • Detect coding errors quickly through pattern recognition
  • Identify suspicious behavior or intrusion signals
  • Surface performance regressions in near real-time
  • Build automated diagnostics and recommendations
  • Enable predictive maintenance and proactive issue resolution

Use Cases

Debugging

Trace execution flow with precise timing and caller context for rapid root-cause analysis.

Security

Monitor for intrusion attempts and suspicious patterns through comprehensive operation logging.

Performance

Identify bottlenecks and regressions with millisecond-accurate execution time tracking.

Compliance

Maintain audit trails with immutable operation records including timestamps and user context.

Quick Start Example

Here's a complete example of using DSM in an ASP.NET Core controller:

[HttpGet("{id}")]
public async Task<ActionResult<DSMEnvelope<PersonDto>>> GetPerson(int id)
{
    var envelope = DSMEnvelope<PersonDto>
        .InitWithCaller(nameof(PersonController))
        .CaptureAndSetHeaders(HttpContext);
    
    try
    {
        var person = await _service.GetByIdAsync(id);
        if (person == null)
        {
            envelope.SetState(
                DSMEnvelopeCodeManager.Manager
                    .Find(DSMEnvelopeCodeEnum.API_APPVLD_02001),
                $"Person {id} not found"
            );
            return NotFound(envelope);
        }
        
        envelope.Success(person);
        return Ok(envelope);
    }
    catch (Exception ex)
    {
        envelope.CaptureException(ex);
        return StatusCode(500, envelope);
    }
}

Integration Options

ASP.NET Core Header Capture

Automatically captures HTTP headers from HttpContext for distributed tracing:

  • Api-Trace-Id propagation
  • Idempotency-Key-Id tracking
  • Fluent API integration

PostSharp Attribute (Automation)

DSMEnvelopeAttribute can auto-wrap methods at entry/exit:

  • Eliminates boilerplate code
  • Aspect-oriented programming approach
  • Automatic envelope lifecycle management

Output Formats

DSM provides multiple output formats for different use cases:

Console Output

Color-coded console output with comprehensive details for development and debugging. Yellow for initialized state, green for success, red for errors.

JSON Serialization

Call ToRawJson() to get JSON output perfect for logging pipelines, analytics systems, and AI/MCP integration.

Ready to Enhance Your Application Reliability?

Contact us today for a free consultation on how DSM can transform your application monitoring and debugging capabilities.

Contact Us