Skip to content

Commit

Permalink
Changes follow suggestion.
Browse files Browse the repository at this point in the history
  • Loading branch information
weixiang committed Sep 14, 2024
1 parent 68e166f commit dfd0f1e
Show file tree
Hide file tree
Showing 31 changed files with 398 additions and 384 deletions.
9 changes: 0 additions & 9 deletions .github/actions/run/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,6 @@ runs:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-agent-test-run-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-agent-test-run-
- name: Install docker-compose
shell: bash
if: runner.os != 'Windows'
run: |
if ! command docker-compose 2>&1 > /dev/null; then
echo "Installing docker-compose"
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
fi
- name: Run Plugin Test ${{ inputs.test_case }}
shell: bash
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.apache.skywalking.apm.agent.core.logging.api.ILog;
import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
import org.apache.skywalking.apm.agent.core.sampling.SamplingService;
import org.apache.skywalking.apm.agent.core.so11y.AgentSO11Y;
import org.apache.skywalking.apm.agent.core.so11y.AgentSo11y;
import org.apache.skywalking.apm.util.StringUtil;

import static org.apache.skywalking.apm.agent.core.conf.Config.Agent.OPERATION_NAME_THRESHOLD;
Expand All @@ -53,7 +53,7 @@ private static AbstractTracerContext getOrCreate(String operationName, boolean f
if (LOGGER.isDebugEnable()) {
LOGGER.debug("No operation name, ignore this trace.");
}
AgentSO11Y.recordTracingContextCreate(forceSampling, true);
AgentSo11y.measureTracingContextCreation(forceSampling, true);
context = new IgnoredTracerContext();
} else {
if (EXTEND_SERVICE == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.apache.skywalking.apm.agent.core.remote.GRPCChannelManager;
import org.apache.skywalking.apm.agent.core.remote.GRPCChannelStatus;
import org.apache.skywalking.apm.agent.core.sampling.SamplingService;
import org.apache.skywalking.apm.agent.core.so11y.AgentSO11Y;
import org.apache.skywalking.apm.agent.core.so11y.AgentSo11y;
import org.apache.skywalking.apm.util.StringUtil;

@DefaultImplementor
Expand Down Expand Up @@ -82,22 +82,22 @@ public AbstractTracerContext createTraceContext(String operationName, boolean fo
* Don't trace anything if the backend is not available.
*/
if (!Config.Agent.KEEP_TRACING && GRPCChannelStatus.DISCONNECT.equals(status)) {
AgentSO11Y.recordTracingContextCreate(forceSampling, true);
AgentSo11y.measureTracingContextCreation(forceSampling, true);
return new IgnoredTracerContext();
}

int suffixIdx = operationName.lastIndexOf(".");
if (suffixIdx > -1 && ignoreSuffixSet.contains(operationName.substring(suffixIdx))) {
AgentSO11Y.recordTracingContextCreate(forceSampling, true);
AgentSo11y.measureTracingContextCreation(forceSampling, true);
context = new IgnoredTracerContext();
} else {
SamplingService samplingService = ServiceManager.INSTANCE.findService(SamplingService.class);
if (forceSampling || samplingService.trySampling(operationName)) {
AgentSO11Y.recordTracingContextCreate(forceSampling, false);
AgentSo11y.measureTracingContextCreation(forceSampling, false);
context = new TracingContext(operationName, spanLimitWatcher);
} else {
AgentSO11Y.recordTracingContextCreate(false, true);
AgentSO11Y.recordLeakedTracingContext(true);
AgentSo11y.measureTracingContextCreation(false, true);
AgentSo11y.measureLeakedTracingContext(true);
context = new IgnoredTracerContext();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
import org.apache.skywalking.apm.agent.core.context.trace.NoopSpan;
import org.apache.skywalking.apm.agent.core.profile.ProfileStatusContext;
import org.apache.skywalking.apm.agent.core.so11y.AgentSO11Y;
import org.apache.skywalking.apm.agent.core.so11y.AgentSo11y;

/**
* The <code>IgnoredTracerContext</code> represent a context should be ignored. So it just maintains the stack with an
Expand Down Expand Up @@ -117,7 +117,7 @@ public AbstractSpan activeSpan() {
public boolean stopSpan(AbstractSpan span) {
stackDepth--;
if (stackDepth == 0) {
AgentSO11Y.recordTracingContextFinish(true);
AgentSo11y.measureTracingContextCompletion(true);
ListenerManager.notifyFinish(this);
}
return stackDepth == 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
import org.apache.skywalking.apm.agent.core.profile.ProfileStatusContext;
import org.apache.skywalking.apm.agent.core.profile.ProfileTaskExecutionService;
import org.apache.skywalking.apm.agent.core.so11y.AgentSO11Y;
import org.apache.skywalking.apm.agent.core.so11y.AgentSo11y;
import org.apache.skywalking.apm.util.StringUtil;

import static org.apache.skywalking.apm.agent.core.conf.Config.Agent.CLUSTER;
Expand Down Expand Up @@ -463,9 +463,9 @@ private void finish() {
if (isFinishedInMainThread && (!isRunningInAsyncMode || asyncSpanCounter == 0)) {
boolean limitMechanismWorking = isLimitMechanismWorking();
if (limitMechanismWorking) {
AgentSO11Y.recordLeakedTracingContext(false);
AgentSo11y.measureLeakedTracingContext(false);
}
AgentSO11Y.recordTracingContextFinish(false);
AgentSo11y.measureTracingContextCompletion(false);
TraceSegment finishedSegment = segment.finish(limitMechanismWorking);
TracingContext.ListenerManager.notifyFinish(finishedSegment);
running = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class BootstrapInstrumentBoost {
"org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.v2.MethodInvocationContext",

//SO11Y
"org.apache.skywalking.apm.agent.core.so11y.bootstrap.BootstrapPluginSO11Y"
"org.apache.skywalking.apm.agent.core.so11y.bootstrap.BootstrapPluginSo11y"
};

private static String INSTANCE_METHOD_DELEGATE_TEMPLATE = "org.apache.skywalking.apm.agent.core.plugin.bootstrap.template.InstanceMethodInterTemplate";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.BootstrapInterRuntimeAssist;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
import org.apache.skywalking.apm.agent.core.so11y.bootstrap.BootstrapPluginSO11Y;
import org.apache.skywalking.apm.agent.core.so11y.bootstrap.BootstrapPluginSo11y;

/**
* --------CLASS TEMPLATE---------
Expand All @@ -39,6 +39,7 @@
*/
public class ConstructorInterTemplate {

private static final String INTERCEPTOR_TYPE = "constructor";
/**
* This field is never set in the template, but has value in the runtime.
*/
Expand All @@ -50,9 +51,7 @@ public class ConstructorInterTemplate {

private static InstanceConstructorInterceptor INTERCEPTOR;
private static IBootstrapLog LOGGER;
private static BootstrapPluginSO11Y PLUGIN_SO11Y;

private static final String INTERCEPTOR_TYPE = "constructor";
private static BootstrapPluginSo11y PLUGIN_SO11Y;

/**
* Intercept the target constructor.
Expand All @@ -75,10 +74,10 @@ public static void intercept(@This Object obj, @AllArguments Object[] allArgumen
INTERCEPTOR.onConstruct(targetObject, allArguments);
} catch (Throwable t) {
LOGGER.error("ConstructorInter failure.", t);
PLUGIN_SO11Y.recordInterceptorError(PLUGIN_NAME, INTERCEPTOR_TYPE);
PLUGIN_SO11Y.error(PLUGIN_NAME, INTERCEPTOR_TYPE);
}
interceptorTimeCost += System.nanoTime() - startTime;
PLUGIN_SO11Y.recordInterceptorTimeCost(interceptorTimeCost);
PLUGIN_SO11Y.duration(interceptorTimeCost);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
import org.apache.skywalking.apm.agent.core.so11y.bootstrap.BootstrapPluginSO11Y;
import org.apache.skywalking.apm.agent.core.so11y.bootstrap.BootstrapPluginSo11y;

/**
* --------CLASS TEMPLATE---------
Expand All @@ -44,6 +44,7 @@
*/
public class InstanceMethodInterTemplate {

private static final String INTERCEPTOR_TYPE = "inst";
/**
* This field is never set in the template, but has value in the runtime.
*/
Expand All @@ -55,9 +56,7 @@ public class InstanceMethodInterTemplate {

private static InstanceMethodsAroundInterceptor INTERCEPTOR;
private static IBootstrapLog LOGGER;
private static BootstrapPluginSO11Y PLUGIN_SO11Y;

private static final String INTERCEPTOR_TYPE = "inst";
private static BootstrapPluginSo11y PLUGIN_SO11Y;

/**
* Intercept the target instance method.
Expand All @@ -78,7 +77,7 @@ public static Object intercept(@This Object obj, @AllArguments Object[] allArgum
prepare();

long interceptorTimeCost = 0L;
long beforeStartTime = System.nanoTime();
long startTimeOfMethodBeforeInter = System.nanoTime();
MethodInterceptResult result = new MethodInterceptResult();
try {
if (INTERCEPTOR != null) {
Expand All @@ -88,9 +87,9 @@ public static Object intercept(@This Object obj, @AllArguments Object[] allArgum
if (LOGGER != null) {
LOGGER.error(t, "class[{}] before method[{}] intercept failure", obj.getClass(), method.getName());
}
PLUGIN_SO11Y.recordInterceptorError(PLUGIN_NAME, INTERCEPTOR_TYPE);
PLUGIN_SO11Y.error(PLUGIN_NAME, INTERCEPTOR_TYPE);
}
interceptorTimeCost += System.nanoTime() - beforeStartTime;
interceptorTimeCost += System.nanoTime() - startTimeOfMethodBeforeInter;

Object ret = null;
try {
Expand All @@ -100,7 +99,7 @@ public static Object intercept(@This Object obj, @AllArguments Object[] allArgum
ret = zuper.call();
}
} catch (Throwable t) {
long handleExceptionStartTime = System.nanoTime();
long startTimeOfMethodHandleExceptionInter = System.nanoTime();
try {
if (INTERCEPTOR != null) {
INTERCEPTOR.handleMethodException(targetObject, method, allArguments, method.getParameterTypes(), t);
Expand All @@ -109,12 +108,12 @@ public static Object intercept(@This Object obj, @AllArguments Object[] allArgum
if (LOGGER != null) {
LOGGER.error(t2, "class[{}] handle method[{}] exception failure", obj.getClass(), method.getName());
}
PLUGIN_SO11Y.recordInterceptorError(PLUGIN_NAME, INTERCEPTOR_TYPE);
PLUGIN_SO11Y.error(PLUGIN_NAME, INTERCEPTOR_TYPE);
}
interceptorTimeCost += System.nanoTime() - handleExceptionStartTime;
interceptorTimeCost += System.nanoTime() - startTimeOfMethodHandleExceptionInter;
throw t;
} finally {
long afterStartTime = System.nanoTime();
long startTimeOfMethodAfterInter = System.nanoTime();
try {
if (INTERCEPTOR != null) {
ret = INTERCEPTOR.afterMethod(targetObject, method, allArguments, method.getParameterTypes(), ret);
Expand All @@ -123,11 +122,11 @@ public static Object intercept(@This Object obj, @AllArguments Object[] allArgum
if (LOGGER != null) {
LOGGER.error(t, "class[{}] after method[{}] intercept failure", obj.getClass(), method.getName());
}
PLUGIN_SO11Y.recordInterceptorError(PLUGIN_NAME, INTERCEPTOR_TYPE);
PLUGIN_SO11Y.error(PLUGIN_NAME, INTERCEPTOR_TYPE);
}
interceptorTimeCost += System.nanoTime() - afterStartTime;
interceptorTimeCost += System.nanoTime() - startTimeOfMethodAfterInter;
}
PLUGIN_SO11Y.recordInterceptorTimeCost(interceptorTimeCost);
PLUGIN_SO11Y.duration(interceptorTimeCost);

return ret;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.OverrideCallable;
import org.apache.skywalking.apm.agent.core.so11y.bootstrap.BootstrapPluginSO11Y;
import org.apache.skywalking.apm.agent.core.so11y.bootstrap.BootstrapPluginSo11y;

/**
* --------CLASS TEMPLATE---------
Expand All @@ -44,6 +44,7 @@
*/
public class InstanceMethodInterWithOverrideArgsTemplate {

private static final String INTERCEPTOR_TYPE = "inst";
/**
* This field is never set in the template, but has value in the runtime.
*/
Expand All @@ -55,9 +56,7 @@ public class InstanceMethodInterWithOverrideArgsTemplate {

private static InstanceMethodsAroundInterceptor INTERCEPTOR;
private static IBootstrapLog LOGGER;
private static BootstrapPluginSO11Y PLUGIN_SO11Y;

private static final String INTERCEPTOR_TYPE = "inst";
private static BootstrapPluginSo11y PLUGIN_SO11Y;

/**
* Intercept the target instance method.
Expand All @@ -78,7 +77,7 @@ public static Object intercept(@This Object obj, @AllArguments Object[] allArgum
prepare();

long interceptorTimeCost = 0L;
long beforeStartTime = System.nanoTime();
long startTimeOfMethodBeforeInter = System.nanoTime();
MethodInterceptResult result = new MethodInterceptResult();
try {
if (INTERCEPTOR != null) {
Expand All @@ -88,9 +87,9 @@ public static Object intercept(@This Object obj, @AllArguments Object[] allArgum
if (LOGGER != null) {
LOGGER.error(t, "class[{}] before method[{}] intercept failure", obj.getClass(), method.getName());
}
PLUGIN_SO11Y.recordInterceptorError(PLUGIN_NAME, INTERCEPTOR_TYPE);
PLUGIN_SO11Y.error(PLUGIN_NAME, INTERCEPTOR_TYPE);
}
interceptorTimeCost += System.nanoTime() - beforeStartTime;
interceptorTimeCost += System.nanoTime() - startTimeOfMethodBeforeInter;

Object ret = null;
try {
Expand All @@ -100,7 +99,7 @@ public static Object intercept(@This Object obj, @AllArguments Object[] allArgum
ret = zuper.call(allArguments);
}
} catch (Throwable t) {
long handleExceptionStartTime = System.nanoTime();
long startTimeOfMethodHandleExceptionInter = System.nanoTime();
try {
if (INTERCEPTOR != null) {
INTERCEPTOR.handleMethodException(targetObject, method, allArguments, method.getParameterTypes(), t);
Expand All @@ -109,12 +108,12 @@ public static Object intercept(@This Object obj, @AllArguments Object[] allArgum
if (LOGGER != null) {
LOGGER.error(t2, "class[{}] handle method[{}] exception failure", obj.getClass(), method.getName());
}
PLUGIN_SO11Y.recordInterceptorError(PLUGIN_NAME, INTERCEPTOR_TYPE);
PLUGIN_SO11Y.error(PLUGIN_NAME, INTERCEPTOR_TYPE);
}
interceptorTimeCost += System.nanoTime() - handleExceptionStartTime;
interceptorTimeCost += System.nanoTime() - startTimeOfMethodHandleExceptionInter;
throw t;
} finally {
long afterStartTime = System.nanoTime();
long startTimeOfMethodAfterInter = System.nanoTime();
try {
if (INTERCEPTOR != null) {
ret = INTERCEPTOR.afterMethod(targetObject, method, allArguments, method.getParameterTypes(), ret);
Expand All @@ -123,11 +122,11 @@ public static Object intercept(@This Object obj, @AllArguments Object[] allArgum
if (LOGGER != null) {
LOGGER.error(t, "class[{}] after method[{}] intercept failure", obj.getClass(), method.getName());
}
PLUGIN_SO11Y.recordInterceptorError(PLUGIN_NAME, INTERCEPTOR_TYPE);
PLUGIN_SO11Y.error(PLUGIN_NAME, INTERCEPTOR_TYPE);
}
interceptorTimeCost += System.nanoTime() - afterStartTime;
interceptorTimeCost += System.nanoTime() - startTimeOfMethodAfterInter;
}
PLUGIN_SO11Y.recordInterceptorTimeCost(interceptorTimeCost);
PLUGIN_SO11Y.duration(interceptorTimeCost);

return ret;
}
Expand Down
Loading

0 comments on commit dfd0f1e

Please sign in to comment.