Skip to content

Commit

Permalink
add asm instrument
Browse files Browse the repository at this point in the history
  • Loading branch information
jaehong-kim committed Aug 29, 2016
1 parent 7c396bc commit 2e2dfd9
Show file tree
Hide file tree
Showing 161 changed files with 11,168 additions and 67 deletions.
3 changes: 3 additions & 0 deletions agent/src/main/resources-local/pinpoint.config
Expand Up @@ -76,6 +76,9 @@ profiler.callstack.max.depth=64
# weather or not to propagate exceptions occurred at interceptor
profiler.interceptor.exception.propagate=false

# Allow bytecode framework
profiler.instrument.asm=false

# bytecode dump option
# java bytecode debug option
bytecode.dump.enable=false
Expand Down
3 changes: 3 additions & 0 deletions agent/src/main/resources-release/pinpoint.config
Expand Up @@ -72,6 +72,9 @@ profiler.callstack.max.depth=64
# weather or not to propagate exceptions occurred at interceptor
profiler.interceptor.exception.propagate=false

# Allow bytecode framework
profiler.instrument.asm=false

# bytecode dump option
# java bytecode debug option
bytecode.dump.enable=false
Expand Down
Expand Up @@ -64,6 +64,9 @@ profiler.callstack.max.depth=64
# weather or not to propagate exceptions occurred at interceptor
profiler.interceptor.exception.propagate=false

# Allow bytecode framework
profiler.instrument.asm=false

# java bytecode dump option
bytecode.dump.enable=false
#bytecode.dump.classlist=com.pinpoint.user.UserService,com.pinpoint.debug.TestClass
Expand Down
3 changes: 3 additions & 0 deletions agent/src/test/resources/pinpoint-disabled-plugin-test.config
Expand Up @@ -50,6 +50,9 @@ profiler.agentInfo.send.retry.interval=300000
# Allows TCP data command
profiler.tcpdatasender.command.accept.enable=true

# Allow bytecode framework
profiler.instrument.asm=false

###########################################################
# application type #
###########################################################
Expand Down
3 changes: 3 additions & 0 deletions agent/src/test/resources/pinpoint-spring-bean-test.config
Expand Up @@ -50,6 +50,9 @@ profiler.agentInfo.send.retry.interval=300000
# Allows TCP data command
profiler.tcpdatasender.command.accept.enable=true

# Allow bytecode framework
profiler.instrument.asm=false

###########################################################
# application type #
###########################################################
Expand Down
Expand Up @@ -86,6 +86,8 @@ public static ProfilerConfig load(String pinpointConfigFileName) throws IOExcept

private boolean profileEnable = false;

private boolean profileInstrumentASM = false;

private int interceptorRegistrySize = 1024*8;

private String collectorSpanServerIp = DEFAULT_IP;
Expand Down Expand Up @@ -564,12 +566,18 @@ public boolean isPropagateInterceptorException() {
return propagateInterceptorException;
}

@Override
public boolean isProfileInstrumentASM() {
return profileInstrumentASM;
}

// for test
void readPropertyValues() {
// TODO : use Properties' default value instead of using a temp variable.
final ValueResolver placeHolderResolver = new PlaceHolderResolver();

this.profileEnable = readBoolean("profiler.enable", true);
this.profileInstrumentASM = readBoolean("profiler.instrument.asm", false);

this.interceptorRegistrySize = readInt("profiler.interceptorregistry.size", 1024*8);

Expand Down
Expand Up @@ -169,6 +169,8 @@ public interface ProfilerConfig {

boolean isPropagateInterceptorException();

boolean isProfileInstrumentASM();

String readString(String propertyName, String defaultValue);

int readInt(String propertyName, int defaultValue);
Expand Down
@@ -0,0 +1,49 @@
/**
* Copyright 2016 NAVER Corp.
* 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.
*/
package com.navercorp.pinpoint.bootstrap.interceptor;

/**
* @author jaehong.kim
*/
public class ExceptionHandleApiIdAwareAroundInterceptor implements ApiIdAwareAroundInterceptor {

private final ApiIdAwareAroundInterceptor delegate;

public ExceptionHandleApiIdAwareAroundInterceptor(ApiIdAwareAroundInterceptor delegate) {
if (delegate == null) {
throw new NullPointerException("delegate must not be null");
}

this.delegate = delegate;
}

@Override
public void before(Object target, int apiId, Object[] args) {
try {
this.delegate.before(target, apiId, args);
} catch (Throwable t) {
InterceptorInvokerHelper.handleException(t);
}
}

@Override
public void after(Object target, int apiId, Object[] args, Object result, Throwable throwable) {
try {
this.delegate.after(target, apiId, args, result, throwable);
} catch (Throwable t) {
InterceptorInvokerHelper.handleException(t);
}
}
}
@@ -0,0 +1,49 @@
/**
* Copyright 2016 NAVER Corp.
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.navercorp.pinpoint.bootstrap.interceptor;

/**
* @author jaehong.kim
*/
public class ExceptionHandleAroundInterceptor implements AroundInterceptor {

private final AroundInterceptor delegate;

public ExceptionHandleAroundInterceptor(AroundInterceptor delegate) {
if (delegate == null) {
throw new NullPointerException("delegate must not be null");
}

this.delegate = delegate;
}

@Override
public void before(Object target, Object[] args) {
try {
this.delegate.before(target, args);
} catch (Throwable t) {
InterceptorInvokerHelper.handleException(t);
}
}

@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
try {
this.delegate.after(target, args, result, throwable);
} catch (Throwable t) {
InterceptorInvokerHelper.handleException(t);
}
}
}
@@ -0,0 +1,50 @@
/**
* Copyright 2016 NAVER Corp.
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.navercorp.pinpoint.bootstrap.interceptor;

/**
* @author jaehong.kim
*/
public class ExceptionHandleAroundInterceptor0 implements AroundInterceptor0 {

private final AroundInterceptor0 delegate;

public ExceptionHandleAroundInterceptor0(AroundInterceptor0 delegate) {
if (delegate == null) {
throw new NullPointerException("delegate must not be null");
}

this.delegate = delegate;
}

@Override
public void before(Object target) {
try {
this.delegate.before(target);
} catch (Throwable t) {
InterceptorInvokerHelper.handleException(t);
}

}

@Override
public void after(Object target, Object result, Throwable throwable) {
try {
this.delegate.after(target, result, throwable);
} catch (Throwable t) {
InterceptorInvokerHelper.handleException(t);
}
}
}
@@ -0,0 +1,49 @@
/**
* Copyright 2016 NAVER Corp.
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.navercorp.pinpoint.bootstrap.interceptor;

/**
* @author jaehong.kim
*/
public class ExceptionHandleAroundInterceptor1 implements AroundInterceptor1 {

private final AroundInterceptor1 delegate;

public ExceptionHandleAroundInterceptor1(AroundInterceptor1 delegate) {
if (delegate == null) {
throw new NullPointerException("delegate must not be null");
}

this.delegate = delegate;
}

@Override
public void before(Object target, Object arg0) {
try {
this.delegate.before(target, arg0);
} catch (Throwable t) {
InterceptorInvokerHelper.handleException(t);
}
}

@Override
public void after(Object target, Object arg0, Object result, Throwable throwable) {
try {
this.delegate.after(target, arg0, result, throwable);
} catch (Throwable t) {
InterceptorInvokerHelper.handleException(t);
}
}
}
@@ -0,0 +1,49 @@
/**
* Copyright 2016 NAVER Corp.
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.navercorp.pinpoint.bootstrap.interceptor;

/**
* @author jaehong.kim
*/
public class ExceptionHandleAroundInterceptor2 implements AroundInterceptor2 {

private final AroundInterceptor2 delegate;

public ExceptionHandleAroundInterceptor2(AroundInterceptor2 delegate) {
if (delegate == null) {
throw new NullPointerException("delegate must not be null");
}

this.delegate = delegate;
}

@Override
public void before(Object target, Object arg0, Object arg1) {
try {
this.delegate.before(target, arg0, arg1);
} catch (Throwable t) {
InterceptorInvokerHelper.handleException(t);
}
}

@Override
public void after(Object target, Object arg0, Object arg1, Object result, Throwable throwable) {
try {
this.delegate.after(target, arg0, arg1, result, throwable);
} catch (Throwable t) {
InterceptorInvokerHelper.handleException(t);
}
}
}
@@ -0,0 +1,49 @@
/**
* Copyright 2016 NAVER Corp.
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.navercorp.pinpoint.bootstrap.interceptor;

/**
* @author jaehong.kim
*/
public class ExceptionHandleAroundInterceptor3 implements AroundInterceptor3 {

private final AroundInterceptor3 delegate;

public ExceptionHandleAroundInterceptor3(AroundInterceptor3 delegate) {
if (delegate == null) {
throw new NullPointerException("delegate must not be null");
}

this.delegate = delegate;
}

@Override
public void before(Object target, Object arg0, Object arg1, Object arg2) {
try {
this.delegate.before(target, arg0, arg1, arg2);
} catch (Throwable t) {
InterceptorInvokerHelper.handleException(t);
}
}

@Override
public void after(Object target, Object arg0, Object arg1, Object arg2, Object result, Throwable throwable) {
try {
this.delegate.after(target, arg0, arg1, arg2, result, throwable);
} catch (Throwable t) {
InterceptorInvokerHelper.handleException(t);
}
}
}

0 comments on commit 2e2dfd9

Please sign in to comment.