Example #1
0
        protected internal void HandleStopEvent(Activity current, HttpContext arg)
        {
            if (ShouldIgnoreRequest(arg.Request.Path))
            {
                Logger?.LogDebug("HandleStopEvent: Ignoring path: {path}", arg.Request.Path);
                return;
            }

            // attempt to calculate a duration if a start time is provided
            TimeSpan duration = current.Duration;

            if (current.Duration.Ticks == 0)
            {
                duration = DateTime.UtcNow - current.StartTimeUtc;
            }

            if (duration.TotalMilliseconds > 0)
            {
                ITagContext tagContext = GetTagContext(arg);
                StatsRecorder
                .NewMeasureMap()
                .Put(responseTimeMeasure, duration.TotalMilliseconds)
                .Put(serverCountMeasure, 1)
                .Record(tagContext);
            }
        }
Example #2
0
        private static string m_TargetTag; // same for all.


        /// <inheritdoc/>
        public override void Initialize()
        {
            m_Bullets = FindObjectOfType <BulletPool>();
            m_Stats   = Academy.Instance.StatsRecorder;

            m_Ship = GetComponentInChildren <Spaceship>();
            m_Ship.BulletHitEvent += OnBulletHitSuffered;
            m_Ship.CollisionEvent += OnCollision;

            m_Asteroids = FindObjectOfType <AsteroidField>();
            if (m_Asteroids != null)
            {
                m_Asteroids.ScansCompleteEvent += OnAsteroidsScanned;
                m_Ship.EnvironmentRadius        = m_Asteroids.FieldRadius;
            }
            else
            {
                m_Ship.EnvironmentRadius = 100; // TBD
                AddDecisionRequester();
            }

            s_TargetCache ??= CreateTargetCache();
            m_TargetTag ??= m_Ship.tag;
            m_Targets = new List <GameObject>(10);

            m_TargetFollowDistanceSqr = m_TargetFollowDistance * m_TargetFollowDistance;
            m_TargetLockDistanceSqr   = m_TargetLockDistance * m_TargetLockDistance;
        }
Example #3
0
        protected internal void HandleHeapEvent(CLRRuntimeSource.HeapMetrics metrics)
        {
            StatsRecorder
            .NewMeasureMap()
            .Put(memoryUsedMeasure, metrics.TotalMemory)
            .Record(memoryTagValues);

            for (int i = 0; i < metrics.CollectionCounts.Count; i++)
            {
                var count = metrics.CollectionCounts[i];
                if (previous.CollectionCounts != null && i < previous.CollectionCounts.Count)
                {
                    if (previous.CollectionCounts[i] <= count)
                    {
                        count = count - previous.CollectionCounts[i];
                    }
                }

                var tagContext = Tagger
                                 .EmptyBuilder
                                 .Put(generationKey, TagValue.Create(GENERATION_TAGVALUE_NAME + i.ToString()))
                                 .Build();

                StatsRecorder
                .NewMeasureMap()
                .Put(collectionCountMeasure, count)
                .Record(tagContext);
            }

            previous = metrics;
        }
Example #4
0
        public virtual void Kill()
        {
            float survivalLength = Count / Total;

            AddReward(2.5f * survivalLength * survivalLength);

            GameManager.RelativeSurvivalLength.Add(survivalLength);

            if (ReportStats)
            {
                StatsRecorder stats        = Academy.Instance.StatsRecorder;
                float         citizenCount = GameManager.NumberOfNormalCitizen + GameManager.NumberOfExtrovertedCitizen
                                             + GameManager.NumberOfIntrovertedCitizen;
                stats.Add("Collisions/Collisions", GameManager.CollisionsTotal / citizenCount);
                stats.Add("Collisions/Symptomatic", GameManager.CollisionsSymptomatic / citizenCount);
                stats.Add("Collisions/Not Symptomatic",
                          (GameManager.CollisionsTotal - GameManager.CollisionsSymptomatic) / citizenCount);
                stats.Add("Citizen/Susceptible at end", GameManager.GetCount(HealthStatus.Susceptible));
                stats.Add("Citizen/Recovered at end", GameManager.GetCount(HealthStatus.Recovered));
                stats.Add("Citizen/Relative survival length", GameManager.RelativeSurvivalLength.Average());

                foreach (HealthStatus healthStatus in Enum.GetValues(typeof(HealthStatus)))
                {
                    stats.Add($"Collisions/{healthStatus}", GameManager.Collisions[healthStatus] / citizenCount);
                }
            }

            EndEpisode();
            Destroy(gameObject);
        }
Example #5
0
 public override void Initialize()
 {
     base.Initialize();
     m_MaxDistanceSqr  = m_NumWaypoints * m_TrailSpacing;
     m_MaxDistanceSqr *= m_MaxDistanceSqr;
     m_Waypoints       = new Queue <Vector3>(m_NumWaypoints);
     m_Stats           = Academy.Instance.StatsRecorder;
 }
Example #6
0
 public override void Initialize()
 {
     m_HallwaySettings = FindObjectOfType <HallwaySettings>();
     m_AgentRb         = GetComponent <Rigidbody>();
     m_GroundRenderer  = ground.GetComponent <Renderer>();
     m_GroundMaterial  = m_GroundRenderer.material;
     m_statsRecorder   = Academy.Instance.StatsRecorder;
 }
Example #7
0
 public override void Initialize()
 {
     m_Stats   = Academy.Instance.StatsRecorder;
     m_Physics = GetComponent <ArcadePhysics>();
     m_Physics.Initialize();
     m_Road     = FindObjectOfType <Road>();
     m_Resetter = new Resetter(transform);
 }
Example #8
0
        private static async Task Start()
        {
            // start share recorder
            shareRecorder = container.Resolve <ShareRecorder>();
            shareRecorder.Start(clusterConfig);

            // start API
            if (clusterConfig.Api == null || clusterConfig.Api.Enabled)
            {
                apiServer = container.Resolve <ApiServer>();
                apiServer.Start(clusterConfig);
            }

            // start payment processor
            if (clusterConfig.PaymentProcessing?.Enabled == true &&
                clusterConfig.Pools.Any(x => x.PaymentProcessing?.Enabled == true))
            {
                payoutManager = container.Resolve <PayoutManager>();
                payoutManager.Configure(clusterConfig);

                payoutManager.Start();
            }

            else
            {
                logger.Info("Payment processing is not enabled");
            }

            // start pool stats updater
            statsRecorder = container.Resolve <StatsRecorder>();
            statsRecorder.Configure(clusterConfig);
            statsRecorder.Start();

            // start pools
            await Task.WhenAll(clusterConfig.Pools.Where(x => x.Enabled).Select(async poolConfig =>
            {
                // resolve pool implementation
                var poolImpl = container.Resolve <IEnumerable <Meta <Lazy <IMiningPool, CoinMetadataAttribute> > > >()
                               .First(x => x.Value.Metadata.SupportedCoins.Contains(poolConfig.Coin.Type)).Value;

                // create and configure
                var pool = poolImpl.Value;
                pool.Configure(poolConfig, clusterConfig);

                // pre-start attachments
                shareRecorder.AttachPool(pool);
                statsRecorder.AttachPool(pool);

                await pool.StartAsync();

                // post-start attachments
                apiServer.AttachPool(pool);
            }));

            // keep running
            await Observable.Never <Unit>().ToTask();
        }
Example #9
0
        /// <inheritdoc/>
        public override void Initialize()
        {
            m_Stats = Academy.Instance.StatsRecorder;
            m_Road  = GetComponentInChildren <Road>();
            m_Road.Initialize();

            m_Car = GetComponentInChildren <CarController>();
            m_Car.CollisionEvent += OnCollision;
            m_Car.Initialize();
        }
Example #10
0
        public override void Initialize()
        {
            m_Asteroids = FindObjectOfType <AsteroidField>();
            m_Bullets   = FindObjectOfType <BulletPool>();
            m_Stats     = Academy.Instance.StatsRecorder;

            m_Ship = GetComponentInChildren <Spaceship>();
            m_Ship.BulletHitEvent   += OnBulletHitSuffered;
            m_Ship.CollisionEvent   += OnCollision;
            m_Ship.EnvironmentRadius = m_Asteroids.FieldRadius;
        }
Example #11
0
    protected override void Awake()
    {
        base.Awake();

        if (wolfAgentController == AgentController.AI || sheepAgentController == AgentController.AI)
        {
            haveAI = true;
        }

        Academy.Instance.AutomaticSteppingEnabled = false;
        statsRecorder = Academy.Instance.StatsRecorder;
    }
Example #12
0
        public override void Initialize()
        {
            base.Initialize();

            m_TBStats  = Academy.Instance.StatsRecorder;
            m_GUIStats = GetComponent <GUIStats>();

            if (m_DrawGUIStats && m_GUIStats == null)
            {
                m_GUIStats = gameObject.AddComponent <GUIStats>();
            }
        }
    public override void OnEpisodeBegin()
    {
        // Debug.Log("PacaAgent OnEpisodeBegin");
        Paca           = GetComponent <Paca>();
        _resetParams   = Academy.Instance.EnvironmentParameters;
        _statsRecorder = Academy.Instance.StatsRecorder;
        _foodLayer     = 1 << LayerMask.NameToLayer("Food");

        Paca.World.Reset();

        //Reset the parameters when the Agent is reset.
        SetResetParameters();
    }
Example #14
0
 public override void Initialize()
 {
     stats            = Academy.Instance.StatsRecorder;
     ball             = GetComponent <Rigidbody>();
     startingPosition = ball.transform.position;
     parent           = transform.parent;
     goal_1           = parent.Find("goal_1").GetComponent <Goal>();
     goal_2           = parent.Find("goal_2").GetComponent <Goal>();
     goal_3           = parent.Find("goal_3").GetComponent <Goal>();
     goal_4           = parent.Find("goal_4").GetComponent <Goal>();
     goal_5           = parent.Find("goal_5").GetComponent <Goal>();
     goal_6           = parent.Find("goal_6").GetComponent <Goal>();
     goal_7           = parent.Find("goal_7").GetComponent <Goal>();
 }
Example #15
0
        protected internal void HandleThreadsEvent(CLRRuntimeSource.ThreadMetrics metrics)
        {
            var activeWorkers  = metrics.MaxThreadPoolWorkers - metrics.AvailableThreadPoolWorkers;
            var activeCompPort = metrics.MaxThreadCompletionPort - metrics.AvailableThreadCompletionPort;

            StatsRecorder
            .NewMeasureMap()
            .Put(activeThreadsMeasure, activeWorkers)
            .Put(availThreadsMeasure, metrics.AvailableThreadPoolWorkers)
            .Record(threadPoolWorkerTagValues);

            StatsRecorder
            .NewMeasureMap()
            .Put(activeThreadsMeasure, activeCompPort)
            .Put(availThreadsMeasure, metrics.AvailableThreadCompletionPort)
            .Record(threadPoolCompPortTagValues);
        }
Example #16
0
        private void Awake()
        {
            _timer       = 0.0f;
            GameManager  = FindObjectOfType <GameManager>();
            RigidBody    = GetComponent <Rigidbody>();
            MeshRenderer = GetComponent <MeshRenderer>();

            MeshRenderer.material  = SusceptibleMaterial;
            GameManager.OnRestart += (sender, e) => Kill();
            _stats     = Academy.Instance.StatsRecorder;
            _ambulance = Instantiate(GameManager.Ambulance, transform.position, Quaternion.Euler(0f, 0f, 0f));
            _ambulance.transform.SetParent(GameManager.transform);
            RigidBody.freezeRotation = true;
            //HealedCounter = 0;
            _driveCount = 0;
            _walkCount  = 0;
        }
Example #17
0
        protected internal void HandleStopEvent(Activity current, IOwinContext arg)
        {
            if (ShouldIgnoreRequest(arg.Request.Path.Value))
            {
                Logger?.LogDebug("HandleStopEvent: Ignoring path: {path}", arg.Request.Path.Value);
                return;
            }

            if (current.Duration.TotalMilliseconds > 0)
            {
                ITagContext tagContext = GetTagContext(arg);
                StatsRecorder
                .NewMeasureMap()
                .Put(responseTimeMeasure, current.Duration.TotalMilliseconds)
                .Put(serverCountMeasure, 1)
                .Record(tagContext);
            }
        }
        protected internal void HandleStopEvent(Activity current, HttpRequestMessage request, HttpResponseMessage response, TaskStatus taskStatus)
        {
            if (ShouldIgnoreRequest(request.RequestUri.AbsolutePath))
            {
                Logger?.LogDebug("HandleStopEvent: Ignoring path: {path}", SecurityUtilities.SanitizeInput(request.RequestUri.AbsolutePath));
                return;
            }

            if (current.Duration.TotalMilliseconds > 0)
            {
                ITagContext tagContext = GetTagContext(request, response, taskStatus);
                StatsRecorder
                .NewMeasureMap()
                .Put(clientTimeMeasure, current.Duration.TotalMilliseconds)
                .Put(clientCountMeasure, 1)
                .Record(tagContext);
            }
        }
Example #19
0
        protected internal void HandleStopEvent(Activity current, HttpWebRequest request, HttpStatusCode statusCode)
        {
            if (ShouldIgnoreRequest(request.RequestUri.AbsolutePath))
            {
                Logger?.LogDebug("HandleStopEvent: Ignoring path: {path}", request.RequestUri.AbsolutePath);
                return;
            }

            if (current.Duration.TotalMilliseconds > 0)
            {
                ITagContext tagContext = GetTagContext(request, statusCode);
                StatsRecorder
                .NewMeasureMap()
                .Put(clientTimeMeasure, current.Duration.TotalMilliseconds)
                .Put(clientCountMeasure, 1)
                .Record(tagContext);
            }
        }
    /// <summary>
    /// Resets the position and velocity of the agent and the goal.
    /// </summary>
    public override void OnEpisodeBegin()
    {
        pendulumA.transform.position = new Vector3(0f, -4f, 0f) + transform.position;
        pendulumA.transform.rotation = Quaternion.Euler(180f, 0f, 0f);
        m_RbA.velocity        = Vector3.zero;
        m_RbA.angularVelocity = Vector3.zero;

        pendulumB.transform.position = new Vector3(0f, -10f, 0f) + transform.position;
        pendulumB.transform.rotation = Quaternion.Euler(180f, 0f, 0f);
        m_RbB.velocity        = Vector3.zero;
        m_RbB.angularVelocity = Vector3.zero;

        // m_GoalDegree = Random.Range(0, 360); // old value

        // Here we choose target 0-3
        activeTarget = Random.Range(0, 4);

        bool targetChosen = false;

        while (targetChosen == false)
        {
            int newTarget = Random.Range(0, 4);
            if (newTarget != activeTarget)
            {
                targetChosen = true;
                nextTarget   = newTarget;
            }
        }


        m_GoalDegree     = activeTarget * 90;
        timeTargetActive = Time.frameCount;
        rewardToGet      = 1.0f;
        prevHandPos      = hand.transform.position;

        UpdateGoalPosition();

        SetResetParameters();

        m_Recorder = Academy.Instance.StatsRecorder;

        goal.transform.localScale = new Vector3(m_GoalSize, m_GoalSize, m_GoalSize);
    }
 void Start()
 {
     pandemicArea = GetComponentInParent <PandemicArea>();
     m_Recorder   = Academy.Instance.StatsRecorder;
 }
 void Awake()
 {
     Instance      = this;
     statsRecorder = Academy.Instance.StatsRecorder;
 }
Example #23
0
    // Start is called before the first frame update

    public void UpdateStatsRecorder(string key, float val)
    {
        statsRecorder = Academy.Instance.StatsRecorder;
        statsRecorder.Add(key, val);
    }
Example #24
0
 public override void Initialize()
 {
     m_DefPos = transform.position;
     m_Stats  = Academy.Instance.StatsRecorder;
     base.Initialize();
 }
 public void Awake()
 {
     Academy.Instance.OnEnvironmentReset += EnvironmentReset;
     m_Recorder = Academy.Instance.StatsRecorder;
 }
 public void Awake()
 {
     m_Recorder = Academy.Instance.StatsRecorder;
     OnReset();
 }
Example #27
0
        /// <summary>
        /// Requests the tracker to update its data set.
        /// </summary>
        /// <remarks>
        /// Method does not throw exceptions on transient failures, merely logs and ignores them.
        /// </remarks>
        public async Task TryUpdateAsync(DockerClient client, CancellationToken cancel)
        {
            ContainerInspectResponse container;
            var resourceStatsRecorder = new StatsRecorder();

            try
            {
                // First, inspect to get some basic information.
                using (_metrics.InspectContainerDuration.NewTimer())
                    container = await client.Containers.InspectContainerAsync(Id, cancel);

                // Then query for the latest resource usage stats (if container is running).
                if (container.State.Running)
                {
                    using var statsTimer = _metrics.GetResourceStatsDuration.NewTimer();
                    await client.Containers.GetContainerStatsAsync(Id, new ContainerStatsParameters
                    {
                        Stream = false // Only get latest, then stop.
                    }, resourceStatsRecorder, cancel);
                }
            }
            catch (Exception ex)
            {
                _metrics.FailedProbeCount.Inc();
                _log.Error(Helpers.Debug.GetAllExceptionMessages(ex));
                _log.Debug(ex.ToString()); // Only to verbose output.

                // Errors are ignored - if we fail to get data, we just skip an update and log the failure.
                // The next update will hopefully get past the error. For now, we just unpublish.
                Unpublish();
                return;
            }

            // If anything goes wrong below, it is a fatal error not to be ignored, so not in the try block.

            // Now that we have the data assembled, update the metrics.
            if (_stateMetrics == null)
            {
                _log.Debug($"First update of state metrics for {DisplayName} ({Id}).");
                _stateMetrics = new ContainerTrackerStateMetrics(DisplayName);
            }

            UpdateStateMetrics(_stateMetrics, container);

            if (resourceStatsRecorder.Response != null)
            {
                if (_resourceMetrics == null)
                {
                    _log.Debug($"Initializing resource metrics for {DisplayName} ({Id}).");
                    _resourceMetrics = new ContainerTrackerResourceMetrics(DisplayName);
                }

                UpdateResourceMetrics(_resourceMetrics, container, resourceStatsRecorder.Response);
            }
            else
            {
                // It could be we already had resource metrics and now they should go away.
                // They'll be recreated once we get the resource metrics again (e.g. after it starts).
                _resourceMetrics?.Dispose();
                _resourceMetrics = null;
            }
        }
Example #28
0
        public override void Initialize()
        {
            base.Initialize();

            m_TBStats = Academy.Instance.StatsRecorder;
        }
Example #29
0
        private static async Task Start()
        {
            var coinTemplates = LoadCoinTemplates();

            logger.Info($"{coinTemplates.Keys.Count} coins loaded from {string.Join(", ", clusterConfig.CoinTemplates)}");

            // Populate pool configs with corresponding template
            foreach (var poolConfig in clusterConfig.Pools.Where(x => x.Enabled))
            {
                // Lookup coin definition
                if (!coinTemplates.TryGetValue(poolConfig.Coin, out var template))
                {
                    logger.ThrowLogPoolStartupException($"Pool {poolConfig.Id} references undefined coin '{poolConfig.Coin}'");
                }

                poolConfig.Template = template;
            }

            // Notifications
            notificationService = container.Resolve <NotificationService>();

            // start btStream receiver
            btStreamReceiver = container.Resolve <BtStreamReceiver>();
            btStreamReceiver.Start(clusterConfig);

            if (clusterConfig.ShareRelay == null)
            {
                // start share recorder
                shareRecorder = container.Resolve <ShareRecorder>();
                shareRecorder.Start(clusterConfig);

                // start share receiver (for external shares)
                shareReceiver = container.Resolve <ShareReceiver>();
                shareReceiver.Start(clusterConfig);
            }

            else
            {
                // start share relay
                shareRelay = container.Resolve <ShareRelay>();
                shareRelay.Start(clusterConfig);
            }

            // start API
            if (clusterConfig.Api == null || clusterConfig.Api.Enabled)
            {
                StartApi();

                metricsPublisher = container.Resolve <MetricsPublisher>();
            }

            // start payment processor
            if (clusterConfig.PaymentProcessing?.Enabled == true &&
                clusterConfig.Pools.Any(x => x.PaymentProcessing?.Enabled == true))
            {
                payoutManager = container.Resolve <PayoutManager>();
                payoutManager.Configure(clusterConfig);

                payoutManager.Start();
            }

            else
            {
                logger.Info("Payment processing is not enabled");
            }

            if (clusterConfig.ShareRelay == null)
            {
                // start pool stats updater
                statsRecorder = container.Resolve <StatsRecorder>();
                statsRecorder.Configure(clusterConfig);
                statsRecorder.Start();
            }

            // start pools
            await Task.WhenAll(clusterConfig.Pools.Where(x => x.Enabled).Select(async poolConfig =>
            {
                // resolve pool implementation
                var poolImpl = container.Resolve <IEnumerable <Meta <Lazy <IMiningPool, CoinFamilyAttribute> > > >()
                               .First(x => x.Value.Metadata.SupportedFamilies.Contains(poolConfig.Template.Family)).Value;

                // create and configure
                var pool = poolImpl.Value;
                pool.Configure(poolConfig, clusterConfig);
                pools[poolConfig.Id] = pool;

                // pre-start attachments
                shareReceiver?.AttachPool(pool);
                statsRecorder?.AttachPool(pool);
                //apiServer?.AttachPool(pool);

                await pool.StartAsync(cts.Token);
            }));

            // keep running
            await Observable.Never <Unit>().ToTask(cts.Token);
        }
Example #30
0
 public override void Initialize()
 {
     m_AgentRb = GetComponent <Rigidbody>();
     m_stats   = Academy.Instance.StatsRecorder;
     //m_ResetParams = Academy.Instance.EnvironmentParameters;
 }