private void AddPluginExecutionContextDetails(int stage, IPluginExecutionContext executionContext) { this.EventProperties.Source = "Plug-in"; this.EventProperties.Stage = AiProperties.GetStageName(stage); if (executionContext == null) { return; } this.EventProperties.ParentCorrelationId = (executionContext?.ParentContext?.CorrelationId ?? executionContext?.CorrelationId).ToString(); // this.AddPluginExecutionHistory(executionContext); }
private void AddPluginExecutionHistory(IPluginExecutionContext executionContext) { // This doesn't work... need to figure out something that can work here. DateTime?end = null; if (!executionContext.SharedVariables.ContainsKey("StartedOn")) { executionContext.SharedVariables.Add("StartedOn", DateTime.UtcNow); } else { end = (DateTime?)executionContext.SharedVariables["StartedOn"]; } var past = new Stack <AiPluginProperties>(); if (this.EventProperties.Depth > 1) { var currentContext = executionContext; var last = currentContext; while (currentContext != null) { past.Push( new AiPluginProperties { OperationId = currentContext.OperationId.ToString(), ImpersonatingUserId = currentContext.UserId.ToString(), CorrelationId = currentContext.CorrelationId.ToString(), Message = currentContext.MessageName, Mode = AiProperties.GetModeName(currentContext.Mode), Depth = currentContext.Depth, EntityId = currentContext.PrimaryEntityId.ToString(), EntityName = currentContext.PrimaryEntityName, Stage = AiProperties.GetStageName(currentContext.Stage), ParentCorrelationId = currentContext.ParentContext?.CorrelationId.ToString(), OperationCreatedOn = currentContext.OperationCreatedOn.ToUniversalTime() .ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'") }); last = currentContext; currentContext = currentContext.ParentContext; } var span = DateTime.UtcNow - (end ?? last.OperationCreatedOn.ToUniversalTime()); this.WriteMetric("BackendDuration", span.TotalMilliseconds); this.EventProperties.History = past.ToArray(); this.EventProperties.Duration = span.TotalMilliseconds.ToString(); } }
private void AddPluginExecutionContextDetails(int stage) { _eventProperties.Source = "Plug-in"; _eventProperties.Stage = AiProperties.GetStageName(stage); }