-
Notifications
You must be signed in to change notification settings - Fork 6.6k
[WIP]add postgresql plugin agent sql param show #3618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
79bfa27
4a88cf3
b30de5f
4575724
e845494
7bbe3de
8a0b357
1e419dc
6f1c498
361c355
c22ca87
a4c25d7
3456f93
9a70f3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,6 +52,13 @@ public ElementMatcher<MethodDescription> getMethodsMatcher() { | |
| } | ||
| } | ||
|
|
||
| if (Config.Plugin.PostgreSQL.TRACE_SQL_PARAMETERS) { | ||
| final Set<String> setters = ignorable ? PS_IGNORABLE_SETTERS : PS_SETTERS; | ||
| for (String setter : setters) { | ||
| matcher = matcher.or(named(setter)); | ||
| } | ||
| } | ||
|
|
||
|
Comment on lines
+55
to
+61
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simply collapse this to line 48 if (Config.Plugin.MySQL.TRACE_SQL_PARAMETERS || Config.Plugin.PostgreSQL.TRACE_SQL_PARAMETERS) {
final Set<String> setters = ignorable ? PS_IGNORABLE_SETTERS : PS_SETTERS;
for (String setter : setters) {
matcher = matcher.or(named(setter));
}
} |
||
| return matcher; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,6 +73,22 @@ public void setParameter(int index, final Object parameter) { | |
| parameters[index] = parameter; | ||
| } | ||
|
|
||
| public String getFullSql() { | ||
| StringBuilder resultSql = new StringBuilder(); | ||
| int index = 0; | ||
| int startPos = 0; | ||
| int findPos = 0; | ||
| while ((findPos = sql.indexOf("?", startPos)) > 0) { | ||
| resultSql.append(sql.substring(startPos, findPos)); | ||
| resultSql.append("'"); | ||
| resultSql.append(parameters[index++]); | ||
|
Comment on lines
+81
to
+84
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's unsafe to parse the SQL using
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My point is not to try to parse the SQL, store the parameters in another tag
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Parsing SQL is the next generation after ShardingShpere ( @tristaZero and @terrymanu ) provides the real SQL Parser. We don't do this by ourselves.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @wu-sheng @kezhenxu94 ACK,i will store the parameters in another tag. |
||
| resultSql.append("'"); | ||
| startPos = findPos + 1; | ||
| } | ||
| resultSql.append(sql.substring(startPos)); | ||
| return resultSql.toString(); | ||
| } | ||
|
|
||
| public Object[] getParameters() { | ||
| return parameters; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| /* | ||
| * 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.postgresql.define; | ||
|
|
||
| import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; | ||
| import org.apache.skywalking.apm.plugin.jdbc.PSSetterDefinitionOfJDBCInstrumentation; | ||
|
|
||
| /** | ||
| * @author aderm | ||
| */ | ||
| public class PgPreparedStatementSetterInstrumentation extends PgPreparedStatementInstrumentation { | ||
|
|
||
| @Override | ||
| public final InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { | ||
| return new InstanceMethodsInterceptPoint[] { | ||
| new PSSetterDefinitionOfJDBCInstrumentation(false) | ||
| }; | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default value should be
falsedue to possible performance issueThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How much impact on performance?