Exemple #1
0
        static void Main(string[] args)
        {
            //Initialize the metrics manager. This method should be called only once!
            MetricsManager.Initialize("SampleApp", "Development", "localhost");

            //Imitate long-running taks and get the timings
            //should be resolved in ~500ms
            using (var timer = MetricsManager.GetRootMetricsLogger().StartTimer("Timer"))
            {
                Task.Delay(500).Wait();
            }

            //service also allows you to extend the logging experience by grouping metrics
            //together via dimensions. The line below creates a new logger with additional
            //property `api`.
            var logger = MetricsManager.GetMetricsLogger("api=Counters");
            //and then extends an existing logger by adding more specifi property
            var extendedLogger = logger.ExtendDimensions("subApi=Recorders");

            //Imitate concurrent environment, create counter and record metrics and update them
            Parallel.For(0, 1000, (i) => {
                logger.IncrementCounter("MyCounter", 1);
                extendedLogger.Record("MyRecorder", 1.0M, Unit.Second);
            });

            //If the 'IsManualFlush' config key is set to false, then the next line is redundant
            //as metrics manager will automatically flush things
            // MetricsManager.FlushAll();

            Console.ReadKey();
        }
    // Start is called before the first frame update
    void Start()
    {
        if (singleton == null)
        {
            singleton = this;
        }
        else
        {
            Destroy(this.gameObject);
            return;
        }

        if (ActivePlayerCharacter == null)
        {
            ActivePlayerCharacter = FindObjectOfType <PlayerCharacter>();
            if (ActivePlayerCharacter == null && PlayerCharacterPrefab != null)
            {
                ActivePlayerCharacter = GameObject.Instantiate(PlayerCharacterPrefab);

                // Do any player initialization here
            }
        }
        if (MainUI == null)
        {
            MainUI = FindObjectOfType <MainUI>();
            if (MainUI == null && MainUIPrefab != null)
            {
                MainUI = GameObject.Instantiate(MainUIPrefab);

                // Do any UI initialization here
            }
        }

        metricsManager = new MetricsManager();
        metricsManager.Initialize();

        MapLayout.LoadMapFile();
    }
 public void InvalidSerivceNameShouldThrow()
 {
     Assert.Throws <ArgumentException>(() => { MetricsManager.Initialize("Invalid@Service@Name"); });
 }
 public MetricsManagerTests()
 {
     MetricsManager.Initialize(TestServiceName, TestEnvironment, TestHostName);
     AddExpectations("/PutMetric*");
 }