Exemple #1
0
 public override void Before(MethodInfo methodUnderTest)
 {
     _tracer            = Tracer.Instance;
     _tracerManager     = _tracer.TracerManager;
     _distributedTracer = ClrProfiler.DistributedTracer.Instance;
     base.Before(methodUnderTest);
 }
Exemple #2
0
        public static void Initialize()
        {
            if (Interlocked.Exchange(ref _firstInitialization, 0) != 1)
            {
                // Initialize() was already called before
                return;
            }

            Log.Information("Initializing CI Visibility");

            LifetimeManager.Instance.AddAsyncShutdownTask(ShutdownAsync);

            TracerSettings tracerSettings = _settings.TracerSettings;

            // Set the service name if empty
            Log.Information("Setting up the service name");
            if (string.IsNullOrEmpty(tracerSettings.ServiceName))
            {
                // Extract repository name from the git url and use it as a default service name.
                tracerSettings.ServiceName = GetServiceNameFromRepository(CIEnvironmentValues.Instance.Repository);
            }

            // Initialize Tracer
            Log.Information("Initialize Test Tracer instance");
            TracerManager.ReplaceGlobalManager(tracerSettings.Build(), new CITracerManagerFactory(_settings));
        }
 protected BaseGameBehaviour()
 {
     this.iPlayerTurn       = 1;
     this.iCurrentRound     = 1;
     this.allRoundsComplete = false;
     this.players           = new List <PLAYER>();
     this.previousBalls     = new List <CBall>(50);
     this.tee               = GameObject.FindGameObjectWithTag("Tee");
     this.pin               = GameObject.FindGameObjectWithTag("Pin");
     this.uiDialsHUD        = CGameManager.instance.UiHolder.UiDialsParent;
     this.golfCameraManager = CGameManager.instance.UiHolder.GolfCamera;
     //this._gameExitPanel = CGameManager.instance.UiHolder.GameExitPanel;
     //this.uiPillPanel = CGameManager.instance.UiHolder.PrePostPill;
     //this.clubPopUpManager = CGameManager.instance.UiHolder.ClubPopUpManager;
     this.uiClubSelect = this.clubPopUpManager.gameObject;
     //this.numericDisplays = CGameManager.instance.UiHolder.NumericDisplays;
     //this.numericDisplayStatic = CGameManager.instance.UiHolder.NumericDisplaysStatic;
     //this.numericDisplays.SetPanels();
     this.tracerManager = CGameManager.instance.UiHolder.TracerManager;
     this.gameSettings  = CGameManager.instance.UiHolder.GameSettings;
     //this.panelFade = CGameManager.instance.UiHolder.PanelFade;
     this.ktWatchBall         = new CKitchenTimer(2f);
     this.ktWatchWinnerScreen = new CKitchenTimer(2f);
     this.KTWatchNextUp       = new CKitchenTimer(2f);
     this._isShutdown         = false;
 }
        public void LockedTracerInstanceSwap()
        {
            var tracerOne = TracerHelper.Create();
            var tracerTwo = new LockedTracer();

            TracerRestorerAttribute.SetTracer(tracerOne);
            Tracer.Instance.Should().Be(tracerOne);
            Tracer.Instance.TracerManager.Should().Be(tracerOne.TracerManager);

            TracerRestorerAttribute.SetTracer(null);
            Tracer.Instance.Should().BeNull();

            // Set the locked tracer
            TracerRestorerAttribute.SetTracer(tracerTwo);
            Tracer.Instance.Should().Be(tracerTwo);
            Tracer.Instance.TracerManager.Should().Be(tracerTwo.TracerManager);

            // We test the locked tracer cannot be replaced.
#pragma warning disable CS0618 // Setter isn't actually obsolete, just should be internal
            Assert.Throws <InvalidOperationException>(() => Tracer.Instance = tracerOne);

            Assert.Throws <InvalidOperationException>(() => Tracer.Instance = null);

            Assert.Throws <InvalidOperationException>(() => TracerManager.ReplaceGlobalManager(null, TracerManagerFactory.Instance));
            Assert.Throws <InvalidOperationException>(() => TracerManager.ReplaceGlobalManager(null, new CITracerManagerFactory(CIVisibility.Settings)));
        }
Exemple #5
0
 internal static void SetTracer(Tracer tracer, TracerManager manager = null)
 {
     // CI Visibility tracer cannot be replaced, so we use an internal api to ensure the set.
     Tracer.UnsafeSetTracerInstance(tracer);
     manager ??= tracer?.TracerManager;
     if (manager is not null)
     {
         TracerManager.UnsafeReplaceGlobalManager(manager);
     }
 }
Exemple #6
0
        public void CurrentTracer()
        {
            var request  = new HttpRequest("file_name", "https://www.google.com", "");
            var response = new HttpResponse(new StringWriter());

            HttpContext.Current = new HttpContext(request, response);

            Assert.Null(TracerManager.GetCurrentTracer());
            TracerManager.SetCurrentTracer(DoNothingTracer.Instance);
            Assert.Equal(DoNothingTracer.Instance, TracerManager.GetCurrentTracer());
            TracerManager.SetCurrentTracer(null);
            Assert.Null(TracerManager.GetCurrentTracer());
        }
        protected override void Initialize()
        {
            base.Initialize ();

            var manager = new TracerManager();
            manager.SetTracingLevel (GetType ().Namespace, SourceLevels.Information);
            Tracer.Initialize (manager);

            Tracer.Get<FormsPlayerPackage> ().Info ("!Xamarin Forms Player Initialized");

            OleMenuCommandService mcs = GetService (typeof (IMenuCommandService)) as OleMenuCommandService;
            if (null != mcs) {
                // Create the command for the tool window
                CommandID toolwndCommandID = new CommandID (GuidList.guidFormsPlayerCmdSet, (int)PkgCmdIDList.cmdXamarinFormsPlayer);
                MenuCommand menuToolWin = new MenuCommand (ShowToolWindow, toolwndCommandID);
                mcs.AddCommand (menuToolWin);
            }
        }
        private static void Main(string[] args)
        {
            var services = new ServiceCollection();

            services.AddButterfly(option =>
            {
                option.CollectorUrl = "http://localhost:9618";
                option.Service      = "Console";
            });

            services.AddSingleton <HttpClient>(p => new HttpClient(p.GetService <HttpTracingHandler>()));
            services.AddSingleton <IFooService, FooService>();

            var provider = services.BuildAspectCoreServiceProvider();

            var fooService = provider.GetService <IFooService>();
            var result     = fooService.GetValues();

            System.Console.WriteLine($"Get result from backend:{result}");

            System.Console.ReadLine();

            TracerManager.Init(new ButterflyOptions()
            {
                CollectorUrl = "http://localhost:9618",
                Service      = "Console"
            }, new ButterflyLoggerFactory(new LoggerFactory()));

            var serviceTracer = TracerManager.Instence.ServiceTracer;
            var httpClient    = new HttpClient(new HttpTracingHandler(serviceTracer));

            var proxyGenerator = new ProxyGeneratorBuilder()
                                 .ConfigureService(opt => opt.AddInstance(serviceTracer))
                                 .Build();

            var fooService2 = proxyGenerator.CreateInterfaceProxy <IFooService, FooService>(httpClient);

            var result2 = fooService2.GetValues();

            System.Console.WriteLine($"Get result from backend:{result2}");

            System.Console.ReadLine();
        }
        protected override void Initialize()
        {
            base.Initialize();

            var manager = new TracerManager();

            manager.SetTracingLevel(GetType().Namespace, SourceLevels.Information);
            Tracer.Initialize(manager);

            Tracer.Get <FormsPlayerPackage> ().Info("!Xamarin Forms Player Initialized");

            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (null != mcs)
            {
                // Create the command for the tool window
                CommandID   toolwndCommandID = new CommandID(GuidList.guidFormsPlayerCmdSet, (int)PkgCmdIDList.cmdXamarinFormsPlayer);
                MenuCommand menuToolWin      = new MenuCommand(ShowToolWindow, toolwndCommandID);
                mcs.AddCommand(menuToolWin);
            }
        }
 public AggregateTracer(TracerManager manager, string name, IEnumerable<DiagnosticsTracer> tracers)
 {
     this.manager = manager;
     this.name = name;
     this.tracers = tracers.ToList();
 }
 /// <summary>
 /// Initializes the <see cref="Tracer"/> class by specifying the 
 /// diagnostics tracer as the default implementation.
 /// </summary>
 static Tracer()
 {
     manager = new TracerManager();
 }