Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
fafcf29
Bulk executed with failures,then log detail message
dagmom May 31, 2020
81d07c0
Merge branch 'master' into master
dagmom May 31, 2020
dcc9a71
add new java sdk plugin : InfluxDB
dagmom May 31, 2020
d28d344
Merge branch 'master' into master
dagmom May 31, 2020
d7a5d8a
Merge branch 'master' into master
dagmom Jun 3, 2020
7121812
plugin-test : influxdb-scenario
dagmom Jun 3, 2020
2f99381
plugin-test : influxdb-scenario
dagmom Jun 3, 2020
2e0c634
plugin-test : upgrade influxdb-scenario support-version.list form 2.5…
dagmom Jun 3, 2020
1296890
plugin-test : add influxdb-scenario to Github Actions Job.
dagmom Jun 3, 2020
9caa661
Merge branch 'master' into master
dagmom Jun 3, 2020
b151ad3
raf check : exclude [jacoco] dir --> generated file from test agent p…
dagmom Jun 4, 2020
ca855b4
influxdb plugin : resolve raf problem and unit test case
dagmom Jun 4, 2020
5818b7e
[PHP-E2E] Support v8 (#4862)
heyanlong Jun 5, 2020
fa94bb5
Remove nacos (#4867)
songzhendong Jun 6, 2020
916a018
influxdb plugin : Some review comments fix
dagmom Jun 6, 2020
ef35816
influxdb plugin : Some review comments fix
dagmom Jun 6, 2020
dadb56e
Merge branch 'master' into master
dagmom Jun 6, 2020
59a168d
influxdb plugin : remove since date
dagmom Jun 6, 2020
c6b379b
Merge remote-tracking branch 'upstream/master'
dagmom Jun 14, 2020
55b2b24
update influxdb plugin version.
dagmom Jun 14, 2020
8387f04
Merge branch 'master' into master
dagmom Jun 14, 2020
4889fa9
add component-libraries.yml and update Supported-list.md
dagmom Jun 14, 2020
e28d7fd
influxdb support db.statement tag, like influxql,lineProtocol value
dagmom Jun 18, 2020
168f7f6
Update skywalking-ui
dagmom Jun 18, 2020
36811ea
remove local ut
dagmom Jun 18, 2020
8744795
update submodule
dagmom Jun 18, 2020
da0181e
Merge branch 'master' into master
dagmom Jun 19, 2020
e272e75
fixed influxdb-scenario `expectedData.yaml` assert value
dagmom Jun 20, 2020
4d9e137
Merge branch 'master' into master
dagmom Jun 20, 2020
0838ef5
Mischange when merge remote-tracing branch
dagmom Jun 20, 2020
f77f8f3
Revert "update submodule"
dagmom Jun 20, 2020
d4c4515
make submodule commit id is as same as the master branch.
dagmom Jun 20, 2020
15884f1
exclude scenario test gen files
dagmom Jun 20, 2020
f85be1b
Merge remote-tracking branch 'remotes/upstream/master'
dagmom Jun 21, 2020
da55955
change componentId
dagmom Jun 21, 2020
d6b32df
add `agent/config/agent.config` : plugin.influxdb.trace_influxql
dagmom Jun 21, 2020
43af626
Component id defined in class ComponentsDefine should be the same as …
dagmom Jun 21, 2020
d285424
Merge branch 'master' into master
dagmom Jun 21, 2020
03ac123
Revert "add `agent/config/agent.config` : plugin.influxdb.trace_influ…
dagmom Jun 21, 2020
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
1 change: 1 addition & 0 deletions .github/workflows/plugins-test.1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
- { name: 'httpclient-3.x-scenario', title: 'HttpClient 2.0-3.1 (5)' }
- { name: 'httpclient-4.3.x-scenario', title: 'HttpClient 4.3.x-4.5.x (14)' }
- { name: 'hystrix-scenario', title: 'Hystrix 1.4.20-1.5.12 (20)' }
- { name: 'influxdb-scenario', title: 'InfluxDB Java 2.5-2.17 (12)' }
- { name: 'jdk-http-scenario', title: 'JDK http (1)' }
- { name: 'jdk-threading-scenario', title: 'JDK Threading (1)' }
- { name: 'jedis-scenario', title: 'Jedis 2.4.0-2.9.0 (18)' }
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ OALLexer.tokens
.externalToolBuilders
/test/plugin/dist
/test/plugin/workspace
/test/jacoco/classes
/test/jacoco/*.exec
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,6 @@ public class ComponentsDefine {
public static final OfficialComponent MARIADB_JDBC = new OfficialComponent(87, "mariadb-jdbc");

public static final OfficialComponent QUASAR = new OfficialComponent(88, "quasar");

public static final OfficialComponent INFLUXDB_JAVA = new OfficialComponent(90, "influxdb-java");
}
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,13 @@ public static class Http {
*/
public static int HTTP_PARAMS_LENGTH_THRESHOLD = 1024;
}

public static class InfluxDB {
/**
* If set to true, the parameters of the InfluxQL would be collected.
*/
public static boolean TRACE_INFLUXQL = true;
}
}

public static class Correlation {
Expand Down
47 changes: 47 additions & 0 deletions apm-sniffer/apm-sdk-plugin/influxdb-2.x-plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
~
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>apm-sdk-plugin</artifactId>
<groupId>org.apache.skywalking</groupId>
<version>8.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>apm-influxdb-2.x-plugin</artifactId>
<description>This plugin is for use with influxdb-java client</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<influxdb-jave.version>2.15</influxdb-jave.version>
</properties>

<dependencies>
<dependency>
<groupId>org.influxdb</groupId>
<artifactId>influxdb-java</artifactId>
<version>${influxdb-jave.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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.influxdb.define;

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

/**
* InfluxDB plugin Constants
*
* @since 2020/6/6
*/
public class Constants {

public static final String DB_TYPE = "InfluxDB";

public static final String PING_METHOD = "ping";
public static final String WRITE_METHOD = "write";
public static final String QUERY_METHOD = "query";
public static final String CREATE_DATABASE_METHOD = "createDatabase";
public static final String DELETE_DATABASE_METHOD = "deleteDatabase";
public static final String FLUSH_METHOD = "flush";
public static final String CREATE_RETENTION_POLICY_METHOD = "createRetentionPolicy";
public static final String DROP_RETENTION_POLICY_METHOD = "dropRetentionPolicy";

public static final Set<String> MATCHER_METHOD_NAME = new HashSet<>(Arrays.asList(PING_METHOD, WRITE_METHOD, QUERY_METHOD, CREATE_DATABASE_METHOD, DELETE_DATABASE_METHOD, FLUSH_METHOD, CREATE_RETENTION_POLICY_METHOD, DROP_RETENTION_POLICY_METHOD));

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
* 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.influxdb.define;

import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
import net.bytebuddy.matcher.ElementMatchers;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch;

import java.util.Set;

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


/**
* Enhance InfluxDB InfluxDBFactory
* Really impl class {@link org.influxdb.impl.InfluxDBImpl}
*
* @since 2020/05/22
*/
public class InfluxDBInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {

private static final String ENHANCE_CLASS = "org.influxdb.impl.InfluxDBImpl";
private static final String INTERCEPTOR_CLASS = "org.apache.skywalking.apm.plugin.influxdb.interceptor.InfluxDBConstructorInterceptor";
private static final String INFLUXDB_METHOD_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.influxdb.interceptor.InfluxDBMethodInterceptor";

@Override
protected ClassMatch enhanceClass() {
return NameMatch.byName(ENHANCE_CLASS);
}

@Override
public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[] {
new ConstructorInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return ElementMatchers.takesArgument(0, String.class);
}

@Override
public String getConstructorInterceptor() {
return INTERCEPTOR_CLASS;
}
}
};
}

@Override
public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
return new InstanceMethodsInterceptPoint[] {
new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
ElementMatcher.Junction<MethodDescription> matcher = none();
final Set<String> setters = Constants.MATCHER_METHOD_NAME;
for (String setter : setters) {
matcher = matcher.or(named(setter));
}
return matcher;
}

@Override
public String getMethodsInterceptor() {
return getInstanceMethodsInterceptor();
}

@Override
public boolean isOverrideArgs() {
return false;
}
}
};
}

protected String getInstanceMethodsInterceptor() {
return INFLUXDB_METHOD_INTERCEPT_CLASS;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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.influxdb.interceptor;

import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;

public class InfluxDBConstructorInterceptor implements InstanceConstructorInterceptor {

@Override
public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
String url = (String) allArguments[0];
objInst.setSkyWalkingDynamicField(url);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* 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.influxdb.interceptor;

import org.apache.skywalking.apm.agent.core.conf.Config;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
import org.apache.skywalking.apm.agent.core.context.tag.Tags;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
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.network.trace.component.ComponentsDefine;
import org.apache.skywalking.apm.plugin.influxdb.define.Constants;
import org.influxdb.dto.BatchPoints;
import org.influxdb.dto.Point;
import org.influxdb.dto.Query;

import java.lang.reflect.Method;

import static org.apache.skywalking.apm.plugin.influxdb.define.Constants.DB_TYPE;

public class InfluxDBMethodInterceptor implements InstanceMethodsAroundInterceptor {

@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
MethodInterceptResult result) throws Throwable {
String methodName = method.getName();
String peer = String.valueOf(objInst.getSkyWalkingDynamicField());
AbstractSpan span = ContextManager.createExitSpan("InfluxDB/" + methodName, peer);
span.setComponent(ComponentsDefine.INFLUXDB_JAVA);
SpanLayer.asDB(span);
Tags.DB_TYPE.set(span, DB_TYPE);

if (allArguments.length <= 0 || !Config.Plugin.InfluxDB.TRACE_INFLUXQL) {
return;
}

if (allArguments[0] instanceof Query) {
Query query = (Query) allArguments[0];
Tags.DB_INSTANCE.set(span, query.getDatabase());
Tags.DB_STATEMENT.set(span, query.getCommand());
return;
}

if (Constants.WRITE_METHOD.equals(methodName)) {
if (allArguments[0] instanceof BatchPoints) {
BatchPoints batchPoints = (BatchPoints) allArguments[0];
Tags.DB_INSTANCE.set(span, batchPoints.getDatabase());
Tags.DB_STATEMENT.set(span, batchPoints.lineProtocol());
return;
}
if (allArguments.length == 5) {
if (allArguments[0] instanceof String) {
Tags.DB_INSTANCE.set(span, (String) allArguments[0]);
}
if (allArguments[4] instanceof String) {
Tags.DB_STATEMENT.set(span, (String) allArguments[4]);
}
return;
}
if (allArguments.length == 3 && allArguments[2] instanceof Point) {
Tags.DB_INSTANCE.set(span, (String) allArguments[0]);
Tags.DB_STATEMENT.set(span, ((Point) allArguments[2]).lineProtocol());
}
}

}

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

@Override
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
Class<?>[] argumentsTypes, Throwable t) {
ContextManager.activeSpan().errorOccurred().log(t);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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.

influxdb-2.x=org.apache.skywalking.apm.plugin.influxdb.define.InfluxDBInstrumentation
Loading