Dataverse Plug-in Tracing: Capture Actionable Diagnostics Without Leaking Data

Plug-in tracing records diagnostic messages that help developers investigate failures and execution paths. Good traces explain what the plug-in was doing, which branch ran and how to correlate the execution with a platform error.

Why this matters

Use ITracingService in Dataverse plug-ins to capture correlation IDs, execution context and diagnostic details while avoiding sensitive data exposure.

Step-by-step implementation

  1. Obtain ITracingService from the service provider at the beginning of Execute.
  2. Trace the plug-in name, message, stage, depth and correlation identifier to establish context.
  3. Add concise messages before and after important operations and include safe identifiers for relevant records.
  4. Catch exceptions only when you can add useful context; rethrow or wrap them appropriately so the platform reports failure.
  5. Configure plug-in trace logging deliberately and review retention and storage impact.

Code or policy example

var tracing = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
var context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
tracing.Trace("OrderPlugin start. Message={0}; Stage={1}; Depth={2}; Correlation={3}",
    context.MessageName, context.Stage, context.Depth, context.CorrelationId);
try
{
    // Execute business logic.
}
catch (Exception ex)
{
    tracing.Trace("OrderPlugin failed. Type={0}; Message={1}", ex.GetType().Name, ex.Message);
    throw;
}

Common mistakes to avoid

  • Do not trace passwords, access tokens, personal data or entire entity payloads.
  • Avoid verbose per-row tracing in high-volume plug-ins.
  • Do not swallow exceptions after tracing; ensure failure semantics remain correct.

Testing and validation

Trigger a controlled failure, locate the trace, correlate it to the plug-in error and confirm no sensitive values appear.

Conclusion

Build the operational safeguards alongside the implementation. Clear diagnostics, least privilege and deliberate retry behaviour make the solution easier to support in production.