{"action":"created","issue":{"url":"https://api.github.com/repos/Recognos/Metrics.NET/issues/80","repository_url":"https://api.github.com/repos/Recognos/Metrics.NET","labels_url":"https://api.github.com/repos/Recognos/Metrics.NET/issues/80/labels{/name}","comments_url":"https://api.github.com/repos/Recognos/Metrics.NET/issues/80/comments","events_url":"https://api.github.com/repos/Recognos/Metrics.NET/issues/80/events","html_url":"https://github.com/Recognos/Metrics.NET/issues/80","id":240502151,"number":80,"title":"Metric.Timer has NaN for Mean","user":{"login":"hhansell","id":2264683,"avatar_url":"https://avatars0.githubusercontent.com/u/2264683?v=4","gravatar_id":"","url":"https://api.github.com/users/hhansell","html_url":"https://github.com/hhansell","followers_url":"https://api.github.com/users/hhansell/followers","following_url":"https://api.github.com/users/hhansell/following{/other_user}","gists_url":"https://api.github.com/users/hhansell/gists{/gist_id}","starred_url":"https://api.github.com/users/hhansell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hhansell/subscriptions","organizations_url":"https://api.github.com/users/hhansell/orgs","repos_url":"https://api.github.com/users/hhansell/repos","events_url":"https://api.github.com/users/hhansell/events{/privacy}","received_events_url":"https://api.github.com/users/hhansell/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2017-07-04T21:54:04Z","updated_at":"2017-11-03T02:16:04Z","closed_at":null,"author_association":"NONE","body":"After leaving a process running for some time, I've come across the following issue.  \r\nCould someone confirm if this is a metrics.net issue or whether it is an issue for the Metrics.NET.InfluxDB project?\r\n\r\nThanks\r\n\r\n`public static readonly Timer ResponseTime = Metric.Timer(\"Response Time\", Unit.Requests);`\r\n\r\n\r\n2017-07-05 05:45:05, 226 [22  ] Metrics: **Unhandled exception in Metrics.NET** Library Error while uploading 51 measurements (5.72 KiB) to InfluxDB over HTTP [http://localhost:8070/write?db=metrics&u=user&p=password&precision=s] [ResponseStatus: ProtocolError] [Response: {\r\n\"error\":\"partial write: unable to parse '\r\nResponse  Time Active  Sessions=0i,\r\nTotal  Time=4i,\r\nCount=1i,\r\nMean  Rate=1.9858004319199677E-05,\r\n1  Min  Rate=2.96439387504748E-314,\r\n5  Min  Rate=5.0414622397472423E-76,\r\n15  Min  Rate=5.9199171854273278E-28,\r\nLast=4.0835409999999994,\r\nMin=4.0835409999999994,\r\n**Mean=NaN,**\r\nMax=4.0835409999999994,\r\nStdDev=0,\r\nMedian=4.0835409999999994,\r\nSample  Size=1i,\r\nPercentile  75%=4.0835409999999994,\r\nPercentile  95%=4.0835409999999994,\r\nPercentile  98%=4.0835409999999994,\r\nPercentile  99%=4.0835409999999994,\r\nPercentile  99.9%=4.0835409999999994 1499197505': invalid number\"}\r\n"},"comment":{"url":"https://api.github.com/repos/Recognos/Metrics.NET/issues/comments/341608529","html_url":"https://github.com/Recognos/Metrics.NET/issues/80#issuecomment-341608529","issue_url":"https://api.github.com/repos/Recognos/Metrics.NET/issues/80","id":341608529,"user":{"login":"hhansell","id":2264683,"avatar_url":"https://avatars0.githubusercontent.com/u/2264683?v=4","gravatar_id":"","url":"https://api.github.com/users/hhansell","html_url":"https://github.com/hhansell","followers_url":"https://api.github.com/users/hhansell/followers","following_url":"https://api.github.com/users/hhansell/following{/other_user}","gists_url":"https://api.github.com/users/hhansell/gists{/gist_id}","starred_url":"https://api.github.com/users/hhansell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hhansell/subscriptions","organizations_url":"https://api.github.com/users/hhansell/orgs","repos_url":"https://api.github.com/users/hhansell/repos","events_url":"https://api.github.com/users/hhansell/events{/privacy}","received_events_url":"https://api.github.com/users/hhansell/received_events","type":"User","site_admin":false},"created_at":"2017-11-03T02:16:04Z","updated_at":"2017-11-03T02:16:04Z","author_association":"NONE","body":"@PaulParau, after logging out some values, I see that the NaN comes ultimately as the result of a list where all items have a weight of zero.  Perhaps a change to the Mean function to handle this and return 0?  This won't fix the bigger issue further down though.\r\n\r\n```\r\n            var list = new SortedList<double, WeightedSample>(100, ReverseOrderDoubleComparer.Instance);         \r\n            list[double.Parse(\"1.48219693752374E-323\")] = new WeightedSample(1957668, null, 0.000000000000000000000000000000);\r\n            var snapshot = new WeightedSnapshot(list.Count, list.Values);\r\n            var mean = snapshot.Mean;\r\n            Debug.Assert(!double.IsNaN(mean));\r\n```\r\n\r\nHaving logged out the values, here is an example using real data (from a logged version of the Rescale method in the ExponentiallyDecayingReservoir) that has lead to a weight of zero:\r\n```\r\n            var alpha = 0.015;\r\n            var sampleWeight = double.Parse(\"6.30093530948943E-302\");\r\n            var startTime = 294463;\r\n            var oldStartTime = 290906;\r\n            double weight = sampleWeight * Math.Exp(-alpha * (startTime - oldStartTime));\r\n```\r\nUltimately, this comes down to the 'sampleWeight * scalingFactor' being too small for a double. 6.73314423785015E-24 * 6.30093530948943E-302 == double(0).\r\n\r\nI presume that the purpose of ResetReservoir is to prevent the weights from decaying to this point, however, I cannot see how this is ultimately called though.\r\n            \r\n            "}}
{"actor":{"display_login":"hhansell"}}