diff --git a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/plugin/yaml/swapper/YamlPointcutConfigurationSwapper.java b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/plugin/yaml/swapper/YamlPointcutConfigurationSwapper.java index e05f46f2a97e2..cc364dd50013c 100644 --- a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/plugin/yaml/swapper/YamlPointcutConfigurationSwapper.java +++ b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/plugin/yaml/swapper/YamlPointcutConfigurationSwapper.java @@ -48,9 +48,6 @@ public Optional> swapToObject(final Ya } private ElementMatcher appendParameters(final YamlPointcutConfiguration yamlPointcutConfig, final Junction pointcut) { - if (yamlPointcutConfig.getParams().isEmpty()) { - return pointcut.and(ElementMatchers.takesNoArguments()); - } Junction result = pointcut; for (YamlPointcutParameterConfiguration each : yamlPointcutConfig.getParams()) { result = result.and(ElementMatchers.takesArgument(each.getIndex(), ElementMatchers.named(each.getName()))); diff --git a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/plugin/yaml/swapper/YamlAdvisorsConfigurationSwapperTest.java b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/plugin/yaml/swapper/YamlAdvisorsConfigurationSwapperTest.java index c3cca840c6295..844ac49447427 100644 --- a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/plugin/yaml/swapper/YamlAdvisorsConfigurationSwapperTest.java +++ b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/plugin/yaml/swapper/YamlAdvisorsConfigurationSwapperTest.java @@ -50,13 +50,13 @@ private void assertAdvisorConfiguration(final AdvisorConfiguration actual) { assertThat(each.getAdviceClassName(), is(YamlAdviceFixture.class.getName())); } List actualAdvisorConfig = new ArrayList<>(actual.getAdvisors()); - assertThat(actualAdvisorConfig.get(0).getPointcut(), is(ElementMatchers.isConstructor().and(ElementMatchers.takesNoArguments()))); + assertThat(actualAdvisorConfig.get(0).getPointcut(), is(ElementMatchers.isConstructor())); assertThat(actualAdvisorConfig.get(1).getPointcut(), is(ElementMatchers.isConstructor().and(ElementMatchers.takesArgument(0, ElementMatchers.named("value"))))); - assertThat(actualAdvisorConfig.get(2).getPointcut(), is(ElementMatchers.named("call").and(ElementMatchers.takesNoArguments()))); + assertThat(actualAdvisorConfig.get(2).getPointcut(), is(ElementMatchers.named("call"))); assertThat(actualAdvisorConfig.get(3).getPointcut(), is(ElementMatchers.named("call").and(ElementMatchers.takesArgument(0, ElementMatchers.named("value"))))); assertThat(actualAdvisorConfig.get(4).getPointcut(), is(ElementMatchers.named("call") .and(ElementMatchers.takesArgument(0, ElementMatchers.named("value1"))).and(ElementMatchers.takesArgument(1, ElementMatchers.named("value2"))))); - assertThat(actualAdvisorConfig.get(5).getPointcut(), is(ElementMatchers.named("staticCall").and(ElementMatchers.takesNoArguments()))); + assertThat(actualAdvisorConfig.get(5).getPointcut(), is(ElementMatchers.named("staticCall"))); assertThat(actualAdvisorConfig.get(6).getPointcut(), is(ElementMatchers.named("staticCall").and(ElementMatchers.takesArgument(0, ElementMatchers.named("value"))))); assertThat(actualAdvisorConfig.get(7).getPointcut(), is(ElementMatchers.named("staticCall") .and(ElementMatchers.takesArgument(0, ElementMatchers.named("value1"))).and(ElementMatchers.takesArgument(1, ElementMatchers.named("value2"))))); diff --git a/agent/plugins/logging/base/src/main/java/org/apache/shardingsphere/agent/plugin/logging/base/BaseLoggingAdvisorDefinitionService.java b/agent/plugins/logging/base/src/main/java/org/apache/shardingsphere/agent/plugin/logging/base/BaseLoggingAdvisorDefinitionService.java index 12b638bd35bda..1d789921df3e3 100644 --- a/agent/plugins/logging/base/src/main/java/org/apache/shardingsphere/agent/plugin/logging/base/BaseLoggingAdvisorDefinitionService.java +++ b/agent/plugins/logging/base/src/main/java/org/apache/shardingsphere/agent/plugin/logging/base/BaseLoggingAdvisorDefinitionService.java @@ -17,44 +17,30 @@ package org.apache.shardingsphere.agent.plugin.logging.base; -import net.bytebuddy.matcher.ElementMatchers; import org.apache.shardingsphere.agent.config.advisor.AdvisorConfiguration; -import org.apache.shardingsphere.agent.config.advisor.MethodAdvisorConfiguration; -import org.apache.shardingsphere.agent.core.plugin.advisor.AdvisorConfigurationRegistryFactory; -import org.apache.shardingsphere.agent.plugin.logging.base.advice.MetaDataContextsFactoryAdvice; +import org.apache.shardingsphere.agent.core.plugin.yaml.loader.YamlAdvisorsConfigurationLoader; +import org.apache.shardingsphere.agent.core.plugin.yaml.swapper.YamlAdvisorsConfigurationSwapper; import org.apache.shardingsphere.agent.spi.advisor.AdvisorDefinitionService; import java.util.Collection; -import java.util.LinkedList; /** * Base logging advisor definition service. */ public final class BaseLoggingAdvisorDefinitionService implements AdvisorDefinitionService { - private static final String SCHEMA_METADATA_LOADER_CLASS = "org.apache.shardingsphere.mode.metadata.MetaDataContextsFactory"; + private final YamlAdvisorsConfigurationLoader loader = new YamlAdvisorsConfigurationLoader(); - private static final String SCHEMA_METADATA_LOADER_METHOD_NAME = "create"; - - private static final String SCHEMA_METADATA_LOADER_ADVICE_CLASS = MetaDataContextsFactoryAdvice.class.getName(); + private final YamlAdvisorsConfigurationSwapper swapper = new YamlAdvisorsConfigurationSwapper(); @Override public Collection getProxyAdvisorConfigurations() { - return getAdvisorConfigurations(); + return swapper.swapToObject(loader.load(getClass().getResourceAsStream("/baselogging/advisors.yaml")), getType()); } @Override public Collection getJDBCAdvisorConfigurations() { - return getAdvisorConfigurations(); - } - - private Collection getAdvisorConfigurations() { - Collection result = new LinkedList<>(); - AdvisorConfiguration advisorConfig = AdvisorConfigurationRegistryFactory.getRegistry(getType()).getAdvisorConfiguration(SCHEMA_METADATA_LOADER_CLASS); - advisorConfig.getAdvisors().add( - new MethodAdvisorConfiguration(ElementMatchers.named(SCHEMA_METADATA_LOADER_METHOD_NAME).and(ElementMatchers.takesArguments(4)), SCHEMA_METADATA_LOADER_ADVICE_CLASS)); - result.add(advisorConfig); - return result; + return swapper.swapToObject(loader.load(getClass().getResourceAsStream("/baselogging/advisors.yaml")), getType()); } @Override diff --git a/agent/plugins/logging/base/src/main/resources/baselogging/advisors.yaml b/agent/plugins/logging/base/src/main/resources/baselogging/advisors.yaml new file mode 100644 index 0000000000000..3fe1b6be3d60d --- /dev/null +++ b/agent/plugins/logging/base/src/main/resources/baselogging/advisors.yaml @@ -0,0 +1,26 @@ +# +# 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. +# + +advisors: + - target: org.apache.shardingsphere.mode.metadata.MetaDataContextsFactory + advice: org.apache.shardingsphere.agent.plugin.logging.base.advice.MetaDataContextsFactoryAdvice + pointcuts: + - name: create + type: method + params: + - index: 3 + name: storageNodes \ No newline at end of file diff --git a/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/PrometheusAdvisorDefinitionService.java b/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/PrometheusAdvisorDefinitionService.java index 57f73d664c3b1..6b816c0fe06fe 100644 --- a/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/PrometheusAdvisorDefinitionService.java +++ b/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/PrometheusAdvisorDefinitionService.java @@ -41,7 +41,7 @@ public Collection getProxyAdvisorConfigurations() { @Override public Collection getJDBCAdvisorConfigurations() { - // TODO add JDBC related interceptors + // TODO add JDBC advisor return Collections.emptyList(); } diff --git a/agent/plugins/tracing/core/pom.xml b/agent/plugins/tracing/core/pom.xml deleted file mode 100644 index 0b3e997928b25..0000000000000 --- a/agent/plugins/tracing/core/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - 4.0.0 - - org.apache.shardingsphere - shardingsphere-agent-plugin-tracing - 5.3.1-SNAPSHOT - - shardingsphere-agent-tracing-core - ${project.artifactId} - diff --git a/agent/plugins/tracing/core/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/core/advice/TracingAdviceEngine.java b/agent/plugins/tracing/core/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/core/advice/TracingAdviceEngine.java deleted file mode 100644 index 02deb9d4564d1..0000000000000 --- a/agent/plugins/tracing/core/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/core/advice/TracingAdviceEngine.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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.shardingsphere.agent.plugin.tracing.core.advice; - -import lombok.RequiredArgsConstructor; -import org.apache.shardingsphere.agent.config.advisor.AdvisorConfiguration; -import org.apache.shardingsphere.agent.advice.type.InstanceMethodAdvice; -import org.apache.shardingsphere.agent.plugin.tracing.core.advice.adviser.impl.CommandExecutorTaskAdviser; -import org.apache.shardingsphere.agent.plugin.tracing.core.advice.adviser.impl.JDBCExecutorCallbackAdviser; -import org.apache.shardingsphere.agent.plugin.tracing.core.advice.adviser.impl.SQLParserEngineAdviser; - -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedList; - -/** - * Tracing advice engine. - */ -@RequiredArgsConstructor -public final class TracingAdviceEngine { - - private final String type; - - /** - * Get proxy tracing advisor configurations. - * - * @param commandExecutorTaskAdvice command executor task advice - * @param sqlParserEngineAdvice SQL parser engine advice - * @param jdbcExecutorCallbackAdvice JDBC executor callback advice - * @return got configurations - */ - public Collection getProxyAdvisorConfigurations(final Class commandExecutorTaskAdvice, - final Class sqlParserEngineAdvice, - final Class jdbcExecutorCallbackAdvice) { - // TODO load from YAML, please ref metrics - Collection result = new LinkedList<>(); - result.add(new CommandExecutorTaskAdviser(type).getAdvisorConfiguration(commandExecutorTaskAdvice)); - result.add(new SQLParserEngineAdviser(type).getAdvisorConfiguration(sqlParserEngineAdvice)); - result.add(new JDBCExecutorCallbackAdviser(type).getAdvisorConfiguration(jdbcExecutorCallbackAdvice)); - return result; - } - - /** - * Get JDBC tracing advisor configurations. - * - * @return got configurations - */ - public Collection getJDBCAdvisorConfigurations() { - // TODO - return Collections.emptyList(); - } -} diff --git a/agent/plugins/tracing/core/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/core/advice/adviser/TracingAdviser.java b/agent/plugins/tracing/core/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/core/advice/adviser/TracingAdviser.java deleted file mode 100644 index 1f94c397a2e26..0000000000000 --- a/agent/plugins/tracing/core/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/core/advice/adviser/TracingAdviser.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.shardingsphere.agent.plugin.tracing.core.advice.adviser; - -import org.apache.shardingsphere.agent.advice.type.InstanceMethodAdvice; -import org.apache.shardingsphere.agent.config.advisor.AdvisorConfiguration; - -/** - * Tracing adviser. - */ -public interface TracingAdviser { - - /** - * Get advisor configuration. - * - * @param adviceClass instance method advice class - * @return advisor configuration - */ - AdvisorConfiguration getAdvisorConfiguration(Class adviceClass); -} diff --git a/agent/plugins/tracing/core/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/core/advice/adviser/impl/CommandExecutorTaskAdviser.java b/agent/plugins/tracing/core/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/core/advice/adviser/impl/CommandExecutorTaskAdviser.java deleted file mode 100644 index dde9826486f3d..0000000000000 --- a/agent/plugins/tracing/core/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/core/advice/adviser/impl/CommandExecutorTaskAdviser.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.shardingsphere.agent.plugin.tracing.core.advice.adviser.impl; - -import lombok.RequiredArgsConstructor; -import net.bytebuddy.matcher.ElementMatchers; -import org.apache.shardingsphere.agent.advice.type.InstanceMethodAdvice; -import org.apache.shardingsphere.agent.config.advisor.AdvisorConfiguration; -import org.apache.shardingsphere.agent.config.advisor.MethodAdvisorConfiguration; -import org.apache.shardingsphere.agent.core.plugin.advisor.AdvisorConfigurationRegistryFactory; -import org.apache.shardingsphere.agent.plugin.tracing.core.advice.adviser.TracingAdviser; - -/** - * Command executor task adviser. - */ -@RequiredArgsConstructor -public final class CommandExecutorTaskAdviser implements TracingAdviser { - - private static final String TARGET_CLASS = "org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask"; - - private static final String TARGET_METHOD = "run"; - - private final String type; - - @Override - public AdvisorConfiguration getAdvisorConfiguration(final Class adviceClass) { - AdvisorConfiguration result = AdvisorConfigurationRegistryFactory.getRegistry(type).getAdvisorConfiguration(TARGET_CLASS); - result.getAdvisors().add(new MethodAdvisorConfiguration(ElementMatchers.named(TARGET_METHOD), adviceClass.getName())); - return result; - } -} diff --git a/agent/plugins/tracing/core/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/core/advice/adviser/impl/JDBCExecutorCallbackAdviser.java b/agent/plugins/tracing/core/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/core/advice/adviser/impl/JDBCExecutorCallbackAdviser.java deleted file mode 100644 index fe276d62d176d..0000000000000 --- a/agent/plugins/tracing/core/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/core/advice/adviser/impl/JDBCExecutorCallbackAdviser.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.shardingsphere.agent.plugin.tracing.core.advice.adviser.impl; - -import lombok.RequiredArgsConstructor; -import net.bytebuddy.matcher.ElementMatchers; -import org.apache.shardingsphere.agent.advice.type.InstanceMethodAdvice; -import org.apache.shardingsphere.agent.config.advisor.AdvisorConfiguration; -import org.apache.shardingsphere.agent.config.advisor.MethodAdvisorConfiguration; -import org.apache.shardingsphere.agent.core.plugin.advisor.AdvisorConfigurationRegistryFactory; -import org.apache.shardingsphere.agent.plugin.tracing.core.advice.adviser.TracingAdviser; - -/** - * JDBC executor callback adviser. - */ -@RequiredArgsConstructor -public final class JDBCExecutorCallbackAdviser implements TracingAdviser { - - private static final String TARGET_CLASS = "org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutorCallback"; - - private static final String TARGET_METHOD = "execute"; - - private static final String TARGET_METHOD_FIRST_PARAM = "org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutionUnit"; - - private final String type; - - @Override - public AdvisorConfiguration getAdvisorConfiguration(final Class adviceClass) { - AdvisorConfiguration result = AdvisorConfigurationRegistryFactory.getRegistry(type).getAdvisorConfiguration(TARGET_CLASS); - result.getAdvisors().add(new MethodAdvisorConfiguration( - ElementMatchers.named(TARGET_METHOD).and(ElementMatchers.takesArgument(0, ElementMatchers.named(TARGET_METHOD_FIRST_PARAM))), adviceClass.getName())); - return result; - } -} diff --git a/agent/plugins/tracing/core/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/core/advice/adviser/impl/SQLParserEngineAdviser.java b/agent/plugins/tracing/core/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/core/advice/adviser/impl/SQLParserEngineAdviser.java deleted file mode 100644 index 3c7d3687b190c..0000000000000 --- a/agent/plugins/tracing/core/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/core/advice/adviser/impl/SQLParserEngineAdviser.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.shardingsphere.agent.plugin.tracing.core.advice.adviser.impl; - -import lombok.RequiredArgsConstructor; -import net.bytebuddy.matcher.ElementMatchers; -import org.apache.shardingsphere.agent.advice.type.InstanceMethodAdvice; -import org.apache.shardingsphere.agent.config.advisor.AdvisorConfiguration; -import org.apache.shardingsphere.agent.config.advisor.MethodAdvisorConfiguration; -import org.apache.shardingsphere.agent.core.plugin.advisor.AdvisorConfigurationRegistryFactory; -import org.apache.shardingsphere.agent.plugin.tracing.core.advice.adviser.TracingAdviser; - -/** - * SQL parser engine adviser. - */ -@RequiredArgsConstructor -public final class SQLParserEngineAdviser implements TracingAdviser { - - private static final String TARGET_CLASS = "org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine"; - - private static final String TARGET_METHOD = "parse"; - - private final String type; - - @Override - public AdvisorConfiguration getAdvisorConfiguration(final Class adviceClass) { - AdvisorConfiguration result = AdvisorConfigurationRegistryFactory.getRegistry(type).getAdvisorConfiguration(TARGET_CLASS); - result.getAdvisors().add(new MethodAdvisorConfiguration(ElementMatchers.named(TARGET_METHOD), adviceClass.getName())); - return result; - } -} diff --git a/agent/plugins/tracing/pom.xml b/agent/plugins/tracing/pom.xml index d7d89aa4bf4d7..6665ee29a9c23 100644 --- a/agent/plugins/tracing/pom.xml +++ b/agent/plugins/tracing/pom.xml @@ -29,7 +29,6 @@ ${project.artifactId} - core type test diff --git a/agent/plugins/tracing/type/jaeger/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/JaegerAdvisorDefinitionService.java b/agent/plugins/tracing/type/jaeger/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/JaegerAdvisorDefinitionService.java index eb0e7803fd7bd..886408a38955d 100644 --- a/agent/plugins/tracing/type/jaeger/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/JaegerAdvisorDefinitionService.java +++ b/agent/plugins/tracing/type/jaeger/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/JaegerAdvisorDefinitionService.java @@ -18,28 +18,31 @@ package org.apache.shardingsphere.agent.plugin.tracing.jaeger; import org.apache.shardingsphere.agent.config.advisor.AdvisorConfiguration; -import org.apache.shardingsphere.agent.plugin.tracing.core.advice.TracingAdviceEngine; -import org.apache.shardingsphere.agent.plugin.tracing.jaeger.advice.CommandExecutorTaskAdvice; -import org.apache.shardingsphere.agent.plugin.tracing.jaeger.advice.JDBCExecutorCallbackAdvice; +import org.apache.shardingsphere.agent.core.plugin.yaml.loader.YamlAdvisorsConfigurationLoader; +import org.apache.shardingsphere.agent.core.plugin.yaml.swapper.YamlAdvisorsConfigurationSwapper; import org.apache.shardingsphere.agent.spi.advisor.AdvisorDefinitionService; import java.util.Collection; +import java.util.Collections; /** * Jaeger advisor definition service. */ public final class JaegerAdvisorDefinitionService implements AdvisorDefinitionService { - private final TracingAdviceEngine engine = new TracingAdviceEngine(getType()); + private final YamlAdvisorsConfigurationLoader loader = new YamlAdvisorsConfigurationLoader(); + + private final YamlAdvisorsConfigurationSwapper swapper = new YamlAdvisorsConfigurationSwapper(); @Override public Collection getProxyAdvisorConfigurations() { - return engine.getProxyAdvisorConfigurations(CommandExecutorTaskAdvice.class, CommandExecutorTaskAdvice.class, JDBCExecutorCallbackAdvice.class); + return swapper.swapToObject(loader.load(getClass().getResourceAsStream("/jaeger/advisors.yaml")), getType()); } @Override public Collection getJDBCAdvisorConfigurations() { - return engine.getJDBCAdvisorConfigurations(); + // TODO add JDBC advisor + return Collections.emptyList(); } @Override diff --git a/agent/plugins/tracing/type/jaeger/src/main/resources/jaeger/advisors.yaml b/agent/plugins/tracing/type/jaeger/src/main/resources/jaeger/advisors.yaml new file mode 100644 index 0000000000000..72efb072c242f --- /dev/null +++ b/agent/plugins/tracing/type/jaeger/src/main/resources/jaeger/advisors.yaml @@ -0,0 +1,36 @@ +# +# 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. +# + +advisors: + - target: org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask + advice: org.apache.shardingsphere.agent.plugin.tracing.jaeger.advice.CommandExecutorTaskAdvice + pointcuts: + - name: run + type: method + - target: org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine + advice: org.apache.shardingsphere.agent.plugin.tracing.jaeger.advice.SQLParserEngineAdvice + pointcuts: + - name: parse + type: method + - target: org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutorCallback + advice: org.apache.shardingsphere.agent.plugin.tracing.jaeger.advice.JDBCExecutorCallbackAdvice + pointcuts: + - name: execute + type: method + params: + - index: 0 + name: jdbcExecutionUnit diff --git a/agent/plugins/tracing/type/opentelemetry/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/opentelemetry/OpenTelemetryTracingAdvisorDefinitionService.java b/agent/plugins/tracing/type/opentelemetry/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/opentelemetry/OpenTelemetryTracingAdvisorDefinitionService.java index c18d3eb55d7e7..bab2e8d75b2f7 100644 --- a/agent/plugins/tracing/type/opentelemetry/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/opentelemetry/OpenTelemetryTracingAdvisorDefinitionService.java +++ b/agent/plugins/tracing/type/opentelemetry/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/opentelemetry/OpenTelemetryTracingAdvisorDefinitionService.java @@ -18,28 +18,31 @@ package org.apache.shardingsphere.agent.plugin.tracing.opentelemetry; import org.apache.shardingsphere.agent.config.advisor.AdvisorConfiguration; -import org.apache.shardingsphere.agent.plugin.tracing.core.advice.TracingAdviceEngine; -import org.apache.shardingsphere.agent.plugin.tracing.opentelemetry.advice.CommandExecutorTaskAdvice; -import org.apache.shardingsphere.agent.plugin.tracing.opentelemetry.advice.JDBCExecutorCallbackAdvice; +import org.apache.shardingsphere.agent.core.plugin.yaml.loader.YamlAdvisorsConfigurationLoader; +import org.apache.shardingsphere.agent.core.plugin.yaml.swapper.YamlAdvisorsConfigurationSwapper; import org.apache.shardingsphere.agent.spi.advisor.AdvisorDefinitionService; import java.util.Collection; +import java.util.Collections; /** * OpenTelemetry advisor definition service. */ public final class OpenTelemetryTracingAdvisorDefinitionService implements AdvisorDefinitionService { - private final TracingAdviceEngine engine = new TracingAdviceEngine(getType()); + private final YamlAdvisorsConfigurationLoader loader = new YamlAdvisorsConfigurationLoader(); + + private final YamlAdvisorsConfigurationSwapper swapper = new YamlAdvisorsConfigurationSwapper(); @Override public Collection getProxyAdvisorConfigurations() { - return engine.getProxyAdvisorConfigurations(CommandExecutorTaskAdvice.class, CommandExecutorTaskAdvice.class, JDBCExecutorCallbackAdvice.class); + return swapper.swapToObject(loader.load(getClass().getResourceAsStream("/opentelemetry/advisors.yaml")), getType()); } @Override public Collection getJDBCAdvisorConfigurations() { - return engine.getJDBCAdvisorConfigurations(); + // TODO add JDBC advisor + return Collections.emptyList(); } @Override diff --git a/agent/plugins/tracing/type/opentelemetry/src/main/resources/opentelemetry/advisors.yaml b/agent/plugins/tracing/type/opentelemetry/src/main/resources/opentelemetry/advisors.yaml new file mode 100644 index 0000000000000..caf43f677d0c2 --- /dev/null +++ b/agent/plugins/tracing/type/opentelemetry/src/main/resources/opentelemetry/advisors.yaml @@ -0,0 +1,36 @@ +# +# 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. +# + +advisors: + - target: org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask + advice: org.apache.shardingsphere.agent.plugin.tracing.opentelemetry.advice.CommandExecutorTaskAdvice + pointcuts: + - name: run + type: method + - target: org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine + advice: org.apache.shardingsphere.agent.plugin.tracing.opentelemetry.advice.SQLParserEngineAdvice + pointcuts: + - name: parse + type: method + - target: org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutorCallback + advice: org.apache.shardingsphere.agent.plugin.tracing.opentelemetry.advice.JDBCExecutorCallbackAdvice + pointcuts: + - name: execute + type: method + params: + - index: 0 + name: jdbcExecutionUnit diff --git a/agent/plugins/tracing/type/opentracing/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/OpenTracingAdvisorDefinitionService.java b/agent/plugins/tracing/type/opentracing/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/OpenTracingAdvisorDefinitionService.java index 7ca3874ddb7c9..1b23e061f1bdb 100644 --- a/agent/plugins/tracing/type/opentracing/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/OpenTracingAdvisorDefinitionService.java +++ b/agent/plugins/tracing/type/opentracing/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/OpenTracingAdvisorDefinitionService.java @@ -18,28 +18,31 @@ package org.apache.shardingsphere.agent.plugin.tracing.opentracing; import org.apache.shardingsphere.agent.config.advisor.AdvisorConfiguration; -import org.apache.shardingsphere.agent.plugin.tracing.core.advice.TracingAdviceEngine; -import org.apache.shardingsphere.agent.plugin.tracing.opentracing.advice.CommandExecutorTaskAdvice; -import org.apache.shardingsphere.agent.plugin.tracing.opentracing.advice.JDBCExecutorCallbackAdvice; +import org.apache.shardingsphere.agent.core.plugin.yaml.loader.YamlAdvisorsConfigurationLoader; +import org.apache.shardingsphere.agent.core.plugin.yaml.swapper.YamlAdvisorsConfigurationSwapper; import org.apache.shardingsphere.agent.spi.advisor.AdvisorDefinitionService; import java.util.Collection; +import java.util.Collections; /** * OpenTracing advisor definition service. */ public final class OpenTracingAdvisorDefinitionService implements AdvisorDefinitionService { - private final TracingAdviceEngine engine = new TracingAdviceEngine(getType()); + private final YamlAdvisorsConfigurationLoader loader = new YamlAdvisorsConfigurationLoader(); + + private final YamlAdvisorsConfigurationSwapper swapper = new YamlAdvisorsConfigurationSwapper(); @Override public Collection getProxyAdvisorConfigurations() { - return engine.getProxyAdvisorConfigurations(CommandExecutorTaskAdvice.class, CommandExecutorTaskAdvice.class, JDBCExecutorCallbackAdvice.class); + return swapper.swapToObject(loader.load(getClass().getResourceAsStream("/opentracing/advisors.yaml")), getType()); } @Override public Collection getJDBCAdvisorConfigurations() { - return engine.getJDBCAdvisorConfigurations(); + // TODO add JDBC advisor + return Collections.emptyList(); } @Override diff --git a/agent/plugins/tracing/type/opentracing/src/main/resources/opentracing/advisors.yaml b/agent/plugins/tracing/type/opentracing/src/main/resources/opentracing/advisors.yaml new file mode 100644 index 0000000000000..67bfda3fe5e34 --- /dev/null +++ b/agent/plugins/tracing/type/opentracing/src/main/resources/opentracing/advisors.yaml @@ -0,0 +1,36 @@ +# +# 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. +# + +advisors: + - target: org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask + advice: org.apache.shardingsphere.agent.plugin.tracing.opentracing.advice.CommandExecutorTaskAdvice + pointcuts: + - name: run + type: method + - target: org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine + advice: org.apache.shardingsphere.agent.plugin.tracing.opentracing.advice.SQLParserEngineAdvice + pointcuts: + - name: parse + type: method + - target: org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutorCallback + advice: org.apache.shardingsphere.agent.plugin.tracing.opentracing.advice.JDBCExecutorCallbackAdvice + pointcuts: + - name: execute + type: method + params: + - index: 0 + name: jdbcExecutionUnit diff --git a/agent/plugins/tracing/type/pom.xml b/agent/plugins/tracing/type/pom.xml index 7b1792335310f..844f26e9a6e9b 100644 --- a/agent/plugins/tracing/type/pom.xml +++ b/agent/plugins/tracing/type/pom.xml @@ -39,14 +39,6 @@ ${project.basedir}/../../target/plugins - - - org.apache.shardingsphere - shardingsphere-agent-tracing-core - ${project.version} - - - diff --git a/agent/plugins/tracing/type/zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/ZipkinAdvisorDefinitionService.java b/agent/plugins/tracing/type/zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/ZipkinAdvisorDefinitionService.java index 96e1be4849233..f88c3b4d18aa6 100644 --- a/agent/plugins/tracing/type/zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/ZipkinAdvisorDefinitionService.java +++ b/agent/plugins/tracing/type/zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/ZipkinAdvisorDefinitionService.java @@ -18,28 +18,31 @@ package org.apache.shardingsphere.agent.plugin.tracing.zipkin; import org.apache.shardingsphere.agent.config.advisor.AdvisorConfiguration; -import org.apache.shardingsphere.agent.plugin.tracing.core.advice.TracingAdviceEngine; -import org.apache.shardingsphere.agent.plugin.tracing.zipkin.advice.CommandExecutorTaskAdvice; -import org.apache.shardingsphere.agent.plugin.tracing.zipkin.advice.JDBCExecutorCallbackAdvice; +import org.apache.shardingsphere.agent.core.plugin.yaml.loader.YamlAdvisorsConfigurationLoader; +import org.apache.shardingsphere.agent.core.plugin.yaml.swapper.YamlAdvisorsConfigurationSwapper; import org.apache.shardingsphere.agent.spi.advisor.AdvisorDefinitionService; import java.util.Collection; +import java.util.Collections; /** * Zipkin advisor definition service. */ public final class ZipkinAdvisorDefinitionService implements AdvisorDefinitionService { - private final TracingAdviceEngine engine = new TracingAdviceEngine(getType()); + private final YamlAdvisorsConfigurationLoader loader = new YamlAdvisorsConfigurationLoader(); + + private final YamlAdvisorsConfigurationSwapper swapper = new YamlAdvisorsConfigurationSwapper(); @Override public Collection getProxyAdvisorConfigurations() { - return engine.getProxyAdvisorConfigurations(CommandExecutorTaskAdvice.class, CommandExecutorTaskAdvice.class, JDBCExecutorCallbackAdvice.class); + return swapper.swapToObject(loader.load(getClass().getResourceAsStream("/zipkin/advisors.yaml")), getType()); } @Override public Collection getJDBCAdvisorConfigurations() { - return engine.getJDBCAdvisorConfigurations(); + // TODO add JDBC advisor + return Collections.emptyList(); } @Override diff --git a/agent/plugins/tracing/type/zipkin/src/main/resources/zipkin/advisors.yaml b/agent/plugins/tracing/type/zipkin/src/main/resources/zipkin/advisors.yaml new file mode 100644 index 0000000000000..9a7a10ffff133 --- /dev/null +++ b/agent/plugins/tracing/type/zipkin/src/main/resources/zipkin/advisors.yaml @@ -0,0 +1,36 @@ +# +# 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. +# + +advisors: + - target: org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask + advice: org.apache.shardingsphere.agent.plugin.tracing.zipkin.advice.CommandExecutorTaskAdvice + pointcuts: + - name: run + type: method + - target: org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine + advice: org.apache.shardingsphere.agent.plugin.tracing.zipkin.advice.SQLParserEngineAdvice + pointcuts: + - name: parse + type: method + - target: org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutorCallback + advice: org.apache.shardingsphere.agent.plugin.tracing.zipkin.advice.JDBCExecutorCallbackAdvice + pointcuts: + - name: execute + type: method + params: + - index: 0 + name: jdbcExecutionUnit