Skip to content

Commit

Permalink
Fix System Properties and Env Updated Suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
杨冠超 committed Jul 3, 2018
1 parent 18631ef commit 8ee645b
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 14 deletions.
2 changes: 1 addition & 1 deletion client/lookout-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.alipay.sofa.lookout</groupId>
<artifactId>lookout-client-parent</artifactId>
<version>1.4.3</version>
<version>1.4.4</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion client/lookout-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.alipay.sofa.lookout</groupId>
<artifactId>lookout-client-parent</artifactId>
<version>1.4.3</version>
<version>1.4.4</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion client/lookout-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.alipay.sofa.lookout</groupId>
<artifactId>lookout-client-parent</artifactId>
<version>1.4.3</version>
<version>1.4.4</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion client/lookout-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.alipay.sofa.lookout</groupId>
<artifactId>lookout-client-parent</artifactId>
<version>1.4.3</version>
<version>1.4.4</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion client/lookout-ext-jvm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.alipay.sofa.lookout</groupId>
<artifactId>lookout-client-parent</artifactId>
<version>1.4.3</version>
<version>1.4.4</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

import com.alipay.lookout.api.Id;
import com.alipay.lookout.api.Registry;
import com.alipay.lookout.api.info.Info;
import com.alipay.lookout.api.info.AutoPollFriendlyInfo;
import com.alipay.lookout.api.info.AutoPollSuggestion;
import com.alipay.lookout.spi.MetricsImporter;

import java.util.Map;
Expand All @@ -32,15 +33,37 @@ public class JvmSystemPropertiesInfoMetricImporter implements MetricsImporter {
@Override
public void register(Registry registry) {
Id id = registry.createId(LookoutIdNameConstants.JVM_SYSTEM_PROP_NAME);
registry.info(id, new Info<Properties>() {
registry.info(id, new AutoPollFriendlyInfo<Properties>() {
@Override
public AutoPollSuggestion autoPollSuggest() {
return AutoPollSuggestion.POLL_WHEN_UPDATED;
}

@Override
public long lastModifiedTime() {
//only report once on startup
return -1;
}

@Override
public Properties value() {
return System.getProperties();
}
});

Id envId = registry.createId(LookoutIdNameConstants.JVM_SYSTEM_ENV_NAME);
registry.info(envId, new Info<Map<String, String>>() {
registry.info(envId, new AutoPollFriendlyInfo<Map<String, String>>() {
@Override
public AutoPollSuggestion autoPollSuggest() {
return AutoPollSuggestion.POLL_WHEN_UPDATED;
}

@Override
public long lastModifiedTime() {
//only report once on startup
return -1;
}

@Override
public Map<String, String> value() {
return System.getenv();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alipay.lookout.jvm;

import com.alipay.lookout.api.Id;
import com.alipay.lookout.api.Registry;
import com.alipay.lookout.core.DefaultRegistry;
import com.alipay.lookout.core.InfoWrapper;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
* JvmSystemPropertiesInfoMetricImporter Tester.
*
* @author <guanchao.ygc>
* @version 1.0
* @since <pre>07/03/2018</pre>
*/
public class JvmSystemPropertiesInfoMetricImporterTest {

/**
* Method: register(Registry registry)
*/
@Test
public void testRegister() throws Exception {
Registry registry = new DefaultRegistry();
JvmSystemPropertiesInfoMetricImporter jvmSystemPropertiesInfoMetricImporter = new JvmSystemPropertiesInfoMetricImporter();
jvmSystemPropertiesInfoMetricImporter.register(registry);
Id idSys = registry.createId(LookoutIdNameConstants.JVM_SYSTEM_PROP_NAME);
InfoWrapper infoWrapper = registry.get(idSys);
assertEquals(System.getProperties(), infoWrapper.value());
Id envId = registry.createId(LookoutIdNameConstants.JVM_SYSTEM_ENV_NAME);
InfoWrapper envWrapper = registry.get(envId);
assertEquals(System.getenv(), envWrapper.value());
}
}
2 changes: 1 addition & 1 deletion client/lookout-ext-os/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.alipay.sofa.lookout</groupId>
<artifactId>lookout-client-parent</artifactId>
<version>1.4.3</version>
<version>1.4.4</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion client/lookout-reg-dropwizard/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.alipay.sofa.lookout</groupId>
<artifactId>lookout-client-parent</artifactId>
<version>1.4.3</version>
<version>1.4.4</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion client/lookout-reg-prometheus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.alipay.sofa.lookout</groupId>
<artifactId>lookout-client-parent</artifactId>
<version>1.4.3</version>
<version>1.4.4</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion client/lookout-reg-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.alipay.sofa.lookout</groupId>
<artifactId>lookout-client-parent</artifactId>
<version>1.4.3</version>
<version>1.4.4</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion client/lookout-sofa-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.alipay.sofa.lookout</groupId>
<artifactId>lookout-client-parent</artifactId>
<version>1.4.3</version>
<version>1.4.4</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

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

0 comments on commit 8ee645b

Please sign in to comment.