-
Notifications
You must be signed in to change notification settings - Fork 377
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* dubbo compatible all for 2.6.x and 2.7.x
- Loading branch information
Showing
41 changed files
with
2,254 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
sofa-tracer-plugins/sofa-tracer-dubbo-common-plugin/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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>tracer-all-parent</artifactId> | ||
<groupId>com.alipay.sofa</groupId> | ||
<version>3.0.12</version> | ||
<relativePath>../../pom.xml</relativePath> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>sofa-tracer-dubbo-common-plugin</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.alibaba</groupId> | ||
<artifactId>dubbo</artifactId> | ||
<version>2.6.2</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo</artifactId> | ||
<version>2.7.3</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.alipay.sofa</groupId> | ||
<artifactId>tracer-core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-io</groupId> | ||
<artifactId>commons-io</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.alibaba</groupId> | ||
<artifactId>fastjson</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
34 changes: 34 additions & 0 deletions
34
.../src/main/java/com/alipay/sofa/tracer/plugins/dubbo/constants/AttachmentKeyConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* 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 com.alipay.sofa.tracer.plugins.dubbo.constants; | ||
|
||
/** | ||
* @author: guolei.sgl ([email protected]) 2019/7/26 5:25 PM | ||
* @since: | ||
**/ | ||
public class AttachmentKeyConstants { | ||
|
||
public static final String SERVER_DESERIALIZE_SIZE = "server.deserialize.size"; | ||
public static final String SERVER_SERIALIZE_SIZE = "server.serialize.size"; | ||
public static final String CLIENT_DESERIALIZE_SIZE = "client.deserialize.size"; | ||
public static final String CLIENT_SERIALIZE_SIZE = "client.serialize.size"; | ||
|
||
public static final String SERVER_DESERIALIZE_TIME = "server.deserialize.time"; | ||
public static final String SERVER_SERIALIZE_TIME = "server.serialize.time"; | ||
public static final String CLIENT_DESERIALIZE_TIME = "client.deserialize.time"; | ||
public static final String CLIENT_SERIALIZE_TIME = "client.serialize.time"; | ||
} |
69 changes: 69 additions & 0 deletions
69
.../src/main/java/com/alipay/sofa/tracer/plugins/dubbo/encoder/DubboClientDigestEncoder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 com.alipay.sofa.tracer.plugins.dubbo.encoder; | ||
|
||
import com.alipay.common.tracer.core.appender.builder.JsonStringBuilder; | ||
import com.alipay.common.tracer.core.appender.builder.XStringBuilder; | ||
import com.alipay.common.tracer.core.middleware.parent.AbstractDigestSpanEncoder; | ||
import com.alipay.common.tracer.core.span.CommonSpanTags; | ||
import com.alipay.common.tracer.core.span.SofaTracerSpan; | ||
import com.alipay.common.tracer.core.utils.StringUtils; | ||
import com.alipay.sofa.tracer.plugins.dubbo.constants.AttachmentKeyConstants; | ||
import io.opentracing.tag.Tags; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* @author: guolei.sgl ([email protected]) 2019/9/1 2:46 PM | ||
* @since: | ||
**/ | ||
public class DubboClientDigestEncoder extends AbstractDigestSpanEncoder { | ||
|
||
@Override | ||
protected void appendComponentSlot(XStringBuilder xsb, JsonStringBuilder jsb, | ||
SofaTracerSpan span) { | ||
Map<String, String> tagWithStr = span.getTagsWithStr(); | ||
Map<String, Number> tagWithNum = span.getTagsWithNumber(); | ||
//protocol | ||
xsb.append(tagWithStr.get(CommonSpanTags.PROTOCOL)); | ||
// service | ||
xsb.append(tagWithStr.get(CommonSpanTags.SERVICE)); | ||
// method | ||
xsb.append(tagWithStr.get(CommonSpanTags.METHOD)); | ||
// invoke type | ||
xsb.append(tagWithStr.get(CommonSpanTags.INVOKE_TYPE)); | ||
// remote host | ||
xsb.append(tagWithStr.get(CommonSpanTags.REMOTE_HOST)); | ||
// remote port | ||
xsb.append(tagWithStr.get(CommonSpanTags.REMOTE_PORT)); | ||
// local port | ||
xsb.append(tagWithStr.get(CommonSpanTags.LOCAL_HOST)); | ||
// client.serialize.time | ||
xsb.append(tagWithNum.get(AttachmentKeyConstants.CLIENT_SERIALIZE_TIME) + ""); | ||
// client.deserialize.time | ||
xsb.append(tagWithNum.get(AttachmentKeyConstants.CLIENT_DESERIALIZE_TIME) + ""); | ||
// client.serialize.size | ||
Number reqSizeNum = tagWithNum.get(AttachmentKeyConstants.CLIENT_SERIALIZE_SIZE); | ||
xsb.append(reqSizeNum == null ? 0 : reqSizeNum.longValue()); | ||
// client.deserialize.size | ||
Number respSizeNum = tagWithNum.get(AttachmentKeyConstants.CLIENT_DESERIALIZE_SIZE); | ||
xsb.append(respSizeNum == null ? 0 : respSizeNum.longValue()); | ||
// error message | ||
xsb.append(StringUtils.isBlank(tagWithStr.get(Tags.ERROR.getKey())) ? "" : tagWithStr | ||
.get(Tags.ERROR.getKey())); | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
.../main/java/com/alipay/sofa/tracer/plugins/dubbo/encoder/DubboClientDigestJsonEncoder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* 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 com.alipay.sofa.tracer.plugins.dubbo.encoder; | ||
|
||
import com.alipay.common.tracer.core.appender.builder.JsonStringBuilder; | ||
import com.alipay.common.tracer.core.appender.builder.XStringBuilder; | ||
import com.alipay.common.tracer.core.middleware.parent.AbstractDigestSpanEncoder; | ||
import com.alipay.common.tracer.core.span.CommonSpanTags; | ||
import com.alipay.common.tracer.core.span.SofaTracerSpan; | ||
import com.alipay.common.tracer.core.utils.StringUtils; | ||
import com.alipay.sofa.tracer.plugins.dubbo.constants.AttachmentKeyConstants; | ||
import io.opentracing.tag.Tags; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* @author: guolei.sgl ([email protected]) 2019/2/26 3:56 PM | ||
* @since: | ||
**/ | ||
public class DubboClientDigestJsonEncoder extends AbstractDigestSpanEncoder { | ||
|
||
@Override | ||
protected void appendComponentSlot(XStringBuilder xsb, JsonStringBuilder jsb, | ||
SofaTracerSpan span) { | ||
Map<String, String> tagStr = span.getTagsWithStr(); | ||
Map<String, Number> tagNum = span.getTagsWithNumber(); | ||
|
||
// protocol | ||
jsb.append(CommonSpanTags.PROTOCOL, tagStr.get(CommonSpanTags.PROTOCOL)); | ||
// serviceName | ||
jsb.append(CommonSpanTags.SERVICE, tagStr.get(CommonSpanTags.SERVICE)); | ||
// method | ||
jsb.append(CommonSpanTags.METHOD, tagStr.get(CommonSpanTags.METHOD)); | ||
//invoke type | ||
jsb.append(CommonSpanTags.INVOKE_TYPE, tagStr.get(CommonSpanTags.INVOKE_TYPE)); | ||
//target ip | ||
jsb.append(CommonSpanTags.REMOTE_HOST, tagStr.get(CommonSpanTags.REMOTE_HOST)); | ||
//target port | ||
jsb.append(CommonSpanTags.REMOTE_PORT, tagStr.get(CommonSpanTags.REMOTE_PORT)); | ||
//local ip | ||
jsb.append(CommonSpanTags.LOCAL_HOST, tagStr.get(CommonSpanTags.LOCAL_HOST)); | ||
//request serialize time | ||
jsb.append(CommonSpanTags.CLIENT_SERIALIZE_TIME, | ||
tagNum.get(AttachmentKeyConstants.CLIENT_SERIALIZE_TIME)); | ||
//response deserialize time | ||
jsb.append(CommonSpanTags.CLIENT_DESERIALIZE_TIME, | ||
tagNum.get(AttachmentKeyConstants.CLIENT_DESERIALIZE_TIME)); | ||
//Request Body bytes length | ||
Number reqSizeNum = tagNum.get(AttachmentKeyConstants.CLIENT_SERIALIZE_SIZE); | ||
jsb.append(CommonSpanTags.REQ_SIZE, reqSizeNum == null ? 0 : reqSizeNum.longValue()); | ||
//Response Body bytes length | ||
Number respSizeNum = tagNum.get(AttachmentKeyConstants.CLIENT_DESERIALIZE_SIZE); | ||
jsb.append(CommonSpanTags.RESP_SIZE, respSizeNum == null ? 0 : respSizeNum.longValue()); | ||
|
||
//error message | ||
if (StringUtils.isNotBlank(tagStr.get(Tags.ERROR.getKey()))) { | ||
jsb.append(Tags.ERROR.getKey(), tagStr.get(Tags.ERROR.getKey())); | ||
} else { | ||
jsb.append(Tags.ERROR.getKey(), StringUtils.EMPTY_STRING); | ||
} | ||
} | ||
} |
Oops, something went wrong.