diff --git a/apm-collector-3.2.3/apm-collector-boot/src/main/assembly/assembly.xml b/apm-collector-3.2.3/apm-collector-boot/src/main/assembly/assembly.xml
index 4c09e75d4f955ecd5cb5e49d77bd68d830312bf4..b1e6e3ec11bc3a98e67eb01b694ecd50b7e9914d 100644
--- a/apm-collector-3.2.3/apm-collector-boot/src/main/assembly/assembly.xml
+++ b/apm-collector-3.2.3/apm-collector-boot/src/main/assembly/assembly.xml
@@ -56,13 +56,5 @@
/config
-
-
- ${project.build.directory}
- /libs
-
- ${build.finalName}.jar
-
-
diff --git a/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/ModuleManager.java b/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/ModuleManager.java
index 838b564e52f432d13a222fd0492ebf64bc82ed2a..fc78ce3c2d574d84a9aabbfe008681d4a05db725 100644
--- a/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/ModuleManager.java
+++ b/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/ModuleManager.java
@@ -31,7 +31,7 @@ import java.util.ServiceLoader;
*/
public class ModuleManager {
private Map loadedModules = new HashMap<>();
- private boolean isServiceInstrument = false;
+ private boolean isServiceInstrument = true;
/**
* Init the given modules
diff --git a/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/ModuleProvider.java b/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/ModuleProvider.java
index 2b48ecbec7f1681e6b42a208054f815c79c2a9f3..35822410547fc450f5d84bd1b345e6759c8d0f4b 100644
--- a/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/ModuleProvider.java
+++ b/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/ModuleProvider.java
@@ -96,7 +96,7 @@ public abstract class ModuleProvider {
Service service) throws ServiceNotProvidedException {
if (serviceType.isInstance(service)) {
if (manager.isServiceInstrument()) {
- service = ServiceInstrumentation.INSTANCE.buildServiceUnderMonitor(service);
+ service = ServiceInstrumentation.INSTANCE.buildServiceUnderMonitor(module.name(), name(), service);
}
this.services.put(serviceType, service);
} else {
diff --git a/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/instrument/MetricCollector.java b/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/instrument/MetricCollector.java
new file mode 100644
index 0000000000000000000000000000000000000000..00c8b16172420bb0dc5e8755abb772bb4f2dac01
--- /dev/null
+++ b/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/instrument/MetricCollector.java
@@ -0,0 +1,171 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed 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.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.collector.core.module.instrument;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The MetricCollector
collects the service metrics by Module/Provider/Service structure.
+ */
+public enum MetricCollector implements Runnable {
+ INSTANCE;
+
+ private final Logger logger = LoggerFactory.getLogger(MetricCollector.class);
+ private HashMap modules = new HashMap<>();
+
+ MetricCollector() {
+ ScheduledExecutorService service = Executors
+ .newSingleThreadScheduledExecutor();
+ service.scheduleAtFixedRate(this, 10, 60, TimeUnit.SECONDS);
+ }
+
+ @Override
+ public void run() {
+ if (!logger.isDebugEnabled()) {
+ return;
+ }
+ StringBuilder report = new StringBuilder();
+ report.append("\n");
+ report.append("##################################################################################################################\n");
+ report.append("# Collector Service Report #\n");
+ report.append("##################################################################################################################\n");
+ modules.forEach((moduleName, moduleMetric) -> {
+ report.append(moduleName).append(":\n");
+ moduleMetric.providers.forEach((providerName, providerMetric) -> {
+ report.append("\t").append(providerName).append(":\n");
+ providerMetric.services.forEach((serviceName, serviceMetric) -> {
+ serviceMetric.methodMetrics.forEach((method, metric) -> {
+ report.append("\t\t").append(method).append(":\n");
+ report.append("\t\t\t").append(metric).append("\n");
+ serviceMetric.methodMetrics.put(method, new ServiceMethodMetric());
+ });
+ });
+ });
+ });
+
+ logger.debug(report.toString());
+
+ }
+
+ ServiceMetric registerService(String module, String provider, String service) {
+ return initIfAbsent(module).initIfAbsent(provider).initIfAbsent(service);
+ }
+
+ private ModuleMetric initIfAbsent(String moduleName) {
+ if (!modules.containsKey(moduleName)) {
+ ModuleMetric metric = new ModuleMetric(moduleName);
+ modules.put(moduleName, metric);
+ return metric;
+ }
+ return modules.get(moduleName);
+ }
+
+ private class ModuleMetric {
+ private String moduleName;
+ private HashMap providers = new HashMap<>();
+
+ public ModuleMetric(String moduleName) {
+ this.moduleName = moduleName;
+ }
+
+ private ProviderMetric initIfAbsent(String providerName) {
+ if (!providers.containsKey(providerName)) {
+ ProviderMetric metric = new ProviderMetric(providerName);
+ providers.put(providerName, metric);
+ return metric;
+ }
+ return providers.get(providerName);
+ }
+ }
+
+ private class ProviderMetric {
+ private String providerName;
+ private HashMap services = new HashMap<>();
+
+ public ProviderMetric(String providerName) {
+ this.providerName = providerName;
+ }
+
+ private ServiceMetric initIfAbsent(String serviceName) {
+ if (!services.containsKey(serviceName)) {
+ ServiceMetric metric = new ServiceMetric(serviceName);
+ services.put(serviceName, metric);
+ return metric;
+ }
+ return services.get(serviceName);
+ }
+ }
+
+ class ServiceMetric {
+ private String serviceName;
+ private ConcurrentHashMap methodMetrics = new ConcurrentHashMap<>();
+
+ public ServiceMetric(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ void trace(Method method, long nano, boolean occurException) {
+ if (logger.isDebugEnabled()) {
+ ServiceMethodMetric metric = methodMetrics.get(method);
+ if (metric == null) {
+ ServiceMethodMetric methodMetric = new ServiceMethodMetric();
+ methodMetrics.putIfAbsent(method, methodMetric);
+ metric = methodMetrics.get(method);
+ }
+ metric.add(nano, occurException);
+ }
+ }
+ }
+
+ private class ServiceMethodMetric {
+ private AtomicLong totalTimeNano;
+ private AtomicLong counter;
+ private AtomicLong errorCounter;
+
+ public ServiceMethodMetric() {
+ totalTimeNano = new AtomicLong(0);
+ counter = new AtomicLong(0);
+ errorCounter = new AtomicLong(0);
+ }
+
+ private void add(long nano, boolean occurException) {
+ totalTimeNano.addAndGet(nano);
+ counter.incrementAndGet();
+ if (occurException)
+ errorCounter.incrementAndGet();
+ }
+
+ @Override public String toString() {
+ if (counter.longValue() == 0) {
+ return "Avg=N/A";
+ }
+ return "Avg=" + (totalTimeNano.longValue() / counter.longValue()) + " (nano)" +
+ ", Success Rate=" + (counter.longValue() - errorCounter.longValue()) * 100 / counter.longValue() +
+ "%";
+ }
+ }
+}
diff --git a/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/instrument/ServiceInstrumentation.java b/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/instrument/ServiceInstrumentation.java
index 1b85a8b6c6e51be88d8afbbd7563fe0438371d7f..a41a6232d06420671b5a8c4d3e5e9ddd780ac88c 100644
--- a/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/instrument/ServiceInstrumentation.java
+++ b/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/instrument/ServiceInstrumentation.java
@@ -31,6 +31,9 @@ import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.not;
/**
+ * The ServiceInstrumentation
create the dynamic service implementations based on the provider
+ * implementation. So the new implementation will report performance metric to {@link MetricCollector}.
+ *
* @author wu-sheng
*/
public enum ServiceInstrumentation {
@@ -39,8 +42,8 @@ public enum ServiceInstrumentation {
private final Logger logger = LoggerFactory.getLogger(ServiceInstrumentation.class);
private ElementMatcher super MethodDescription> excludeObjectMethodsMatcher;
- public Service buildServiceUnderMonitor(Service implementation) {
- if (TracedService.class.isInstance(implementation)) {
+ public Service buildServiceUnderMonitor(String moduleName, String providerName, Service implementation) {
+ if (implementation instanceof TracedService) {
// Duplicate service instrument, ignore.
return implementation;
}
@@ -48,7 +51,7 @@ public enum ServiceInstrumentation {
return new ByteBuddy().subclass(implementation.getClass())
.implement(TracedService.class)
.method(getDefaultMatcher()).intercept(
- MethodDelegation.withDefaultConfiguration().to(new ServiceMetricCollector())
+ MethodDelegation.withDefaultConfiguration().to(new ServiceMetricTracing(moduleName, providerName, implementation.getClass().getName()))
).make().load(getClass().getClassLoader()
).getLoaded().newInstance();
} catch (InstantiationException e) {
diff --git a/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/instrument/ServiceMetricCollector.java b/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/instrument/ServiceMetricTracing.java
similarity index 68%
rename from apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/instrument/ServiceMetricCollector.java
rename to apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/instrument/ServiceMetricTracing.java
index 2da824857b4e80d2eb1c864f81f1ad3e1bd29a08..1f99ffc94f39279c3deab73d11d7ed3b47bac404 100644
--- a/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/instrument/ServiceMetricCollector.java
+++ b/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/instrument/ServiceMetricTracing.java
@@ -29,7 +29,12 @@ import net.bytebuddy.implementation.bind.annotation.This;
/**
* @author wu-sheng
*/
-public class ServiceMetricCollector {
+public class ServiceMetricTracing {
+ private MetricCollector.ServiceMetric serviceMetric;
+
+ public ServiceMetricTracing(String module, String provider, String service) {
+ serviceMetric = MetricCollector.INSTANCE.registerService(module, provider, service);
+ }
@RuntimeType
public Object intercept(@This Object obj,
@@ -37,6 +42,17 @@ public class ServiceMetricCollector {
@SuperCall Callable> zuper,
@Origin Method method
) throws Throwable {
- return zuper.call();
+ boolean occurError = false;
+ long startNano = System.nanoTime();
+ long endNano;
+ try {
+ return zuper.call();
+ } catch (Throwable t) {
+ occurError = true;
+ throw t;
+ } finally {
+ endNano = System.nanoTime();
+ serviceMetric.trace(method, endNano - startNano, occurError);
+ }
}
}
diff --git a/apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleABusiness1Impl.java b/apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleABusiness1Impl.java
new file mode 100644
index 0000000000000000000000000000000000000000..407bc31c6261343d9ffeb2b4ba2b2fe37a79c210
--- /dev/null
+++ b/apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleABusiness1Impl.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed 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.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.collector.core.module;
+
+/**
+ * @author wu-sheng
+ */
+public class ModuleABusiness1Impl implements BaseModuleA.ServiceABusiness1 {
+
+ @Override public void print() {
+ }
+}
diff --git a/apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleABusiness2Impl.java b/apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleABusiness2Impl.java
new file mode 100644
index 0000000000000000000000000000000000000000..36565861bef5518d1b9dea8b30d8531630b471fb
--- /dev/null
+++ b/apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleABusiness2Impl.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed 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.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.collector.core.module;
+
+/**
+ * @author wu-sheng
+ */
+public class ModuleABusiness2Impl implements BaseModuleA.ServiceABusiness2 {
+
+}
diff --git a/apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleAProvider.java b/apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleAProvider.java
index 4fcf7827973528d2cf3bc1e330051d7be6b5fa4d..332af247c695fb8afddcb7ecb52143239c97d82d 100644
--- a/apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleAProvider.java
+++ b/apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleAProvider.java
@@ -33,11 +33,11 @@ public class ModuleAProvider extends ModuleProvider {
}
@Override public void prepare(Properties config) throws ServiceNotProvidedException {
- this.registerServiceImplementation(BaseModuleA.ServiceABusiness1.class, new Business1());
+ this.registerServiceImplementation(BaseModuleA.ServiceABusiness1.class, new ModuleABusiness1Impl());
}
@Override public void start(Properties config) throws ServiceNotProvidedException {
- this.registerServiceImplementation(BaseModuleA.ServiceABusiness2.class, new Business2());
+ this.registerServiceImplementation(BaseModuleA.ServiceABusiness2.class, new ModuleABusiness2Impl());
}
@Override public void notifyAfterCompleted() throws ServiceNotProvidedException {
@@ -47,14 +47,4 @@ public class ModuleAProvider extends ModuleProvider {
@Override public String[] requiredModules() {
return new String[0];
}
-
- public class Business1 implements BaseModuleA.ServiceABusiness1 {
-
- @Override public void print() {
- }
- }
-
- public class Business2 implements BaseModuleA.ServiceABusiness2 {
-
- }
}
diff --git a/apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleBBusiness1Impl.java b/apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleBBusiness1Impl.java
new file mode 100644
index 0000000000000000000000000000000000000000..f5e017da458e05b1ba85f87c3baf7a8d50efd928
--- /dev/null
+++ b/apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleBBusiness1Impl.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed 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.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.collector.core.module;
+
+/**
+ * @author wu-sheng
+ */
+public class ModuleBBusiness1Impl implements BaseModuleB.ServiceBBusiness1 {
+}
diff --git a/apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleBBusiness2Impl.java b/apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleBBusiness2Impl.java
new file mode 100644
index 0000000000000000000000000000000000000000..a0af96a89f62eb1ef286218f5a216f223cefa286
--- /dev/null
+++ b/apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleBBusiness2Impl.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed 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.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.collector.core.module;
+
+/**
+ * @author wu-sheng
+ */
+public class ModuleBBusiness2Impl implements BaseModuleB.ServiceBBusiness2 {
+}
diff --git a/apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleBProvider.java b/apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleBProvider.java
index d846028573122faabb2ffb558227f4ba974577d4..3b5066340efd6b6fefe52354f7ea92bcac7fb220 100644
--- a/apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleBProvider.java
+++ b/apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleBProvider.java
@@ -33,11 +33,11 @@ public class ModuleBProvider extends ModuleProvider {
}
@Override public void prepare(Properties config) throws ServiceNotProvidedException {
- this.registerServiceImplementation(BaseModuleB.ServiceBBusiness1.class, new Business1());
+ this.registerServiceImplementation(BaseModuleB.ServiceBBusiness1.class, new ModuleBBusiness1Impl());
}
@Override public void start(Properties config) throws ServiceNotProvidedException {
- this.registerServiceImplementation(BaseModuleB.ServiceBBusiness2.class, new Business2());
+ this.registerServiceImplementation(BaseModuleB.ServiceBBusiness2.class, new ModuleBBusiness2Impl());
}
@Override public void notifyAfterCompleted() throws ServiceNotProvidedException {
@@ -47,12 +47,4 @@ public class ModuleBProvider extends ModuleProvider {
@Override public String[] requiredModules() {
return new String[0];
}
-
- public class Business1 implements BaseModuleB.ServiceBBusiness1 {
-
- }
-
- public class Business2 implements BaseModuleB.ServiceBBusiness2 {
-
- }
}
diff --git a/apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleManagerTest.java b/apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleManagerTest.java
index 0874c9569af99ae7ded71fded455d273f8a01371..5965e1025392c7fe8cd0d0de6c69a162d8d12c59 100644
--- a/apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleManagerTest.java
+++ b/apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleManagerTest.java
@@ -30,30 +30,47 @@ public class ModuleManagerTest {
public void testInit() throws ServiceNotProvidedException, ModuleNotFoundException, ProviderNotFoundException, DuplicateProviderException {
ApplicationConfiguration configuration = new ApplicationConfiguration();
configuration.addModule("Test").addProviderConfiguration("TestModule-Provider", null);
- configuration.addModule("BaseA").addProviderConfiguration("P-A",null);
- configuration.addModule("BaseB").addProviderConfiguration("P-B",null);
+ configuration.addModule("BaseA").addProviderConfiguration("P-A", null);
+ configuration.addModule("BaseB").addProviderConfiguration("P-B", null);
ModuleManager manager = new ModuleManager();
manager.init(configuration);
BaseModuleA.ServiceABusiness1 serviceABusiness1 = manager.find("BaseA").provider().getService(BaseModuleA.ServiceABusiness1.class);
- serviceABusiness1.print();
+ Assert.assertTrue(serviceABusiness1 != null);
}
- //@Test
+ @Test
public void testInstrument() throws ServiceNotProvidedException, ModuleNotFoundException, ProviderNotFoundException, DuplicateProviderException {
ApplicationConfiguration configuration = new ApplicationConfiguration();
configuration.addModule("Test").addProviderConfiguration("TestModule-Provider", null);
- configuration.addModule("BaseA").addProviderConfiguration("P-A",null);
- configuration.addModule("BaseB").addProviderConfiguration("P-B",null);
+ configuration.addModule("BaseA").addProviderConfiguration("P-A", null);
+ configuration.addModule("BaseB").addProviderConfiguration("P-B", null);
ModuleManager manager = new ModuleManager();
manager.setServiceInstrument(true);
manager.init(configuration);
- BaseModuleA.ServiceABusiness1 serviceABusiness1 = manager.find("BaseA").provider().getService(BaseModuleA.ServiceABusiness1.class);
- serviceABusiness1.print();
+ BaseModuleA.ServiceABusiness1 serviceABusiness1 = manager.find("BaseA").getService(BaseModuleA.ServiceABusiness1.class);
Assert.assertTrue(serviceABusiness1 instanceof TracedService);
+
+// for (int i = 0; i < 10000; i++)
+// serviceABusiness1.print();
+//
+// try {
+// Thread.sleep(60 * 1000L);
+// } catch (InterruptedException e) {
+// e.printStackTrace();
+// }
+//
+// for (int i = 0; i < 10000; i++)
+// serviceABusiness1.print();
+//
+// try {
+// Thread.sleep(120 * 1000L);
+// } catch (InterruptedException e) {
+// e.printStackTrace();
+// }
}
}
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/jvm/memorypool/CMSCollectorModule.java b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/jvm/memorypool/CMSCollectorModule.java
index edf086f8ff5361fca73467d64d411d59b6f3e8c0..f672abc66d369ee8ca3bd164d9751789fc0e0ac7 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/jvm/memorypool/CMSCollectorModule.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/jvm/memorypool/CMSCollectorModule.java
@@ -29,27 +29,27 @@ public class CMSCollectorModule extends MemoryPoolModule {
super(beans);
}
- @Override protected String getPermName() {
- return "CMS Perm Gen";
+ @Override protected String[] getPermNames() {
+ return new String[] {"CMS Perm Gen"};
}
- @Override protected String getCodeCacheName() {
- return "Code Cache";
+ @Override protected String[] getCodeCacheNames() {
+ return new String[] {"Code Cache"};
}
- @Override protected String getEdenName() {
- return "Par Eden Space";
+ @Override protected String[] getEdenNames() {
+ return new String[] {"Par Eden Space"};
}
- @Override protected String getOldName() {
- return "CMS Old Gen";
+ @Override protected String[] getOldNames() {
+ return new String[] {"CMS Old Gen"};
}
- @Override protected String getSurvivorName() {
- return "Par Survivor Space";
+ @Override protected String[] getSurvivorNames() {
+ return new String[] {"Par Survivor Space"};
}
- @Override protected String getMetaspaceName() {
- return "Metaspace";
+ @Override protected String[] getMetaspaceNames() {
+ return new String[] {"Metaspace"};
}
}
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/jvm/memorypool/G1CollectorModule.java b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/jvm/memorypool/G1CollectorModule.java
index 60a722ceaacda9fc9ea73827699259d3b11eb332..728d34e58f1640007ccb41efcd2f897db75d7586 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/jvm/memorypool/G1CollectorModule.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/jvm/memorypool/G1CollectorModule.java
@@ -29,27 +29,27 @@ public class G1CollectorModule extends MemoryPoolModule {
super(beans);
}
- @Override protected String getPermName() {
- return "G1 Perm Gen";
+ @Override protected String[] getPermNames() {
+ return new String[] {"G1 Perm Gen"};
}
- @Override protected String getCodeCacheName() {
- return "Code Cache";
+ @Override protected String[] getCodeCacheNames() {
+ return new String[] {"Code Cache"};
}
- @Override protected String getEdenName() {
- return "G1 Eden Space";
+ @Override protected String[] getEdenNames() {
+ return new String[] {"G1 Eden Space"};
}
- @Override protected String getOldName() {
- return "G1 Old Gen";
+ @Override protected String[] getOldNames() {
+ return new String[] {"G1 Old Gen"};
}
- @Override protected String getSurvivorName() {
- return "G1 Survivor Space";
+ @Override protected String[] getSurvivorNames() {
+ return new String[] {"G1 Survivor Space"};
}
- @Override protected String getMetaspaceName() {
- return "Metaspace";
+ @Override protected String[] getMetaspaceNames() {
+ return new String[] {"Metaspace"};
}
}
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/jvm/memorypool/MemoryPoolModule.java b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/jvm/memorypool/MemoryPoolModule.java
index f1914d36b05d0e8e39642a612de2558cf7d185e4..ef5cd8d560f8e1bac7cec03816204bedefa053c8 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/jvm/memorypool/MemoryPoolModule.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/jvm/memorypool/MemoryPoolModule.java
@@ -40,18 +40,18 @@ public abstract class MemoryPoolModule implements MemoryPoolMetricAccessor {
List poolList = new LinkedList();
for (MemoryPoolMXBean bean : beans) {
String name = bean.getName();
- PoolType type = null;
- if (name.equals(getCodeCacheName())) {
+ PoolType type;
+ if (contains(getCodeCacheNames(), name)) {
type = PoolType.CODE_CACHE_USAGE;
- } else if (name.equals(getEdenName())) {
+ } else if (contains(getEdenNames(), name)) {
type = PoolType.NEWGEN_USAGE;
- } else if (name.equals(getOldName())) {
+ } else if (contains(getOldNames(), name)) {
type = PoolType.OLDGEN_USAGE;
- } else if (name.equals(getSurvivorName())) {
+ } else if (contains(getSurvivorNames(), name)) {
type = PoolType.SURVIVOR_USAGE;
- } else if (name.equals(getMetaspaceName())) {
+ } else if (contains(getMetaspaceNames(), name)) {
type = PoolType.METASPACE_USAGE;
- } else if (name.equals(getPermName())) {
+ } else if (contains(getPermNames(), name)) {
type = PoolType.PERMGEN_USAGE;
} else {
continue;
@@ -68,15 +68,24 @@ public abstract class MemoryPoolModule implements MemoryPoolMetricAccessor {
return poolList;
}
- protected abstract String getPermName();
+ private boolean contains(String[] possibleNames, String name) {
+ for (String possibleName : possibleNames) {
+ if (name.equals(possibleName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected abstract String[] getPermNames();
- protected abstract String getCodeCacheName();
+ protected abstract String[] getCodeCacheNames();
- protected abstract String getEdenName();
+ protected abstract String[] getEdenNames();
- protected abstract String getOldName();
+ protected abstract String[] getOldNames();
- protected abstract String getSurvivorName();
+ protected abstract String[] getSurvivorNames();
- protected abstract String getMetaspaceName();
+ protected abstract String[] getMetaspaceNames();
}
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/jvm/memorypool/ParallelCollectorModule.java b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/jvm/memorypool/ParallelCollectorModule.java
index 66240a352b032511c19c670921fee1a037842ad9..6bbac35ca7164daac3b3c919de3c698d7c16ff65 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/jvm/memorypool/ParallelCollectorModule.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/jvm/memorypool/ParallelCollectorModule.java
@@ -30,27 +30,27 @@ public class ParallelCollectorModule extends MemoryPoolModule {
super(beans);
}
- @Override protected String getPermName() {
- return "PS Perm Gen";
+ @Override protected String[] getPermNames() {
+ return new String[] {"PS Perm Gen", "Compressed Class Space"};
}
- @Override protected String getCodeCacheName() {
- return "Code Cache";
+ @Override protected String[] getCodeCacheNames() {
+ return new String[] {"Code Cache"};
}
- @Override protected String getEdenName() {
- return "PS Eden Space";
+ @Override protected String[] getEdenNames() {
+ return new String[] {"PS Eden Space"};
}
- @Override protected String getOldName() {
- return "PS Old Gen";
+ @Override protected String[] getOldNames() {
+ return new String[] {"PS Old Gen"};
}
- @Override protected String getSurvivorName() {
- return "PS Survivor Space";
+ @Override protected String[] getSurvivorNames() {
+ return new String[] {"PS Survivor Space"};
}
- @Override protected String getMetaspaceName() {
- return "Metaspace";
+ @Override protected String[] getMetaspaceNames() {
+ return new String[] {"Metaspace"};
}
}
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/jvm/memorypool/SerialCollectorModule.java b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/jvm/memorypool/SerialCollectorModule.java
index 99a60dfed848affb1f3ac709b084b02dd5613e71..97b3e4b4f61bcdaa34ade122b5ed9164d7df315e 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/jvm/memorypool/SerialCollectorModule.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/jvm/memorypool/SerialCollectorModule.java
@@ -29,27 +29,27 @@ public class SerialCollectorModule extends MemoryPoolModule {
super(beans);
}
- @Override protected String getPermName() {
- return "Perm Gen";
+ @Override protected String[] getPermNames() {
+ return new String[] {"Perm Gen"};
}
- @Override protected String getCodeCacheName() {
- return "Code Cache";
+ @Override protected String[] getCodeCacheNames() {
+ return new String[] {"Code Cache"};
}
- @Override protected String getEdenName() {
- return "Eden Space";
+ @Override protected String[] getEdenNames() {
+ return new String[] {"Eden Space"};
}
- @Override protected String getOldName() {
- return "Tenured Gen";
+ @Override protected String[] getOldNames() {
+ return new String[] {"Tenured Gen"};
}
- @Override protected String getSurvivorName() {
- return "Survivor Space";
+ @Override protected String[] getSurvivorNames() {
+ return new String[] {"Survivor Space"};
}
- @Override protected String getMetaspaceName() {
- return "Metaspace";
+ @Override protected String[] getMetaspaceNames() {
+ return new String[] {"Metaspace"};
}
}