{"action":"created","issue":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/15483","repository_url":"https://api.github.com/repos/spring-projects/spring-boot","labels_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/15483/labels{/name}","comments_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/15483/comments","events_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/15483/events","html_url":"https://github.com/spring-projects/spring-boot/issues/15483","id":391761001,"node_id":"MDU6SXNzdWUzOTE3NjEwMDE=","number":15483,"title":"HealthEndpoint dependency chain hijacking MeterRegistryConfigurer","user":{"login":"tde-desc","id":20650339,"node_id":"MDQ6VXNlcjIwNjUwMzM5","avatar_url":"https://avatars1.githubusercontent.com/u/20650339?v=4","gravatar_id":"","url":"https://api.github.com/users/tde-desc","html_url":"https://github.com/tde-desc","followers_url":"https://api.github.com/users/tde-desc/followers","following_url":"https://api.github.com/users/tde-desc/following{/other_user}","gists_url":"https://api.github.com/users/tde-desc/gists{/gist_id}","starred_url":"https://api.github.com/users/tde-desc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tde-desc/subscriptions","organizations_url":"https://api.github.com/users/tde-desc/orgs","repos_url":"https://api.github.com/users/tde-desc/repos","events_url":"https://api.github.com/users/tde-desc/events{/privacy}","received_events_url":"https://api.github.com/users/tde-desc/received_events","type":"User","site_admin":false},"labels":[{"id":297028791,"node_id":"MDU6TGFiZWwyOTcwMjg3OTE=","url":"https://api.github.com/repos/spring-projects/spring-boot/labels/status:%20feedback-provided","name":"status: feedback-provided","color":"fef2c0","default":false},{"id":293438798,"node_id":"MDU6TGFiZWwyOTM0Mzg3OTg=","url":"https://api.github.com/repos/spring-projects/spring-boot/labels/status:%20waiting-for-triage","name":"status: waiting-for-triage","color":"fef2c0","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-12-17T15:23:50Z","updated_at":"2018-12-18T20:35:36Z","closed_at":null,"author_association":"NONE","body":"Spring Boot version: 2.1.1\r\nMicrometer version: 1.1.1\r\n\r\nWhile defining a custom micrometer MeterRegistryCustomizer I had to face the following issue: The dependency chain of Spring Boot-HealthIndicator seems to interrupt the MeterRegistry bean creation at runtime. I will try to explain with the following setup. Given:\r\n\r\n```\r\n@Bean\r\npublic MicrometerConfiguration micrometerConfiguration() {\r\n    return new MicrometerConfiguration();\r\n}\r\n\r\n@Bean\r\npublic HealthEndpointMeterBinder healthEndpointMetricRegistry(HealthEndpoint healthEndpoint) {\r\n    return new HealthEndpointMeterBinder(healthEndpoint);\r\n}\r\n```\r\n\r\nAre being defined as follows:\r\n\r\n```\r\n@RequiredArgsConstructor\r\npublic class MicrometerConfiguration implements MeterRegistryCustomizer {\r\n\r\n    @Override\r\n    public void customize(MeterRegistry registry) {\r\n        // do something ...\r\n    }\r\n}\r\n\r\n@RequiredArgsConstructor\r\npublic class HealthEndpointMeterBinder implements MeterBinder {\r\n    private final HealthEndpoint healthEndpoint;\r\n\r\n    @Override\r\n    public void bindTo(MeterRegistry meterRegistry) {\r\n        Gauge.builder(\"unhealthy\", healthEndpoint,\r\n                e -> e.health().getStatus() == Status.UP ? 0.0 : 1.0\r\n        ).register(meterRegistry);\r\n    }\r\n}\r\n```\r\n\r\nIn org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryPostProcessor#getConfigurer you can observe the process being interrupted which for example leads to org.springframework.boot.actuate.metrics.amqp.RabbitMetrics#bindTo being called before MicrometerConfiguration#customize. This results to not being able to register custom common tags for example.\r\n\r\nI could solve this issue by defining the HealthIndicator dependency as ObjectProvider<HealthEndpoint>:\r\n\r\n```\r\n@RequiredArgsConstructor\r\npublic class HealthEndpointMeterBinder implements MeterBinder {\r\n    private final ObjectProvider<HealthEndpoint> healthEndpoint;\r\n\r\n    @Override\r\n    public void bindTo(MeterRegistry meterRegistry) {\r\n        Gauge.builder(\"unhealthy\", healthEndpoint,\r\n                e -> e.getIfAvailable().health().getStatus() == Status.UP ? 0.0 : 1.0\r\n        ).register(meterRegistry);\r\n    }\r\n}\r\n```\r\n\r\nIn my mind, injecting the HealthIndicator bean should not lead to the interruption of the MeterRegistry bean creation. I hope i could make myself clear ...\r\n\r\nRegards \r\nDennis"},"comment":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/comments/448361036","html_url":"https://github.com/spring-projects/spring-boot/issues/15483#issuecomment-448361036","issue_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/15483","id":448361036,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0ODM2MTAzNg==","user":{"login":"wilkinsona","id":914682,"node_id":"MDQ6VXNlcjkxNDY4Mg==","avatar_url":"https://avatars3.githubusercontent.com/u/914682?v=4","gravatar_id":"","url":"https://api.github.com/users/wilkinsona","html_url":"https://github.com/wilkinsona","followers_url":"https://api.github.com/users/wilkinsona/followers","following_url":"https://api.github.com/users/wilkinsona/following{/other_user}","gists_url":"https://api.github.com/users/wilkinsona/gists{/gist_id}","starred_url":"https://api.github.com/users/wilkinsona/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wilkinsona/subscriptions","organizations_url":"https://api.github.com/users/wilkinsona/orgs","repos_url":"https://api.github.com/users/wilkinsona/repos","events_url":"https://api.github.com/users/wilkinsona/events{/privacy}","received_events_url":"https://api.github.com/users/wilkinsona/received_events","type":"User","site_admin":false},"created_at":"2018-12-18T20:35:36Z","updated_at":"2018-12-18T20:35:36Z","author_association":"MEMBER","body":"Thanks for the sample, but it doesn't reproduce the problem. It also doesn't seem to include any of the code that you've mentioned above. What have I missed?"}}
{"actor":{"display_login":"wilkinsona"}}