Skip to content
bitzorcas
中EN

Reference

End-to-End Observability and Structured Auditing with OpenTelemetry

Explore the BitzOrcas.Modern observability engine. Learn OpenTelemetry distributed tracing, metrics export, and ActivityAudit pipeline audit trails.

Last updated

In modular monoliths and microservices, diagnosing latency spikes or intermittent failures without observability is frustrating:

  • Relying on brittle grep commands across unstructured text files;
  • Unable to pinpoint whether slow requests stem from SQL execution, Redis locks, or third-party gateways.

BitzOrcas.Modern includes native OpenTelemetry standards + automated audit pipelines: Inbound requests automatically generate a global TraceId propagated across service boundaries.

End-to-End Observability Topology

1. Inbound Request

2. OpenTelemetry Tracing (Injects TraceId & Spans)

3. Logging & ActivityAudit Pipelines

4. Business Handler Execution

5. DB / Redis (Automated Child Spans)

6. Persist Audit Entry to SysAuditLog

7. OTLP Export to Prometheus / Jaeger / Grafana


Step 1: Structured Logging in Business Handlers

Never concatenate strings in log calls. Use structured placeholders so TenantId, UserId, and TraceId attach automatically:

ProcessPaymentCommandHandler.cs: Structured Logging
using Microsoft.Extensions.Logging;
public sealed class ProcessPaymentCommandHandler(
ILogger<ProcessPaymentCommandHandler> logger)
{
public async ValueTask<Result> Handle(ProcessPaymentCommand command, CancellationToken ct)
{
// Structured logging with named parameters
logger.LogInformation(
"Processing payment transaction: Order {OrderId}, Amount {Amount} {Currency}",
command.OrderId,
command.Amount,
command.Currency);
// Simulate payment processing
await Task.Delay(10, ct);
logger.LogInformation("Payment transaction completed successfully for Order {OrderId}", command.OrderId);
return Result.Success();
}
}

Step 2: Automated Audit Capture (ActivityAuditPipelineBehavior)

Mutating commands pass through ActivityAuditPipelineBehavior, recording audit metadata:

Persisted Audit Record
// Structured audit entity: captured automatically by ActivityAuditPipelineBehavior
public sealed class SysAuditRecord
{
// Primary audit key and OpenTelemetry distributed TraceId
public string Id { get; set; } = Guid.NewGuid().ToString("N");
public string TraceId { get; set; } = "4bf92f3577b34da6a3ce929d0e0e4736";
public string ActionName { get; set; } = "Ordering.CreateOrder";
public string OperatorId { get; set; } = "user-1001";
public string TenantId { get; set; } = "tenant-test";
public long DurationMs { get; set; } = 42;
public string Status { get; set; } = "Success";
}

Summary

OpenTelemetry and structured auditing secure enterprise workloads:

  • Instant Root Cause Analysis: Full span timing breakdowns per request;
  • Tamper-Proof Audit Trails: Operator, timestamp, and result auditing;
  • Cloud-Native Standards: Zero-code export to Prometheus, Grafana, and Jaeger.

100%

Scroll or use controls to zoom · drag when enlarged · double-click for 100% / 200%