Exemple #1
0
        public WrapperMap(IEnumerable <IWrapper> wrappers, IDefaultWrapper defaultWrapper, INoOpWrapper noOpWrapper)
        {
            _nonDefaultWrappers = wrappers
                                  .Where(wrapper => wrapper != null)
                                  .Where(wrapper => !(wrapper is IDefaultWrapper) && !(wrapper is INoOpWrapper))
                                  .ToList();

            _nonDefaultWrappers.Add(new AttachToAsyncWrapper());
            _nonDefaultWrappers.Add(new DetachWrapper());
            _nonDefaultWrappers.Add(new CustomSegmentWrapper());
            _nonDefaultWrappers.Add(new IgnoreTransactionWrapper());
            _nonDefaultWrappers.Add(new MultithreadedTrackingWrapper());
            _nonDefaultWrappers.Add(new OtherTransactionWrapper());

            // This allows instrumentation that does nothing other than to track the library version.
            _nonDefaultWrappers.Add(noOpWrapper);

            var defaultWrappers = new List <IDefaultWrapper> {
                defaultWrapper, new DefaultWrapperAsync()
            };

            _defaultWrappers = defaultWrappers;

            _noOpTrackedWrapper = new TrackedWrapper(noOpWrapper);

            if (wrappers.Count() == 0)
            {
                Log.Error("No wrappers were loaded.  The agent will not behave as expected.");
            }

            if (Log.IsFinestEnabled)
            {
                Log.Finest($"WrapperMap has NonDefaultWrappers: {string.Join(", ", _nonDefaultWrappers)}");
            }
        }
        public void SetUp()
        {
            _wrapperMap           = Mock.Create <IWrapperMap>();
            _agent                = Mock.Create <IAgent>();
            _configurationService = Mock.Create <IConfigurationService>();
            _agentHealthReporter  = Mock.Create <IAgentHealthReporter>();
            _agentTimerService    = Mock.Create <IAgentTimerService>();

            Mock.Arrange(() => _configurationService.Configuration.WrapperExceptionLimit).Returns(10);

            _defaultWrapper = Mock.Create <IDefaultWrapper>();
            _noOpWrapper    = Mock.Create <INoOpWrapper>();

            _transactionRequiredWrapper = Mock.Create <IWrapper>();
            Mock.Arrange(() => _transactionRequiredWrapper.IsTransactionRequired).Returns(true);

            _wrapperService = new WrapperService(_configurationService, _wrapperMap, _agent, _agentHealthReporter, _agentTimerService);
        }