Example #1
0
        public IOperation CreateOperation(string operationName, byte[] parentContext)
        {
            try
            {
                byte[] capturedCorrelationContext = this.CorrelationContext.Capture();

                CorrelationContext localCorrelationcontext = new CorrelationContext(parentContext);

                long newOperationId = localCorrelationcontext.AddOperation();

                string newOperationIdString = newOperationId.GetBase64String();
                if (string.IsNullOrWhiteSpace(operationName))
                {
                    Diag("Attempting to create operation with null name. Resetting to randomized value. 5NYq0XFr1UM");
                    operationName = "ERR_NO_OPERATION_NAME " + newOperationIdString;
                }

                string cc = localCorrelationcontext.ToString();

                this.CorrelationContext = localCorrelationcontext;

                IOperation createdOperation = new TraceOperation(this, operationName, newOperationIdString, cc);

                return(createdOperation);
            }
            catch (Exception ex)
            {
                DiagnosticTrace.Instance.Error("An unexpected error occurred when attempting to create an operation", ex, "cd11de1d-c4b6-406c-937e-37bc85eb4370");

                return(new NullOperation());
            }
        }
Example #2
0
        public IOperation CreateOperation(string operationName)
        {
            try
            {
                ICorrelationContext localCorrelationcontext = this.CorrelationContext;
                long newOperationId = localCorrelationcontext.AddOperation();

                string newOperationIdString = newOperationId.GetBase64String();
                if (string.IsNullOrWhiteSpace(operationName))
                {
                    Diag("Attempting to create operation with null name. Resetting to randomized value. 5NYq0XFr1UM");
                    operationName = "ERR_NO_OPERATION_NAME " + newOperationIdString;
                }

                string cc = localCorrelationcontext.ToString();

                this.CorrelationContext = localCorrelationcontext;

                IOperation createdOperation = new TraceOperation(this, operationName, newOperationIdString, cc);

                return(createdOperation);
            }
            catch (Exception ex)
            {
                DiagnosticTrace.Instance.Error("An unexpected error occurred when attempting to create an operation", ex, "1f3803c8-5a8c-4562-a96b-7069520d8e32");

                return(new NullOperation());
            }
        }