Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
06b809a
Add config to control tracing sql parameters
kezhenxu94 Jun 10, 2019
7f373ea
Fix codestyle
kezhenxu94 Jun 10, 2019
8e58e61
Merge branch 'master' into gh/2587
wu-sheng Jun 11, 2019
0f2529a
Trigger CI
kezhenxu94 Jun 12, 2019
7c78080
Merge branch 'master' into gh/2587
kezhenxu94 Jun 12, 2019
a5516e2
Merge branch 'master' into gh/2587
kezhenxu94 Jun 13, 2019
da4da6b
Merge remote-tracking branch 'apache/master' into gh/2587
kezhenxu94 Jun 14, 2019
c51b908
Remove dependencies
kezhenxu94 Jun 14, 2019
505ff47
Merge branch 'master' into gh/2587
kezhenxu94 Jun 15, 2019
94d01cc
Revert unexpected changes
kezhenxu94 Jun 15, 2019
c2fb828
Revert unexpected changes
kezhenxu94 Jun 15, 2019
34c35cd
Revert unexpected changes
kezhenxu94 Jun 15, 2019
78541b9
Add LinkedList test
kezhenxu94 Jun 15, 2019
cd72731
Trigger multiple Job
kezhenxu94 Jun 15, 2019
c37d04f
Trigger multiple Job
kezhenxu94 Jun 15, 2019
62ca76b
Trigger multiple Job
kezhenxu94 Jun 15, 2019
6ab0978
Update benchmark result
kezhenxu94 Jun 15, 2019
0d8bd0e
Update test
kezhenxu94 Jun 15, 2019
46a7bee
Improve performance
kezhenxu94 Jun 15, 2019
b8e312c
Remove duplicated codes
kezhenxu94 Jun 15, 2019
8324296
More defence
kezhenxu94 Jun 15, 2019
3bef760
Revert some unexpected changes
kezhenxu94 Jun 15, 2019
9c6f1e2
Add instrumentation declaration
kezhenxu94 Jun 15, 2019
438a48a
Revert unexpected chagnes
kezhenxu94 Jun 16, 2019
e608d46
Revert removed docs
kezhenxu94 Jun 16, 2019
ac32aef
Fix checkstyle
kezhenxu94 Jun 16, 2019
ff9fd5c
Merge branch 'master' into gh/2587
wu-sheng Jun 16, 2019
5c71284
Rename some classes
kezhenxu94 Jun 16, 2019
3c665b3
Merge branch 'master' into gh/2587
wu-sheng Jun 17, 2019
9e4f7d1
Fix 8.x bug
kezhenxu94 Jun 17, 2019
371cb70
Merge branch 'gh/2587' of github.com:kezhenxu94/incubator-skywalking …
kezhenxu94 Jun 17, 2019
71997bb
Merge branch 'master' into gh/2587
kezhenxu94 Jun 17, 2019
3431594
Merge branch 'master' into gh/2587
wu-sheng Jun 18, 2019
0cd8e45
Merge branch 'master' into gh/2587
wu-sheng Jun 18, 2019
beab2b0
Adjust class hierarchy
kezhenxu94 Jun 18, 2019
0bb26d6
Merge branch 'master' into gh/2587
wu-sheng Jun 18, 2019
562a601
Merge branch 'master' into gh/2587
wu-sheng Jun 18, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,21 @@ public static class Toolkit {
public static boolean USE_QUALIFIED_NAME_AS_OPERATION_NAME = false;
}

public static class MySQL {
/**
* If set to true, the parameters of the sql (typically {@link java.sql.PreparedStatement})
* would be collected.
*/
public static boolean TRACE_SQL_PARAMETERS = false;
/**
* For the sake of performance, SkyWalking won't save the entire parameters string into the tag,
* but only the first {@code SQL_PARAMETERS_MAX_LENGTH} characters.
*
* Set a negative number to save the complete parameter string to the tag.
*/
public static int SQL_PARAMETERS_MAX_LENGTH = 512;
}

public static class SolrJ {
/**
* If true, trace all the query parameters(include deleteByIds and deleteByQuery) in Solr query request, default is false.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* 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 org.apache.skywalking.apm.plugin.jdbc;

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.plugin.jdbc.define.Constants;
import org.apache.skywalking.apm.plugin.jdbc.define.StatementEnhanceInfos;

import java.lang.reflect.Method;

/**
* @author kezhenxu94
*/
public class JDBCPreparedStatementIgnorableSetterInterceptor implements InstanceMethodsAroundInterceptor {
@Override
public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments,
Class<?>[] argumentsTypes,
MethodInterceptResult result) throws Throwable {
final StatementEnhanceInfos statementEnhanceInfos = (StatementEnhanceInfos) objInst.getSkyWalkingDynamicField();
final int index = (Integer) allArguments[0];
statementEnhanceInfos.setParameter(index, Constants.SQL_PARAMETER_PLACEHOLDER);
}

@Override
public final Object afterMethod(EnhancedInstance objInst,
Method method,
Object[] allArguments,
Class<?>[] argumentsTypes,
Object ret) throws Throwable {
return ret;
}

@Override
public final void handleMethodException(EnhancedInstance objInst,
Method method,
Object[] allArguments,
Class<?>[] argumentsTypes,
Throwable t) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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 org.apache.skywalking.apm.plugin.jdbc;

import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
import org.apache.skywalking.apm.plugin.jdbc.define.Constants;

import static net.bytebuddy.matcher.ElementMatchers.named;

/**
* @author kezhenxu94
*/
public final class JDBCPreparedStatementNullSetterInstanceMethodsInterceptPoint implements InstanceMethodsInterceptPoint {
@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
return named("setNull");
}

@Override
public String getMethodsInterceptor() {
return Constants.PREPARED_STATEMENT_NULL_SETTER_METHODS_INTERCEPTOR;
}

@Override
public boolean isOverrideArgs() {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* 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 org.apache.skywalking.apm.plugin.jdbc;

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.plugin.jdbc.define.StatementEnhanceInfos;

import java.lang.reflect.Method;

/**
* @author kezhenxu94
*/
public class JDBCPreparedStatementNullSetterInterceptor implements InstanceMethodsAroundInterceptor {
@Override
public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments,
Class<?>[] argumentsTypes,
MethodInterceptResult result) throws Throwable {
final StatementEnhanceInfos statementEnhanceInfos = (StatementEnhanceInfos) objInst.getSkyWalkingDynamicField();
final int index = (Integer) allArguments[0];
statementEnhanceInfos.setParameter(index, "NULL");
}

@Override
public final Object afterMethod(EnhancedInstance objInst,
Method method,
Object[] allArguments,
Class<?>[] argumentsTypes,
Object ret) throws Throwable {
return ret;
}

@Override
public final void handleMethodException(EnhancedInstance objInst,
Method method,
Object[] allArguments,
Class<?>[] argumentsTypes,
Throwable t) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* 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 org.apache.skywalking.apm.plugin.jdbc;

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.plugin.jdbc.define.StatementEnhanceInfos;

import java.lang.reflect.Method;

/**
* @author kezhenxu94
*/
public class JDBCPreparedStatementSetterInterceptor implements InstanceMethodsAroundInterceptor {
@Override
public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments,
Class<?>[] argumentsTypes,
MethodInterceptResult result) throws Throwable {
final StatementEnhanceInfos statementEnhanceInfos = (StatementEnhanceInfos) objInst.getSkyWalkingDynamicField();
final int index = (Integer) allArguments[0];
final Object parameter = allArguments[1];
statementEnhanceInfos.setParameter(index, parameter);
}

@Override
public final Object afterMethod(EnhancedInstance objInst,
Method method,
Object[] allArguments,
Class<?>[] argumentsTypes,
Object ret) throws Throwable {
return ret;
}

@Override
public final void handleMethodException(EnhancedInstance objInst,
Method method,
Object[] allArguments,
Class<?>[] argumentsTypes,
Throwable t) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* 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 org.apache.skywalking.apm.plugin.jdbc;

import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
import org.apache.skywalking.apm.agent.core.conf.Config;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
import org.apache.skywalking.apm.plugin.jdbc.define.Constants;

import java.util.Set;

import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.none;
import static org.apache.skywalking.apm.plugin.jdbc.define.Constants.PS_IGNORABLE_SETTERS;
import static org.apache.skywalking.apm.plugin.jdbc.define.Constants.PS_SETTERS;

/**
* @author kezhenxu94
*/
public class PSSetterDefinitionOfJDBCInstrumentation implements InstanceMethodsInterceptPoint {
private final boolean ignorable;

public PSSetterDefinitionOfJDBCInstrumentation(boolean ignorable) {
this.ignorable = ignorable;
}

@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
ElementMatcher.Junction<MethodDescription> matcher = none();

if (Config.Plugin.MySQL.TRACE_SQL_PARAMETERS) {
final Set<String> setters = ignorable ? PS_IGNORABLE_SETTERS : PS_SETTERS;
for (String setter : setters) {
matcher = matcher.or(named(setter));
}
}

return matcher;
}

@Override
public String getMethodsInterceptor() {
return ignorable
? Constants.PREPARED_STATEMENT_IGNORABLE_SETTER_METHODS_INTERCEPTOR
: Constants.PREPARED_STATEMENT_SETTER_METHODS_INTERCEPTOR;
}

@Override
public boolean isOverrideArgs() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

package org.apache.skywalking.apm.plugin.jdbc.define;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class Constants {
public static final String CREATE_STATEMENT_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.jdbc.JDBCStatementInterceptor";

Expand All @@ -41,5 +45,41 @@ public class Constants {
public static final String CLOSE_METHOD_NAME = "close";

public static final String RELEASE_SAVE_POINT_METHOD_NAME = "releaseSavepoint";
public static final String SQL_PARAMETER_PLACEHOLDER = "?";
public static final Set<String> PS_SETTERS = new HashSet<String>(Arrays.asList(
"setArray",
"setBigDecimal",
"setBoolean",
"setByte",
"setDate",
"setDouble",
"setFloat",
"setInt",
"setLong",
"setNString",
"setObject",
"setRowId",
"setShort",
"setString",
"setTime",
"setTimestamp",
"setURL"
));
public static final Set<String> PS_IGNORABLE_SETTERS = new HashSet<String>(Arrays.asList(
"setAsciiStream",
"setBinaryStream",
"setBlob",
"setBytes",
"setCharacterStream",
"setClob",
"setNCharacterStream",
"setNClob",
"setRef",
"setSQLXML",
"setUnicodeStream"
));

public static final String PREPARED_STATEMENT_SETTER_METHODS_INTERCEPTOR = "org.apache.skywalking.apm.plugin.jdbc.JDBCPreparedStatementSetterInterceptor";
public static final String PREPARED_STATEMENT_NULL_SETTER_METHODS_INTERCEPTOR = "org.apache.skywalking.apm.plugin.jdbc.JDBCPreparedStatementNullSetterInterceptor";
public static final String PREPARED_STATEMENT_IGNORABLE_SETTER_METHODS_INTERCEPTOR = "org.apache.skywalking.apm.plugin.jdbc.JDBCPreparedStatementIgnorableSetterInterceptor";
}
Loading