{"action":"created","issue":{"url":"https://api.github.com/repos/cloudfoundry/gorouter/issues/239","repository_url":"https://api.github.com/repos/cloudfoundry/gorouter","labels_url":"https://api.github.com/repos/cloudfoundry/gorouter/issues/239/labels{/name}","comments_url":"https://api.github.com/repos/cloudfoundry/gorouter/issues/239/comments","events_url":"https://api.github.com/repos/cloudfoundry/gorouter/issues/239/events","html_url":"https://github.com/cloudfoundry/gorouter/issues/239","id":391192104,"node_id":"MDU6SXNzdWUzOTExOTIxMDQ=","number":239,"title":"ms_since_last_registry_update metric emits value of 9.223372036854e+12 when no routed apps have been pushed","user":{"login":"majidmade","id":19802056,"node_id":"MDQ6VXNlcjE5ODAyMDU2","avatar_url":"https://avatars0.githubusercontent.com/u/19802056?v=4","gravatar_id":"","url":"https://api.github.com/users/majidmade","html_url":"https://github.com/majidmade","followers_url":"https://api.github.com/users/majidmade/followers","following_url":"https://api.github.com/users/majidmade/following{/other_user}","gists_url":"https://api.github.com/users/majidmade/gists{/gist_id}","starred_url":"https://api.github.com/users/majidmade/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/majidmade/subscriptions","organizations_url":"https://api.github.com/users/majidmade/orgs","repos_url":"https://api.github.com/users/majidmade/repos","events_url":"https://api.github.com/users/majidmade/events{/privacy}","received_events_url":"https://api.github.com/users/majidmade/received_events","type":"User","site_admin":false},"labels":[{"id":371018005,"node_id":"MDU6TGFiZWwzNzEwMTgwMDU=","url":"https://api.github.com/repos/cloudfoundry/gorouter/labels/in%20progress","name":"in progress","color":"3461AD","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-12-14T17:04:03Z","updated_at":"2019-03-05T19:32:49Z","closed_at":null,"author_association":"MEMBER","body":"## Issue / Context\r\n\r\nIf no routed apps have been pushed to an isolation segment, the `ms_since_last_registry_update` metric emits with a value of `9.223372036854e+12`.\r\n\r\n(Note that there may be other scenarios in which this occurs; however, it's difficult to reproduce outside of isolation segments.)\r\n\r\n![image](https://user-images.githubusercontent.com/19802056/50016504-9bd61800-ff86-11e8-8917-0ab62e680d9b.png)\r\n\r\n## Steps to Reproduce\r\n\r\n1. Create an isolation segment, but don't push an app to it.\r\n2. Run `cf nozzle` and `grep` for `ms_since_last_registry_update`.\r\n3. Note that the ValueMetric is emitted with `9.223372036854e+12`.\r\n4. Push a routed app to the isolation segment.\r\n5. Note that the ValueMetric emits with the appropriate value.\r\n\r\n## Expected result\r\n\r\nNo specific expectation; perhaps a `-1`.\r\n\r\n## Current result\r\n\r\nThe metric is emitted as `9.223372036854e+12` in the problem case. This can cause downstream issues in applications that consume this value.\r\n\r\n## Bug location / Possible Fix\r\n\r\nLooking into the code, the variable `timeOfLastUpdate` starts as the default timestamp [`0001-01-01 00:00:00 +0000 UTC`](https://github.com/cloudfoundry/gorouter/blob/19a2e2aae95a39f23db37493bf630e3d6aeaede0/registry/registry.go#L56). It would normally be overwritten by the current time in the [`Register` function](https://github.com/cloudfoundry/gorouter/blob/19a2e2aae95a39f23db37493bf630e3d6aeaede0/registry/registry.go#L114), but since there is no app route registered, the [`ms_since_last_registry_update`](https://github.com/cloudfoundry/gorouter/blob/19a2e2aae95a39f23db37493bf630e3d6aeaede0/registry/registry.go#L235) metric is emitted with the value of  `9.223372036854e+12`.\r\n\r\nExample: https://play.golang.org/p/HI0afuWrM29\r\n\r\nA possible fix:\r\nWhen [returning the value of `timeOfLastUpdate`](https://github.com/cloudfoundry/gorouter/blob/19a2e2aae95a39f23db37493bf630e3d6aeaede0/registry/registry.go#L260), check if it is equal to the default value and return `-1` instead.\r\n"},"comment":{"url":"https://api.github.com/repos/cloudfoundry/gorouter/issues/comments/469826533","html_url":"https://github.com/cloudfoundry/gorouter/issues/239#issuecomment-469826533","issue_url":"https://api.github.com/repos/cloudfoundry/gorouter/issues/239","id":469826533,"node_id":"MDEyOklzc3VlQ29tbWVudDQ2OTgyNjUzMw==","user":{"login":"ameowlia","id":7025605,"node_id":"MDQ6VXNlcjcwMjU2MDU=","avatar_url":"https://avatars0.githubusercontent.com/u/7025605?v=4","gravatar_id":"","url":"https://api.github.com/users/ameowlia","html_url":"https://github.com/ameowlia","followers_url":"https://api.github.com/users/ameowlia/followers","following_url":"https://api.github.com/users/ameowlia/following{/other_user}","gists_url":"https://api.github.com/users/ameowlia/gists{/gist_id}","starred_url":"https://api.github.com/users/ameowlia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ameowlia/subscriptions","organizations_url":"https://api.github.com/users/ameowlia/orgs","repos_url":"https://api.github.com/users/ameowlia/repos","events_url":"https://api.github.com/users/ameowlia/events{/privacy}","received_events_url":"https://api.github.com/users/ameowlia/received_events","type":"User","site_admin":false},"created_at":"2019-03-05T19:32:49Z","updated_at":"2019-03-05T19:32:49Z","author_association":"CONTRIBUTOR","body":"Hi @majidmade, \r\n\r\nThanks for this issue. We made a fix for this that should be in the next release. \r\n\r\nIn the future you will see `-1` when no routes have been created.\r\n\r\nThanks, \r\n@ameowlia"}}
{"actor":{"display_login":"ameowlia"}}