Skip to content

Commit a86ae3a

Browse files
guanchao-yangluyiisme
authored andcommitted
Change to AutoPollFriendlyInfo and use AutoPollSuggestion.POLL_WHEN_UPDATED suggestion (#25)
* Fix System Properties and Env Updated Suggestion
1 parent 5287564 commit a86ae3a

File tree

13 files changed

+88
-14
lines changed

13 files changed

+88
-14
lines changed

client/lookout-api/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.alipay.sofa.lookout</groupId>
77
<artifactId>lookout-client-parent</artifactId>
8-
<version>1.4.3</version>
8+
<version>1.4.4</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111

client/lookout-client/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.alipay.sofa.lookout</groupId>
88
<artifactId>lookout-client-parent</artifactId>
9-
<version>1.4.3</version>
9+
<version>1.4.4</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

client/lookout-common/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.alipay.sofa.lookout</groupId>
88
<artifactId>lookout-client-parent</artifactId>
9-
<version>1.4.3</version>
9+
<version>1.4.4</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

client/lookout-core/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.alipay.sofa.lookout</groupId>
88
<artifactId>lookout-client-parent</artifactId>
9-
<version>1.4.3</version>
9+
<version>1.4.4</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

client/lookout-ext-jvm/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.alipay.sofa.lookout</groupId>
88
<artifactId>lookout-client-parent</artifactId>
9-
<version>1.4.3</version>
9+
<version>1.4.4</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

client/lookout-ext-jvm/src/main/java/com/alipay/lookout/jvm/JvmSystemPropertiesInfoMetricImporter.java

+26-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919
import com.alipay.lookout.api.Id;
2020
import com.alipay.lookout.api.Registry;
21-
import com.alipay.lookout.api.info.Info;
21+
import com.alipay.lookout.api.info.AutoPollFriendlyInfo;
22+
import com.alipay.lookout.api.info.AutoPollSuggestion;
2223
import com.alipay.lookout.spi.MetricsImporter;
2324

2425
import java.util.Map;
@@ -32,15 +33,37 @@ public class JvmSystemPropertiesInfoMetricImporter implements MetricsImporter {
3233
@Override
3334
public void register(Registry registry) {
3435
Id id = registry.createId(LookoutIdNameConstants.JVM_SYSTEM_PROP_NAME);
35-
registry.info(id, new Info<Properties>() {
36+
registry.info(id, new AutoPollFriendlyInfo<Properties>() {
37+
@Override
38+
public AutoPollSuggestion autoPollSuggest() {
39+
return AutoPollSuggestion.POLL_WHEN_UPDATED;
40+
}
41+
42+
@Override
43+
public long lastModifiedTime() {
44+
//only report once on startup
45+
return -1;
46+
}
47+
3648
@Override
3749
public Properties value() {
3850
return System.getProperties();
3951
}
4052
});
4153

4254
Id envId = registry.createId(LookoutIdNameConstants.JVM_SYSTEM_ENV_NAME);
43-
registry.info(envId, new Info<Map<String, String>>() {
55+
registry.info(envId, new AutoPollFriendlyInfo<Map<String, String>>() {
56+
@Override
57+
public AutoPollSuggestion autoPollSuggest() {
58+
return AutoPollSuggestion.POLL_WHEN_UPDATED;
59+
}
60+
61+
@Override
62+
public long lastModifiedTime() {
63+
//only report once on startup
64+
return -1;
65+
}
66+
4467
@Override
4568
public Map<String, String> value() {
4669
return System.getenv();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package com.alipay.lookout.jvm;
18+
19+
import com.alipay.lookout.api.Id;
20+
import com.alipay.lookout.api.Registry;
21+
import com.alipay.lookout.core.DefaultRegistry;
22+
import com.alipay.lookout.core.InfoWrapper;
23+
import org.junit.Test;
24+
25+
import static org.junit.Assert.assertEquals;
26+
27+
/**
28+
* JvmSystemPropertiesInfoMetricImporter Tester.
29+
*
30+
* @author <guanchao.ygc>
31+
* @version 1.0
32+
* @since <pre>07/03/2018</pre>
33+
*/
34+
public class JvmSystemPropertiesInfoMetricImporterTest {
35+
36+
/**
37+
* Method: register(Registry registry)
38+
*/
39+
@Test
40+
public void testRegister() throws Exception {
41+
Registry registry = new DefaultRegistry();
42+
JvmSystemPropertiesInfoMetricImporter jvmSystemPropertiesInfoMetricImporter = new JvmSystemPropertiesInfoMetricImporter();
43+
jvmSystemPropertiesInfoMetricImporter.register(registry);
44+
Id idSys = registry.createId(LookoutIdNameConstants.JVM_SYSTEM_PROP_NAME);
45+
InfoWrapper infoWrapper = registry.get(idSys);
46+
assertEquals(System.getProperties(), infoWrapper.value());
47+
Id envId = registry.createId(LookoutIdNameConstants.JVM_SYSTEM_ENV_NAME);
48+
InfoWrapper envWrapper = registry.get(envId);
49+
assertEquals(System.getenv(), envWrapper.value());
50+
}
51+
}

client/lookout-ext-os/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.alipay.sofa.lookout</groupId>
77
<artifactId>lookout-client-parent</artifactId>
8-
<version>1.4.3</version>
8+
<version>1.4.4</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111

client/lookout-reg-dropwizard/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.alipay.sofa.lookout</groupId>
88
<artifactId>lookout-client-parent</artifactId>
9-
<version>1.4.3</version>
9+
<version>1.4.4</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

client/lookout-reg-prometheus/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.alipay.sofa.lookout</groupId>
88
<artifactId>lookout-client-parent</artifactId>
9-
<version>1.4.3</version>
9+
<version>1.4.4</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

client/lookout-reg-server/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.alipay.sofa.lookout</groupId>
88
<artifactId>lookout-client-parent</artifactId>
9-
<version>1.4.3</version>
9+
<version>1.4.4</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

client/lookout-sofa-boot-starter/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.alipay.sofa.lookout</groupId>
88
<artifactId>lookout-client-parent</artifactId>
9-
<version>1.4.3</version>
9+
<version>1.4.4</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

client/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.alipay.sofa.lookout</groupId>
77
<artifactId>lookout-client-parent</artifactId>
8-
<version>1.4.3</version>
8+
<version>1.4.4</version>
99
<packaging>pom</packaging>
1010
<name>${project.groupId}:${project.artifactId}</name>
1111
<description>It is a library which allows you to instrument your app with custom metrics</description>

0 commit comments

Comments
 (0)