Exemple #1
0
        public IOperation CreateOperation(string operationName, byte[] correlationContext)
        {
            try
            {
                byte[]             capturedCorrelationContext = this.CorrelationContext.Capture();
                CorrelationContext localCorrelationcontext    = new CorrelationContext(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. c7eyVLlbyUM");
                    operationName = "ERR_NO_OPERATION_NAME " + newOperationIdString;
                }

                string cc = localCorrelationcontext.ToString();

                this.CorrelationContext = localCorrelationcontext;

                IOperation createdOperation = new ApplicationInsightsOperation(this, operationName, newOperationId.GetBase64String(), cc);

                return(createdOperation);
            }
            catch (Exception ex)
            {
                DiagnosticTrace.Instance.Error("An unexpected error occurred when attempting to create an operation", ex, "7AKlKXaBwkM");

                return(new NullOperation());
            }
        }
Exemple #2
0
        /// <summary>
        /// Creates a new operation.
        /// </summary>
        /// <param name="operationName">The name of the operation to create.</param>
        /// <param name="parentContext">Create an operation using another context for the duration of the operation.</param>
        /// <returns>A correlated Operation.</returns>

        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. m7x/mk3e30M");
                    operationName = "ERR_NO_OPERATION_NAME " + newOperationIdString;
                }

                string cc = localCorrelationcontext.ToString();

                this.CorrelationContext = localCorrelationcontext;

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

                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());
            }
        }
Exemple #3
0
        public IOperation CreateOperation(string operationName, byte[] parentContext)
        {
            try
            {
                byte[] capturedCorrelationContext = this.CorrelationContext.Capture();

                CorrelationContext localCorrelationcontext = new CorrelationContext(parentContext);

                long   newOperationId = localCorrelationcontext.AddOperation();
                string cc             = localCorrelationcontext.ToString();

                this.CorrelationContext = localCorrelationcontext;

                IOperation createdOperation = new TestOperation(this, operationName, newOperationId.GetBase64String(), 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());
            }
        }