diff --git a/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java
index e02e8b22e2a4bc49a75ceaa8b60d867a8d2eb067..861ff4a631863fabb428493e8dcb53c6109f30e4 100644
--- a/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java
+++ b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java
@@ -126,6 +126,8 @@ public class ComponentsDefine {
public static final OfficialComponent SPRING_ASYNC = new OfficialComponent(65, "SpringAsync");
+ public static final OfficialComponent JDK_HTTP = new OfficialComponent(66, "JdkHttp");
+
private static ComponentsDefine INSTANCE = new ComponentsDefine();
private String[] components;
diff --git a/apm-sniffer/bootstrap-plugins/jdk-http-plugin/pom.xml b/apm-sniffer/bootstrap-plugins/jdk-http-plugin/pom.xml
new file mode 100755
index 0000000000000000000000000000000000000000..655cba430d4dd510c031add91e77402dbb6b8bba
--- /dev/null
+++ b/apm-sniffer/bootstrap-plugins/jdk-http-plugin/pom.xml
@@ -0,0 +1,46 @@
+
+
+
+
+ org.apache.skywalking
+ bootstrap-plugins
+ 6.3.0-SNAPSHOT
+
+ 4.0.0
+
+ apm-jdk-http-plugin
+ jar
+
+ apm-jdk-http-plugin
+ http://maven.apache.org
+
+
+ UTF-8
+
+
+
+
+
+
+ maven-deploy-plugin
+
+
+
+
diff --git a/apm-sniffer/bootstrap-plugins/jdk-http-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdk/http/HttpClientNewInstanceInterceptor.java b/apm-sniffer/bootstrap-plugins/jdk-http-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdk/http/HttpClientNewInstanceInterceptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..22716dfb27f75f608168d9a668965d117d72eaa3
--- /dev/null
+++ b/apm-sniffer/bootstrap-plugins/jdk-http-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdk/http/HttpClientNewInstanceInterceptor.java
@@ -0,0 +1,50 @@
+/*
+ * 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.jdk.http;
+
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.StaticMethodsAroundInterceptor;
+
+import java.lang.reflect.Method;
+
+/**
+ * @author lican
+ */
+public class HttpClientNewInstanceInterceptor implements StaticMethodsAroundInterceptor {
+
+
+ @Override
+ public void beforeMethod(Class clazz, Method method, Object[] allArguments, Class>[] parameterTypes, MethodInterceptResult result) {
+
+ }
+
+ @Override
+ public Object afterMethod(Class clazz, Method method, Object[] allArguments, Class>[] parameterTypes, Object ret) {
+ if (ret instanceof EnhancedInstance) {
+ ((EnhancedInstance) ret).setSkyWalkingDynamicField(allArguments[4]);
+ }
+ return ret;
+ }
+
+ @Override
+ public void handleMethodException(Class clazz, Method method, Object[] allArguments, Class>[] parameterTypes, Throwable t) {
+
+ }
+}
\ No newline at end of file
diff --git a/apm-sniffer/bootstrap-plugins/jdk-http-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdk/http/HttpClientParseHttpInterceptor.java b/apm-sniffer/bootstrap-plugins/jdk-http-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdk/http/HttpClientParseHttpInterceptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..f73dabe279466e025942486fbdd9885cec798531
--- /dev/null
+++ b/apm-sniffer/bootstrap-plugins/jdk-http-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdk/http/HttpClientParseHttpInterceptor.java
@@ -0,0 +1,90 @@
+/*
+ * 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.jdk.http;
+
+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.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.util.StringUtil;
+import sun.net.www.MessageHeader;
+
+import java.lang.reflect.Method;
+
+/**
+ * @author lican
+ */
+public class HttpClientParseHttpInterceptor implements InstanceMethodsAroundInterceptor {
+
+
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ MethodInterceptResult result) throws Throwable {
+
+ }
+
+
+ @Override
+ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ Object ret) throws Throwable {
+ MessageHeader responseHeader = (MessageHeader) allArguments[0];
+ String statusLine = responseHeader.getValue(0);
+ Integer responseCode = parseResponseCode(statusLine);
+ if (responseCode >= 400) {
+ AbstractSpan span = ContextManager.activeSpan();
+ span.errorOccurred();
+ Tags.STATUS_CODE.set(span, Integer.toString(responseCode));
+ }
+ ContextManager.stopSpan();
+ return ret;
+ }
+
+ @Override
+ public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class>[] argumentsTypes, Throwable t) {
+ AbstractSpan span = ContextManager.activeSpan();
+ span.errorOccurred().log(t);
+ }
+
+
+ /**
+ *
+ * HTTP/1.0 200 OK
+ * HTTP/1.0 401 Unauthorized
+ *
+ * It will return 200 and 401 respectively.
+ * Returns -1 if no code can be discerned
+ */
+ private Integer parseResponseCode(String statusLine) {
+ if (!StringUtil.isEmpty(statusLine)) {
+ String[] results = statusLine.split(" ");
+ if (results.length >= 1) {
+ try {
+ return Integer.valueOf(results[1]);
+ } catch (Exception e) {
+ }
+ }
+ }
+ return -1;
+ }
+
+
+}
\ No newline at end of file
diff --git a/apm-sniffer/bootstrap-plugins/jdk-http-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdk/http/HttpClientWriteRequestInterceptor.java b/apm-sniffer/bootstrap-plugins/jdk-http-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdk/http/HttpClientWriteRequestInterceptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..52142f99e7bceb2c7e5531e4e9b6d2a6a810c261
--- /dev/null
+++ b/apm-sniffer/bootstrap-plugins/jdk-http-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdk/http/HttpClientWriteRequestInterceptor.java
@@ -0,0 +1,90 @@
+/*
+ * 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.jdk.http;
+
+import org.apache.skywalking.apm.agent.core.context.CarrierItem;
+import org.apache.skywalking.apm.agent.core.context.ContextCarrier;
+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.util.StringUtil;
+import sun.net.www.MessageHeader;
+
+import java.lang.reflect.Method;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+/**
+ * @author lican
+ */
+public class HttpClientWriteRequestInterceptor implements InstanceMethodsAroundInterceptor {
+
+
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ MethodInterceptResult result) throws Throwable {
+ HttpURLConnection connection = (HttpURLConnection) objInst.getSkyWalkingDynamicField();
+ MessageHeader headers = (MessageHeader) allArguments[0];
+ URL url = connection.getURL();
+ ContextCarrier contextCarrier = new ContextCarrier();
+ AbstractSpan span = ContextManager.createExitSpan(getPath(url), contextCarrier, getPeer(url));
+ span.setComponent(ComponentsDefine.JDK_HTTP);
+ Tags.HTTP.METHOD.set(span, connection.getRequestMethod());
+ Tags.URL.set(span, url.toString());
+ SpanLayer.asHttp(span);
+ CarrierItem next = contextCarrier.items();
+ while (next.hasNext()) {
+ next = next.next();
+ headers.add(next.getHeadKey(), next.getHeadValue());
+ }
+ }
+
+
+ @Override
+ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ Object ret) throws Throwable {
+ return ret;
+ }
+
+ @Override
+ public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class>[] argumentsTypes, Throwable t) {
+ AbstractSpan span = ContextManager.activeSpan();
+ span.errorOccurred().log(t);
+ }
+
+ private String getPeer(URL url) {
+ String host = url.getHost();
+ if (url.getPort() > 0) {
+ return host + ":" + url.getPort();
+ }
+ return host;
+ }
+
+ private String getPath(URL url) {
+ return StringUtil.isEmpty(url.getPath()) ? "/" : url.getPath();
+ }
+
+}
+
diff --git a/apm-sniffer/bootstrap-plugins/jdk-http-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdk/http/HttpsClientNewInstanceInterceptor.java b/apm-sniffer/bootstrap-plugins/jdk-http-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdk/http/HttpsClientNewInstanceInterceptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..e8385e0ab2ba9b2ab75dd1b4c0c8891d60d70c62
--- /dev/null
+++ b/apm-sniffer/bootstrap-plugins/jdk-http-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdk/http/HttpsClientNewInstanceInterceptor.java
@@ -0,0 +1,50 @@
+/*
+ * 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.jdk.http;
+
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.StaticMethodsAroundInterceptor;
+
+import java.lang.reflect.Method;
+
+/**
+ * @author lican
+ */
+public class HttpsClientNewInstanceInterceptor implements StaticMethodsAroundInterceptor {
+
+
+ @Override
+ public void beforeMethod(Class clazz, Method method, Object[] allArguments, Class>[] parameterTypes, MethodInterceptResult result) {
+
+ }
+
+ @Override
+ public Object afterMethod(Class clazz, Method method, Object[] allArguments, Class>[] parameterTypes, Object ret) {
+ if (ret instanceof EnhancedInstance) {
+ ((EnhancedInstance) ret).setSkyWalkingDynamicField(allArguments[6]);
+ }
+ return ret;
+ }
+
+ @Override
+ public void handleMethodException(Class clazz, Method method, Object[] allArguments, Class>[] parameterTypes, Throwable t) {
+
+ }
+}
\ No newline at end of file
diff --git a/apm-sniffer/bootstrap-plugins/jdk-http-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdk/http/define/HttpClientInstrumentation.java b/apm-sniffer/bootstrap-plugins/jdk-http-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdk/http/define/HttpClientInstrumentation.java
new file mode 100644
index 0000000000000000000000000000000000000000..4d549f70b47e44cc68c5fa66d9bb7a21f08b6c56
--- /dev/null
+++ b/apm-sniffer/bootstrap-plugins/jdk-http-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdk/http/define/HttpClientInstrumentation.java
@@ -0,0 +1,130 @@
+/*
+ * 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.jdk.http.define;
+
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.DeclaredInstanceMethodsInterceptPoint;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.StaticMethodsInterceptPoint;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassEnhancePluginDefine;
+import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
+import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch;
+
+import static net.bytebuddy.matcher.ElementMatchers.named;
+import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
+import static org.apache.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType;
+
+/**
+ * @author lican
+ */
+public class HttpClientInstrumentation extends ClassEnhancePluginDefine {
+
+ private static final String ENHANCE_HTTP_CLASS = "sun.net.www.http.HttpClient";
+
+ private static final String AFTER_METHOD = "parseHTTP";
+
+ private static final String BEFORE_METHOD = "writeRequests";
+
+ private static final String NEW_INSTANCE_METHOD = "New";
+
+ private static final String INTERCEPT_PARSE_HTTP_CLASS = "org.apache.skywalking.apm.plugin.jdk.http.HttpClientParseHttpInterceptor";
+
+ private static final String INTERCEPT_WRITE_REQUEST_CLASS = "org.apache.skywalking.apm.plugin.jdk.http.HttpClientWriteRequestInterceptor";
+
+ private static final String INTERCEPT_HTTP_NEW_INSTANCE_CLASS = "org.apache.skywalking.apm.plugin.jdk.http.HttpClientNewInstanceInterceptor";
+
+ @Override
+ public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
+ return new ConstructorInterceptPoint[0];
+ }
+
+ @Override
+ public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
+ return new InstanceMethodsInterceptPoint[]{new DeclaredInstanceMethodsInterceptPoint() {
+ @Override
+ public ElementMatcher getMethodsMatcher() {
+ return named(AFTER_METHOD);
+ }
+
+ @Override
+ public String getMethodsInterceptor() {
+ return INTERCEPT_PARSE_HTTP_CLASS;
+ }
+
+ @Override
+ public boolean isOverrideArgs() {
+ return false;
+ }
+ }, new DeclaredInstanceMethodsInterceptPoint() {
+ @Override
+ public ElementMatcher getMethodsMatcher() {
+ return named(BEFORE_METHOD).and(takesArguments(2).or(takesArguments(1)));
+ }
+
+ @Override
+ public String getMethodsInterceptor() {
+ return INTERCEPT_WRITE_REQUEST_CLASS;
+ }
+
+ @Override
+ public boolean isOverrideArgs() {
+ return false;
+ }
+ }
+ };
+ }
+
+ @Override
+ public StaticMethodsInterceptPoint[] getStaticMethodsInterceptPoints() {
+ return new StaticMethodsInterceptPoint[]{new StaticMethodsInterceptPoint() {
+ @Override
+ public ElementMatcher getMethodsMatcher() {
+ return named(NEW_INSTANCE_METHOD)
+ .and(takesArguments(5)
+ .and(takesArgumentWithType(0, "java.net.URL"))
+ .and(takesArgumentWithType(4, "sun.net.www.protocol.http.HttpURLConnection"))
+ );
+ }
+
+ @Override
+ public String getMethodsInterceptor() {
+ return INTERCEPT_HTTP_NEW_INSTANCE_CLASS;
+ }
+
+ @Override
+ public boolean isOverrideArgs() {
+ return false;
+ }
+ }
+ };
+ }
+
+ @Override
+ protected ClassMatch enhanceClass() {
+ return NameMatch.byName(ENHANCE_HTTP_CLASS);
+ }
+
+
+ @Override
+ public boolean isBootstrapInstrumentation() {
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/apm-sniffer/bootstrap-plugins/jdk-http-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdk/http/define/HttpsClientInstrumentation.java b/apm-sniffer/bootstrap-plugins/jdk-http-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdk/http/define/HttpsClientInstrumentation.java
new file mode 100644
index 0000000000000000000000000000000000000000..ea85c0994111350109ae0cfecc61c12af0fb07bd
--- /dev/null
+++ b/apm-sniffer/bootstrap-plugins/jdk-http-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdk/http/define/HttpsClientInstrumentation.java
@@ -0,0 +1,92 @@
+/*
+ * 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.jdk.http.define;
+
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+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.StaticMethodsInterceptPoint;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassEnhancePluginDefine;
+import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
+import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch;
+
+import static net.bytebuddy.matcher.ElementMatchers.named;
+import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
+import static org.apache.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType;
+
+/**
+ * @author lican
+ */
+public class HttpsClientInstrumentation extends ClassEnhancePluginDefine {
+
+ private static final String ENHANCE_HTTPS_CLASS = "sun.net.www.protocol.https.HttpsClient";
+
+ private static final String NEW_INSTANCE_METHOD = "New";
+
+ private static final String INTERCEPT_HTTPS_NEW_INSTANCE_CLASS = "org.apache.skywalking.apm.plugin.jdk.http.HttpsClientNewInstanceInterceptor";
+
+
+ @Override
+ public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
+ return new ConstructorInterceptPoint[0];
+ }
+
+ @Override
+ public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
+ return new InstanceMethodsInterceptPoint[0];
+ }
+
+ @Override
+ public StaticMethodsInterceptPoint[] getStaticMethodsInterceptPoints() {
+ return new StaticMethodsInterceptPoint[]{new StaticMethodsInterceptPoint() {
+ @Override
+ public ElementMatcher getMethodsMatcher() {
+ return named(NEW_INSTANCE_METHOD)
+ .and(takesArguments(7)
+ .and(takesArgumentWithType(0, "javax.net.ssl.SSLSocketFactory"))
+ .and(takesArgumentWithType(3, "java.net.Proxy"))
+ .and(takesArgumentWithType(6, "sun.net.www.protocol.http.HttpURLConnection"))
+ );
+ }
+
+ @Override
+ public String getMethodsInterceptor() {
+ return INTERCEPT_HTTPS_NEW_INSTANCE_CLASS;
+ }
+
+ @Override
+ public boolean isOverrideArgs() {
+ return false;
+ }
+ }
+ };
+ }
+
+ @Override
+ protected ClassMatch enhanceClass() {
+ return NameMatch.byName(ENHANCE_HTTPS_CLASS);
+ }
+
+
+ @Override
+ public boolean isBootstrapInstrumentation() {
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/apm-sniffer/bootstrap-plugins/jdk-http-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/bootstrap-plugins/jdk-http-plugin/src/main/resources/skywalking-plugin.def
new file mode 100644
index 0000000000000000000000000000000000000000..f81ac425eb3daf1cf2b03702ed2075b166c15d3f
--- /dev/null
+++ b/apm-sniffer/bootstrap-plugins/jdk-http-plugin/src/main/resources/skywalking-plugin.def
@@ -0,0 +1,18 @@
+# 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.
+
+jdk-http-plugin=org.apache.skywalking.apm.plugin.jdk.http.define.HttpClientInstrumentation
+jdk-http-plugin=org.apache.skywalking.apm.plugin.jdk.http.define.HttpsClientInstrumentation
\ No newline at end of file
diff --git a/apm-sniffer/bootstrap-plugins/pom.xml b/apm-sniffer/bootstrap-plugins/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..9c04ff14eca4d390d8e449a25e353bd68fe5dafc
--- /dev/null
+++ b/apm-sniffer/bootstrap-plugins/pom.xml
@@ -0,0 +1,137 @@
+
+
+
+
+
+ apm-sniffer
+ org.apache.skywalking
+ 6.3.0-SNAPSHOT
+
+ 4.0.0
+
+ bootstrap-plugins
+ pom
+
+ net.bytebuddy
+ ${shade.package}.${shade.net.bytebuddy.source}
+ UTF-8
+
+
+ ${project.build.directory}${sdk.plugin.related.dir}/../../../../skywalking-agent
+ ${agent.package.dest.dir}/bootstrap-plugins
+
+ 1.0b3
+ 1.8.1
+
+
+
+ jdk-http-plugin
+
+
+
+
+ org.apache.skywalking
+ apm-agent-core
+ ${project.version}
+ provided
+
+
+ org.apache.skywalking
+ apm-util
+ ${project.version}
+ provided
+
+
+ org.apache.skywalking
+ apm-test-tools
+ ${project.version}
+ test
+
+
+
+
+
+
+ maven-shade-plugin
+
+
+ package
+
+ shade
+
+
+ false
+ true
+ true
+ true
+
+
+ ${shade.net.bytebuddy.source}
+ ${shade.net.bytebuddy.target}
+
+
+
+
+
+
+
+ maven-antrun-plugin
+
+
+ package
+
+ run
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ant-contrib
+ ant-contrib
+ ${ant-contrib.version}
+
+
+ ant
+ ant
+
+
+
+
+ org.apache.ant
+ ant-nodeps
+ ${ant-nodeps.version}
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/apm-sniffer/pom.xml b/apm-sniffer/pom.xml
index c4aeacd97ec720f290060e9811ef7abe59a5afdb..af303195c6004e2503c3e8c883744e3d953fad58 100644
--- a/apm-sniffer/pom.xml
+++ b/apm-sniffer/pom.xml
@@ -34,6 +34,7 @@
apm-sdk-plugin
apm-toolkit-activation
apm-test-tools
+ bootstrap-plugins
optional-plugins
diff --git a/docs/en/setup/service-agent/java-agent/README.md b/docs/en/setup/service-agent/java-agent/README.md
index 41b1863b78a96194c53a7f0887e3a199e148bdf6..caaf775df8bcb2703beb5cc574a84cf8bfb6eeca 100755
--- a/docs/en/setup/service-agent/java-agent/README.md
+++ b/docs/en/setup/service-agent/java-agent/README.md
@@ -23,6 +23,9 @@ The agent release dist is included in Apache [official release](http://skywalkin
+-- optional-plugins
apm-gson-2.x-plugin.jar
.....
+ +-- bootstrap-plugins
+ jdk-http-plugin.jar
+ .....
+-- logs
skywalking-agent.jar
```
@@ -111,6 +114,10 @@ Now, we have the following known optional plugins.
## Bootstrap class plugins
All bootstrap plugins are optional, due to unexpected risk. Bootstrap plugins are provided in `bootstrap-plugins` folder.
+For using these plugins, you need to put the target plugin jar file into `/plugins`.
+
+Now, we have the following known bootstrap plugins.
+* Plugin of JDK HttpURLConnection. Agent is compatible with JDK 1.6+
## Advanced Features
* Set the settings through system properties for config file override. Read [setting override](Setting-override.md).
diff --git a/oap-server/server-starter/src/main/resources/component-libraries.yml b/oap-server/server-starter/src/main/resources/component-libraries.yml
index e4200c26f013cc16f55d16a5fa92ff94efc1bf83..aca7d915165f844a50ec6ee058f2c542bd11f1d4 100644
--- a/oap-server/server-starter/src/main/resources/component-libraries.yml
+++ b/oap-server/server-starter/src/main/resources/component-libraries.yml
@@ -225,6 +225,9 @@ Solr:
SpringAsync:
id: 65
languages: Java
+JdkHttp:
+ id: 66
+ languages: Java
# .NET/.NET Core components