Esempio n. 1
0
        public Task CaptureTransaction(string name, string type, Func <Task> func, DistributedTracingData distributedTracingData = null)
        {
            var transaction = StartTransaction(name, type, distributedTracingData);
            var task        = func();

            RegisterContinuation(task, transaction);
            return(task);
        }
Esempio n. 2
0
 public Task <T> CaptureTransaction <T>(string name, string type, Func <ITransaction, Task <T> > func,
                                        DistributedTracingData distributedTracingData = null) =>
 Task.Run(() =>
 {
     var transaction = StartTransaction(name, type, distributedTracingData);
     var task        = func(transaction);
     RegisterContinuation(task, transaction);
     return(task);
 });
Esempio n. 3
0
        public ITransaction StartTransaction(string name, string type, DistributedTracingData distributedTracingData = null,
                                             bool ignoreActivity = false
                                             )
        {
            if (_configProvider.CurrentSnapshot.Enabled && _configProvider.CurrentSnapshot.Recording)
            {
                return(StartTransactionInternal(name, type, distributedTracingData, ignoreActivity));
            }

            return(new NoopTransaction(name, type, CurrentExecutionSegmentsContainer));
        }
Esempio n. 4
0
        internal Transaction StartTransactionInternal(string name, string type, DistributedTracingData distributedTracingData = null)
        {
            var retVal = new Transaction(_logger, name, type, Sampler, distributedTracingData, _sender, _configurationReader,
                                         CurrentExecutionSegmentsContainer)
            {
                Service = _service
            };

            _logger.Debug()?.Log("Starting {TransactionValue}", retVal);
            return(retVal);
        }
Esempio n. 5
0
        public ITransaction StartTransaction(string name, string type, DistributedTracingData distributedTracingData = null,
                                             bool ignoreActivity = false, IEnumerable <SpanLink> links = null
                                             )
        {
            if (_configurationProvider.CurrentSnapshot.Enabled && _configurationProvider.CurrentSnapshot.Recording)
            {
                return(StartTransactionInternal(name, type, distributedTracingData, ignoreActivity, links: links));
            }

            return(new NoopTransaction(name, type, CurrentExecutionSegmentsContainer, _configurationProvider.CurrentSnapshot));
        }
        internal Transaction StartTransactionInternal(string name, string type, DistributedTracingData distributedTracingData = null)
        {
            var retVal = new Transaction(_logger, name, type, Sampler, distributedTracingData, _sender)
            {
                Service = _service
            };

            Agent.TransactionContainer.Transactions.Value = retVal;
            _logger.Debug()?.Log("Starting {TransactionValue}", retVal);
            return(retVal);
        }
        internal Transaction StartTransactionInternal(string name, string type, DistributedTracingData distributedTracingData = null, bool ignoreActivity = false)
        {
            var currentConfig = _configProvider.CurrentSnapshot;
            var retVal        = new Transaction(_logger, name, type, new Sampler(currentConfig.TransactionSampleRate), distributedTracingData
                                                , _sender, currentConfig, CurrentExecutionSegmentsContainer, ignoreActivity)
            {
                Service = _service
            };

            _logger.Debug()?.Log("Starting {TransactionValue}", retVal);
            return(retVal);
        }
Esempio n. 8
0
        private Transaction StartTransactionInternal(string name, string type, DistributedTracingData distributedTracingData = null,
                                                     bool ignoreActivity = false, long?timestamp = null, string id = null, string traceId = null
                                                     )
        {
            var currentConfig = _configurationProvider.CurrentSnapshot;
            var retVal        = new Transaction(_logger, name, type, new Sampler(currentConfig.TransactionSampleRate), distributedTracingData
                                                , _sender, currentConfig, CurrentExecutionSegmentsContainer, _apmServerInfo, _breakdownMetricsProvider, ignoreActivity, timestamp, id)
            {
                Service = _service
            };

            _logger.Debug()?.Log("Starting {TransactionValue}", retVal);
            return(retVal);
        }
Esempio n. 9
0
        public void CaptureTransaction(string name, string type, Action action, DistributedTracingData distributedTracingData = null)
        {
            var transaction = StartTransaction(name, type, distributedTracingData);

            try
            {
                action();
            }
            catch (Exception e) when(ExceptionFilter.Capture(e, transaction))
            {
            }
            finally
            {
                transaction.End();
            }
        }
Esempio n. 10
0
        public T CaptureTransaction <T>(string name, string type, Func <T> func, DistributedTracingData distributedTracingData = null)
        {
            var transaction = StartTransaction(name, type, distributedTracingData);
            var retVal      = default(T);

            try
            {
                retVal = func();
            }
            catch (Exception e) when(ExceptionFilter.Capture(e, transaction))
            {
            }
            finally
            {
                transaction.End();
            }

            return(retVal);
        }
Esempio n. 11
0
 public ITransaction StartTransaction(string name, string type, DistributedTracingData distributedTracingData = null) =>
 StartTransactionInternal(name, type, distributedTracingData);
Esempio n. 12
0
        public void CaptureTransaction(string name, string type, Action <ITransaction> action, DistributedTracingData distributedTracingData = null, IEnumerable <SpanLink> links = null)
        {
            var transaction = StartTransaction(name, type, distributedTracingData, links: links);

            try
            {
                action(transaction);
            }
            catch (Exception e) when(ExceptionFilter.Capture(e, transaction))
            {
            }
            finally
            {
                transaction.End();
            }
        }
Esempio n. 13
0
 internal Transaction StartTransactionInternal(string name, string type,
                                               long?timestamp = null, bool ignoreActivity = false, string id = null, string traceId = null,
                                               DistributedTracingData distributedTracingData = null,
                                               IEnumerable <SpanLink> links = null
                                               )
 => StartTransactionInternal(name, type, distributedTracingData, ignoreActivity, timestamp, id, traceId, links);
Esempio n. 14
0
        public async Task <T> CaptureTransaction <T>(string name, string type, Func <Task <T> > func, DistributedTracingData distributedTracingData = null, IEnumerable <SpanLink> links = null)
        {
            var transaction = StartTransaction(name, type, distributedTracingData, links: links);

            try
            {
                return(await func());
            }
            catch (OperationCanceledException ex)
            {
                transaction.CaptureError("Task canceled", "A task was canceled", new StackTrace(ex).GetFrames());

                throw;
            }
            catch (Exception e) when(ExceptionFilter.Capture(e, transaction))
            {
            }
            finally
            {
                transaction.End();
            }
            return(default);
Esempio n. 15
0
 public ITransaction StartTransaction(string name, string type, DistributedTracingData distributedTracingData = null, bool ignoreActivity = false) =>
 StartTransactionInternal(name, type, distributedTracingData, ignoreActivity);