Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="operationName">The name of the timed section</param>
        /// <param name="args">Any arguments useful for tracking the timed section</param>
        public TimedSection(String operationName, params Object[] args)
        {
            this._parentId = TimedSection._activeId?.Value;
            TimedSection._activeId.Value = $"{this.ID}";

            this._lastException = LastException.GetLastException();

            this._operation = TimedSection._client.StartOperation <DependencyTelemetry>(operationName, $"{this.ID}", this._parentId);
            this._operation.Telemetry.Sequence = $"{DateTime.UtcNow.Ticks}";
            this._operation.Telemetry.Type     = "TimedSection";
            this._operation.Telemetry.Data     = args.ToJSON(Newtonsoft.Json.Formatting.None);
        }
Exemple #2
0
        public void Dispose()
        {
            if (this._success != true)
            {
                var ex = LastException.GetLastException();

                // If an exception occurred, and it isn't the exception that was last thrown - flag a failure.
                if ((ex != null) && (ex != this._lastException))
                {
                    this._operation.Telemetry.Success    = false;
                    this._operation.Telemetry.ResultCode = ex.Message;
                }
            }

            TimedSection._client.StopOperation(this._operation);

            TimedSection._activeId.Value = this._parentId;
        }