Staticize the tags for preventing synchronization in JDK 8 (#596)
This commit is contained in:
parent
e31b9bb6a2
commit
9a65fcbd6b
|
|
@ -152,6 +152,7 @@ Callable {
|
|||
* Merge two instrumentation classes to avoid duplicate enhancements in MySQL plugins.
|
||||
* Support asynchronous invocation in jetty client 9.0 and 9.x plugin
|
||||
* Add nacos-client 2.x plugin
|
||||
* Staticize the tags for preventing synchronization in JDK 8
|
||||
|
||||
#### Documentation
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ package org.apache.skywalking.apm.plugin.canal;
|
|||
import com.alibaba.otter.canal.client.impl.SimpleCanalConnector;
|
||||
import java.util.Objects;
|
||||
import org.apache.skywalking.apm.agent.core.context.ContextManager;
|
||||
import org.apache.skywalking.apm.agent.core.context.tag.AbstractTag;
|
||||
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;
|
||||
|
|
@ -33,6 +34,11 @@ import java.net.InetSocketAddress;
|
|||
import java.util.List;
|
||||
|
||||
public class CanalInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
|
||||
private static final AbstractTag<String> BATCH_SIZE_TAG = Tags.ofKey("batchSize");
|
||||
|
||||
private static final AbstractTag<String> DESTINATION_TAG = Tags.ofKey("destination");
|
||||
|
||||
@Override
|
||||
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
|
||||
MethodInterceptResult result) throws Throwable {
|
||||
|
|
@ -62,8 +68,8 @@ public class CanalInterceptor implements InstanceMethodsAroundInterceptor {
|
|||
AbstractSpan activeSpan = ContextManager.createExitSpan("Canal/" + destination, url)
|
||||
.start(System.currentTimeMillis());
|
||||
activeSpan.setComponent(ComponentsDefine.CANAL);
|
||||
activeSpan.tag(Tags.ofKey("batchSize"), batchSize);
|
||||
activeSpan.tag(Tags.ofKey("destination"), destination);
|
||||
activeSpan.tag(BATCH_SIZE_TAG, batchSize);
|
||||
activeSpan.tag(DESTINATION_TAG, destination);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ package org.apache.skywalking.apm.plugin.elasticjob;
|
|||
|
||||
import org.apache.shardingsphere.elasticjob.infra.listener.ShardingContexts;
|
||||
import org.apache.skywalking.apm.agent.core.context.ContextManager;
|
||||
import org.apache.skywalking.apm.agent.core.context.tag.AbstractTag;
|
||||
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;
|
||||
|
|
@ -30,6 +31,15 @@ import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
|
|||
import java.lang.reflect.Method;
|
||||
|
||||
public class ElasticJobExecutorInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
|
||||
private static final AbstractTag<String> ITEM_TAG = Tags.ofKey("item");
|
||||
|
||||
private static final AbstractTag<String> SHARDING_TOTAL_COUNT_TAG = Tags.ofKey("shardingTotalCount");
|
||||
|
||||
private static final AbstractTag<String> TASK_ID_TAG = Tags.ofKey("taskId");
|
||||
|
||||
private static final AbstractTag<String> SHARDING_ITEM_PARAMETERS_TAG = Tags.ofKey("shardingItemParameters");
|
||||
|
||||
@Override
|
||||
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
|
||||
MethodInterceptResult result) {
|
||||
|
|
@ -39,10 +49,10 @@ public class ElasticJobExecutorInterceptor implements InstanceMethodsAroundInter
|
|||
AbstractSpan span = ContextManager.createLocalSpan(operateName);
|
||||
span.setComponent(ComponentsDefine.ELASTIC_JOB);
|
||||
Tags.LOGIC_ENDPOINT.set(span, Tags.VAL_LOCAL_SPAN_AS_LOGIC_ENDPOINT);
|
||||
span.tag(Tags.ofKey("item"), item == null ? "" : String.valueOf(item));
|
||||
span.tag(Tags.ofKey("shardingTotalCount"), Integer.toString(shardingContexts.getShardingTotalCount()));
|
||||
span.tag(Tags.ofKey("taskId"), shardingContexts.getTaskId());
|
||||
span.tag(Tags.ofKey("shardingItemParameters"), shardingContexts.getShardingItemParameters() == null ?
|
||||
span.tag(ITEM_TAG, item == null ? "" : String.valueOf(item));
|
||||
span.tag(SHARDING_TOTAL_COUNT_TAG, Integer.toString(shardingContexts.getShardingTotalCount()));
|
||||
span.tag(TASK_ID_TAG, shardingContexts.getTaskId());
|
||||
span.tag(SHARDING_ITEM_PARAMETERS_TAG, shardingContexts.getShardingItemParameters() == null ?
|
||||
"" : shardingContexts.getShardingItemParameters().toString());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
package org.apache.skywalking.apm.plugin.elasticsearch.v6.interceptor;
|
||||
|
||||
import org.apache.skywalking.apm.agent.core.context.ContextManager;
|
||||
import org.apache.skywalking.apm.agent.core.context.tag.AbstractTag;
|
||||
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;
|
||||
|
|
@ -36,6 +37,8 @@ import static org.apache.skywalking.apm.plugin.elasticsearch.v6.interceptor.Cons
|
|||
|
||||
public class IndicesClientAnalyzeMethodsInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
|
||||
private static final AbstractTag<String> ANALYZER_TAG = Tags.ofKey("analyzer");
|
||||
|
||||
@Override
|
||||
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
|
||||
MethodInterceptResult result) throws Throwable {
|
||||
|
|
@ -47,7 +50,7 @@ public class IndicesClientAnalyzeMethodsInterceptor implements InstanceMethodsAr
|
|||
span.setComponent(ComponentsDefine.REST_HIGH_LEVEL_CLIENT);
|
||||
|
||||
Tags.DB_TYPE.set(span, DB_TYPE);
|
||||
span.tag(Tags.ofKey("analyzer"), analyzeRequest.analyzer());
|
||||
span.tag(ANALYZER_TAG, analyzeRequest.analyzer());
|
||||
if (TRACE_DSL) {
|
||||
Tags.DB_STATEMENT.set(span, analyzeRequest.text()[0]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,9 @@
|
|||
|
||||
package org.apache.skywalking.apm.plugin.grpc.v1;
|
||||
|
||||
import org.apache.skywalking.apm.agent.core.context.tag.AbstractTag;
|
||||
import org.apache.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
/**
|
||||
* Constant variables
|
||||
*/
|
||||
|
|
@ -78,4 +81,6 @@ public class Constants {
|
|||
public static final String GENERIC_CALL_METHOD = "GENERIC_CALL_METHOD";
|
||||
|
||||
public static final String CLIENT_STREAM_PEER = "CLIENT_STREAM_PEER";
|
||||
|
||||
public static final AbstractTag<String> GENERIC_CALL_METHOD_TAG = Tags.ofKey("GENERIC_CALL_METHOD");
|
||||
}
|
||||
|
|
@ -40,6 +40,7 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceC
|
|||
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.grpc.v1.Constants;
|
||||
import org.apache.skywalking.apm.plugin.grpc.v1.OperationNameFormatUtil;
|
||||
import org.apache.skywalking.apm.util.StringUtil;
|
||||
|
||||
|
|
@ -87,7 +88,7 @@ public class ClientCallImplGenericCallInterceptor
|
|||
AbstractSpan span = ContextManager.createExitSpan(serviceName, contextCarrier, remotePeer);
|
||||
span.setComponent(ComponentsDefine.GRPC);
|
||||
span.setLayer(SpanLayer.RPC_FRAMEWORK);
|
||||
span.tag(Tags.ofKey(GENERIC_CALL_METHOD), asyncCallMethod);
|
||||
span.tag(Constants.GENERIC_CALL_METHOD_TAG, asyncCallMethod);
|
||||
|
||||
CarrierItem contextItem = contextCarrier.items();
|
||||
while (contextItem.hasNext()) {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ package org.apache.skywalking.apm.plugin.netty.socketio;
|
|||
import com.corundumstudio.socketio.SocketIOClient;
|
||||
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.AbstractTag;
|
||||
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;
|
||||
|
|
@ -34,6 +35,8 @@ import java.net.InetSocketAddress;
|
|||
|
||||
public class NettySocketIOConnectionInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
|
||||
private static final AbstractTag<String> FROM_TAG = Tags.ofKey("from");
|
||||
|
||||
@Override
|
||||
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
|
||||
MethodInterceptResult result) throws Throwable {
|
||||
|
|
@ -46,7 +49,7 @@ public class NettySocketIOConnectionInterceptor implements InstanceMethodsAround
|
|||
// set client addr
|
||||
InetSocketAddress remoteAddress = (InetSocketAddress) client.getRemoteAddress();
|
||||
String clientAddress = remoteAddress.getAddress().getHostAddress() + ":" + remoteAddress.getPort();
|
||||
span.tag(Tags.ofKey("from"), clientAddress);
|
||||
span.tag(FROM_TAG, clientAddress);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import java.lang.reflect.Method;
|
|||
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.AbstractTag;
|
||||
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;
|
||||
|
|
@ -49,6 +50,10 @@ public class MessageSendInterceptor implements InstanceMethodsAroundInterceptor
|
|||
|
||||
private static final String ASYNC_SEND_OPERATION_NAME_PREFIX = "RocketMQ/";
|
||||
|
||||
private static final AbstractTag<String> MQ_MESSAGE_KEYS_TAG = Tags.ofKey("mq.message.keys");
|
||||
|
||||
private static final AbstractTag<String> MQ_MESSAGE_TAGS_TAG = Tags.ofKey("mq.message.tags");
|
||||
|
||||
@Override
|
||||
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
|
||||
MethodInterceptResult result) throws Throwable {
|
||||
|
|
@ -61,11 +66,11 @@ public class MessageSendInterceptor implements InstanceMethodsAroundInterceptor
|
|||
Tags.MQ_TOPIC.set(span, message.getTopic());
|
||||
String keys = message.getKeys();
|
||||
if (StringUtil.isNotBlank(keys)) {
|
||||
span.tag(Tags.ofKey("mq.message.keys"), keys);
|
||||
span.tag(MQ_MESSAGE_KEYS_TAG, keys);
|
||||
}
|
||||
String tags = message.getTags();
|
||||
if (StringUtil.isNotBlank(tags)) {
|
||||
span.tag(Tags.ofKey("mq.message.tags"), tags);
|
||||
span.tag(MQ_MESSAGE_TAGS_TAG, tags);
|
||||
}
|
||||
|
||||
contextCarrier.extensionInjector().injectSendingTimestamp();
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import org.apache.rocketmq.common.protocol.header.SendMessageRequestHeader;
|
|||
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.AbstractTag;
|
||||
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;
|
||||
|
|
@ -49,6 +50,10 @@ public class MessageSendInterceptor implements InstanceMethodsAroundInterceptor
|
|||
|
||||
public static final String ASYNC_SEND_OPERATION_NAME_PREFIX = "RocketMQ/";
|
||||
|
||||
private static final AbstractTag<String> MQ_MESSAGE_KEYS_TAG = Tags.ofKey("mq.message.keys");
|
||||
|
||||
private static final AbstractTag<String> MQ_MESSAGE_TAGS_TAG = Tags.ofKey("mq.message.tags");
|
||||
|
||||
@Override
|
||||
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
|
||||
MethodInterceptResult result) throws Throwable {
|
||||
|
|
@ -61,11 +66,11 @@ public class MessageSendInterceptor implements InstanceMethodsAroundInterceptor
|
|||
Tags.MQ_TOPIC.set(span, message.getTopic());
|
||||
String keys = message.getKeys();
|
||||
if (StringUtil.isNotBlank(keys)) {
|
||||
span.tag(Tags.ofKey("mq.message.keys"), keys);
|
||||
span.tag(MQ_MESSAGE_KEYS_TAG, keys);
|
||||
}
|
||||
String tags = message.getTags();
|
||||
if (StringUtil.isNotBlank(tags)) {
|
||||
span.tag(Tags.ofKey("mq.message.tags"), tags);
|
||||
span.tag(MQ_MESSAGE_TAGS_TAG, tags);
|
||||
}
|
||||
|
||||
contextCarrier.extensionInjector().injectSendingTimestamp();
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import org.apache.rocketmq.remoting.protocol.header.SendMessageRequestHeader;
|
|||
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.AbstractTag;
|
||||
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;
|
||||
|
|
@ -50,6 +51,10 @@ public class MessageSendInterceptor implements InstanceMethodsAroundInterceptor
|
|||
|
||||
public static final String ASYNC_SEND_OPERATION_NAME_PREFIX = "RocketMQ/";
|
||||
|
||||
private static final AbstractTag<String> MQ_MESSAGE_KEYS_TAG = Tags.ofKey("mq.message.keys");
|
||||
|
||||
private static final AbstractTag<String> MQ_MESSAGE_TAGS_TAG = Tags.ofKey("mq.message.tags");
|
||||
|
||||
@Override
|
||||
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
|
||||
MethodInterceptResult result) throws Throwable {
|
||||
|
|
@ -62,11 +67,11 @@ public class MessageSendInterceptor implements InstanceMethodsAroundInterceptor
|
|||
Tags.MQ_TOPIC.set(span, message.getTopic());
|
||||
String keys = message.getKeys();
|
||||
if (StringUtil.isNotBlank(keys)) {
|
||||
span.tag(Tags.ofKey("mq.message.keys"), keys);
|
||||
span.tag(MQ_MESSAGE_KEYS_TAG, keys);
|
||||
}
|
||||
String tags = message.getTags();
|
||||
if (StringUtil.isNotBlank(tags)) {
|
||||
span.tag(Tags.ofKey("mq.message.tags"), tags);
|
||||
span.tag(MQ_MESSAGE_TAGS_TAG, tags);
|
||||
}
|
||||
|
||||
contextCarrier.extensionInjector().injectSendingTimestamp();
|
||||
|
|
|
|||
|
|
@ -19,18 +19,17 @@
|
|||
package org.apache.skywalking.apm.plugin.fastjson;
|
||||
|
||||
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.MethodInterceptResult;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.StaticMethodsAroundInterceptor;
|
||||
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
|
||||
import org.apache.skywalking.apm.plugin.fastjson.common.Constants;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class ParseArrayInterceptor implements StaticMethodsAroundInterceptor {
|
||||
|
||||
public static final String OPERATION_NAME_FROM_JSON = "Fastjson/";
|
||||
public static final String SPAN_TAG_KEY_LENGTH = "length";
|
||||
|
||||
@Override
|
||||
public void beforeMethod(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes, MethodInterceptResult result) {
|
||||
|
|
@ -39,7 +38,7 @@ public class ParseArrayInterceptor implements StaticMethodsAroundInterceptor {
|
|||
span.setComponent(ComponentsDefine.FASTJSON);
|
||||
|
||||
if (allArguments[0] instanceof String) {
|
||||
span.tag(Tags.ofKey(SPAN_TAG_KEY_LENGTH), Integer.toString(((String) allArguments[0]).length()));
|
||||
span.tag(Constants.SPAN_TAG_KEY_LENGTH, Integer.toString(((String) allArguments[0]).length()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,18 +19,17 @@
|
|||
package org.apache.skywalking.apm.plugin.fastjson;
|
||||
|
||||
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.MethodInterceptResult;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.StaticMethodsAroundInterceptor;
|
||||
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
|
||||
import org.apache.skywalking.apm.plugin.fastjson.common.Constants;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class ParseInterceptor implements StaticMethodsAroundInterceptor {
|
||||
|
||||
public static final String OPERATION_NAME_FROM_JSON = "Fastjson/";
|
||||
public static final String SPAN_TAG_KEY_LENGTH = "length";
|
||||
|
||||
@Override
|
||||
public void beforeMethod(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes, MethodInterceptResult result) {
|
||||
|
|
@ -39,9 +38,9 @@ public class ParseInterceptor implements StaticMethodsAroundInterceptor {
|
|||
span.setComponent(ComponentsDefine.FASTJSON);
|
||||
|
||||
if (allArguments[0] instanceof String) {
|
||||
span.tag(Tags.ofKey(SPAN_TAG_KEY_LENGTH), Integer.toString(((String) allArguments[0]).length()));
|
||||
span.tag(Constants.SPAN_TAG_KEY_LENGTH, Integer.toString(((String) allArguments[0]).length()));
|
||||
} else if (allArguments[0] instanceof byte[]) {
|
||||
span.tag(Tags.ofKey(SPAN_TAG_KEY_LENGTH), Integer.toString(((byte[]) allArguments[0]).length));
|
||||
span.tag(Constants.SPAN_TAG_KEY_LENGTH, Integer.toString(((byte[]) allArguments[0]).length));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,11 +19,11 @@
|
|||
package org.apache.skywalking.apm.plugin.fastjson;
|
||||
|
||||
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.MethodInterceptResult;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.StaticMethodsAroundInterceptor;
|
||||
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
|
||||
import org.apache.skywalking.apm.plugin.fastjson.common.Constants;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
|
|
@ -31,7 +31,6 @@ import java.lang.reflect.Method;
|
|||
public class ParseObjectInterceptor implements StaticMethodsAroundInterceptor {
|
||||
|
||||
public static final String OPERATION_NAME_FROM_JSON = "Fastjson/";
|
||||
public static final String SPAN_TAG_KEY_LENGTH = "length";
|
||||
|
||||
@Override
|
||||
public void beforeMethod(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes, MethodInterceptResult result) {
|
||||
|
|
@ -40,13 +39,13 @@ public class ParseObjectInterceptor implements StaticMethodsAroundInterceptor {
|
|||
span.setComponent(ComponentsDefine.FASTJSON);
|
||||
|
||||
if (allArguments[0] instanceof String) {
|
||||
span.tag(Tags.ofKey(SPAN_TAG_KEY_LENGTH), Integer.toString(((String) allArguments[0]).length()));
|
||||
span.tag(Constants.SPAN_TAG_KEY_LENGTH, Integer.toString(((String) allArguments[0]).length()));
|
||||
} else if (allArguments[0] instanceof byte[]) {
|
||||
span.tag(Tags.ofKey(SPAN_TAG_KEY_LENGTH), Integer.toString(((byte[]) allArguments[0]).length));
|
||||
span.tag(Constants.SPAN_TAG_KEY_LENGTH, Integer.toString(((byte[]) allArguments[0]).length));
|
||||
} else if (allArguments[0] instanceof char[]) {
|
||||
span.tag(Tags.ofKey(SPAN_TAG_KEY_LENGTH), Integer.toString(((char[]) allArguments[0]).length));
|
||||
span.tag(Constants.SPAN_TAG_KEY_LENGTH, Integer.toString(((char[]) allArguments[0]).length));
|
||||
} else if (allArguments[0] instanceof InputStream) {
|
||||
span.tag(Tags.ofKey(SPAN_TAG_KEY_LENGTH), Integer.toString(inputStreamAvailable(allArguments[0])));
|
||||
span.tag(Constants.SPAN_TAG_KEY_LENGTH, Integer.toString(inputStreamAvailable(allArguments[0])));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,18 +19,17 @@
|
|||
package org.apache.skywalking.apm.plugin.fastjson;
|
||||
|
||||
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.MethodInterceptResult;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.StaticMethodsAroundInterceptor;
|
||||
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
|
||||
import org.apache.skywalking.apm.plugin.fastjson.common.Constants;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class ToJavaObjectInterceptor implements StaticMethodsAroundInterceptor {
|
||||
|
||||
public static final String OPERATION_NAME_TO_JSON = "Fastjson/";
|
||||
public static final String SPAN_TAG_KEY_OBJECT = "object";
|
||||
|
||||
@Override
|
||||
public void beforeMethod(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes, MethodInterceptResult result) {
|
||||
|
|
@ -39,7 +38,7 @@ public class ToJavaObjectInterceptor implements StaticMethodsAroundInterceptor {
|
|||
span.setComponent(ComponentsDefine.FASTJSON);
|
||||
|
||||
if (allArguments.length > 1 && allArguments[1] instanceof Class) {
|
||||
span.tag(Tags.ofKey(SPAN_TAG_KEY_OBJECT), ((Class) allArguments[1]).getTypeName());
|
||||
span.tag(Constants.SPAN_TAG_KEY_OBJECT, ((Class) allArguments[1]).getTypeName());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,18 +19,17 @@
|
|||
package org.apache.skywalking.apm.plugin.fastjson;
|
||||
|
||||
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.MethodInterceptResult;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.StaticMethodsAroundInterceptor;
|
||||
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
|
||||
import org.apache.skywalking.apm.plugin.fastjson.common.Constants;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class ToJsonBytesInterceptor implements StaticMethodsAroundInterceptor {
|
||||
|
||||
public static final String OPERATION_NAME_TO_JSON = "Fastjson/";
|
||||
public static final String SPAN_TAG_KEY_LENGTH = "length";
|
||||
|
||||
@Override
|
||||
public void beforeMethod(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes, MethodInterceptResult result) {
|
||||
|
|
@ -46,7 +45,7 @@ public class ToJsonBytesInterceptor implements StaticMethodsAroundInterceptor {
|
|||
return ret;
|
||||
}
|
||||
if (ret instanceof byte[]) {
|
||||
ContextManager.activeSpan().tag(Tags.ofKey(SPAN_TAG_KEY_LENGTH), Integer.toString(((byte[]) ret).length));
|
||||
ContextManager.activeSpan().tag(Constants.SPAN_TAG_KEY_LENGTH, Integer.toString(((byte[]) ret).length));
|
||||
}
|
||||
ContextManager.stopSpan();
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -19,18 +19,17 @@
|
|||
package org.apache.skywalking.apm.plugin.fastjson;
|
||||
|
||||
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.MethodInterceptResult;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.StaticMethodsAroundInterceptor;
|
||||
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
|
||||
import org.apache.skywalking.apm.plugin.fastjson.common.Constants;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class ToJsonInterceptor implements StaticMethodsAroundInterceptor {
|
||||
|
||||
public static final String OPERATION_NAME_TO_JSON = "Fastjson/";
|
||||
public static final String SPAN_TAG_KEY_OBJECT = "object";
|
||||
|
||||
@Override
|
||||
public void beforeMethod(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes, MethodInterceptResult result) {
|
||||
|
|
@ -46,7 +45,7 @@ public class ToJsonInterceptor implements StaticMethodsAroundInterceptor {
|
|||
return ret;
|
||||
}
|
||||
if (ret != null) {
|
||||
ContextManager.activeSpan().tag(Tags.ofKey(SPAN_TAG_KEY_OBJECT), String.valueOf(ret.getClass().getTypeName()));
|
||||
ContextManager.activeSpan().tag(Constants.SPAN_TAG_KEY_OBJECT, String.valueOf(ret.getClass().getTypeName()));
|
||||
}
|
||||
ContextManager.stopSpan();
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -19,18 +19,17 @@
|
|||
package org.apache.skywalking.apm.plugin.fastjson;
|
||||
|
||||
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.MethodInterceptResult;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.StaticMethodsAroundInterceptor;
|
||||
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
|
||||
import org.apache.skywalking.apm.plugin.fastjson.common.Constants;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class ToJsonStringInterceptor implements StaticMethodsAroundInterceptor {
|
||||
|
||||
public static final String OPERATION_NAME_TO_JSON = "Fastjson/";
|
||||
public static final String SPAN_TAG_KEY_LENGTH = "length";
|
||||
|
||||
@Override
|
||||
public void beforeMethod(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes, MethodInterceptResult result) {
|
||||
|
|
@ -46,7 +45,7 @@ public class ToJsonStringInterceptor implements StaticMethodsAroundInterceptor {
|
|||
return ret;
|
||||
}
|
||||
if (ret instanceof String) {
|
||||
ContextManager.activeSpan().tag(Tags.ofKey(SPAN_TAG_KEY_LENGTH), Integer.toString(((String) ret).length()));
|
||||
ContextManager.activeSpan().tag(Constants.SPAN_TAG_KEY_LENGTH, Integer.toString(((String) ret).length()));
|
||||
}
|
||||
ContextManager.stopSpan();
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -19,18 +19,17 @@
|
|||
package org.apache.skywalking.apm.plugin.fastjson;
|
||||
|
||||
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.MethodInterceptResult;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.StaticMethodsAroundInterceptor;
|
||||
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
|
||||
import org.apache.skywalking.apm.plugin.fastjson.common.Constants;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class WriteJsonStringInterceptor implements StaticMethodsAroundInterceptor {
|
||||
|
||||
public static final String OPERATION_NAME_TO_JSON = "Fastjson/";
|
||||
public static final String SPAN_TAG_KEY_LENGTH = "length";
|
||||
|
||||
@Override
|
||||
public void beforeMethod(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes, MethodInterceptResult result) {
|
||||
|
|
@ -46,7 +45,7 @@ public class WriteJsonStringInterceptor implements StaticMethodsAroundIntercepto
|
|||
return ret;
|
||||
}
|
||||
if (ret instanceof Integer) {
|
||||
ContextManager.activeSpan().tag(Tags.ofKey(SPAN_TAG_KEY_LENGTH), Integer.toString(((Integer) ret).intValue()));
|
||||
ContextManager.activeSpan().tag(Constants.SPAN_TAG_KEY_LENGTH, Integer.toString(((Integer) ret).intValue()));
|
||||
}
|
||||
ContextManager.stopSpan();
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* 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.fastjson.common;
|
||||
|
||||
import org.apache.skywalking.apm.agent.core.context.tag.AbstractTag;
|
||||
import org.apache.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
public class Constants {
|
||||
|
||||
public static final AbstractTag<String> SPAN_TAG_KEY_LENGTH = Tags.ofKey("length");
|
||||
|
||||
public static final AbstractTag<String> SPAN_TAG_KEY_OBJECT = Tags.ofKey("object");
|
||||
}
|
||||
|
|
@ -19,12 +19,12 @@
|
|||
package org.apache.skywalking.apm.plugin.gson;
|
||||
|
||||
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.network.trace.component.ComponentsDefine;
|
||||
import org.apache.skywalking.apm.plugin.gson.comm.Constants;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ public class GsonFromJsonInterceptor implements InstanceMethodsAroundInterceptor
|
|||
AbstractSpan span = ContextManager.createLocalSpan("Gson/FromJson");
|
||||
span.setComponent(ComponentsDefine.GSON);
|
||||
int length = allArguments[0].toString().length();
|
||||
span.tag(Tags.ofKey("length"), Integer.toString(length));
|
||||
span.tag(Constants.LENGTH_TAG, Integer.toString(length));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@
|
|||
package org.apache.skywalking.apm.plugin.gson;
|
||||
|
||||
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.network.trace.component.ComponentsDefine;
|
||||
import org.apache.skywalking.apm.plugin.gson.comm.Constants;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ public class GsonToJsonInterceptor implements InstanceMethodsAroundInterceptor {
|
|||
AbstractSpan span = ContextManager.createLocalSpan("Gson/ToJson");
|
||||
span.setComponent(ComponentsDefine.GSON);
|
||||
int length = allArguments[0].toString().length();
|
||||
span.tag(Tags.ofKey("length"), Integer.toString(length));
|
||||
span.tag(Constants.LENGTH_TAG, Integer.toString(length));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* 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.gson.comm;
|
||||
|
||||
import org.apache.skywalking.apm.agent.core.context.tag.AbstractTag;
|
||||
import org.apache.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
public class Constants {
|
||||
|
||||
public static final AbstractTag<String> LENGTH_TAG = Tags.ofKey("length");
|
||||
|
||||
}
|
||||
|
|
@ -19,12 +19,12 @@
|
|||
package org.apache.skywalking.apm.plugin.jackson;
|
||||
|
||||
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.network.trace.component.ComponentsDefine;
|
||||
import org.apache.skywalking.apm.plugin.jackson.comm.Constants;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
|
|
@ -32,7 +32,6 @@ import java.lang.reflect.Method;
|
|||
public class ReadValueInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
|
||||
public static final String OPERATION_NAME_JACKSON = "Jackson/";
|
||||
public static final String SPAN_TAG_KEY_LENGTH = "length";
|
||||
|
||||
@Override
|
||||
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments,
|
||||
|
|
@ -43,11 +42,11 @@ public class ReadValueInterceptor implements InstanceMethodsAroundInterceptor {
|
|||
span.setComponent(ComponentsDefine.JACKSON);
|
||||
|
||||
if (allArguments[0] instanceof String) {
|
||||
span.tag(Tags.ofKey(SPAN_TAG_KEY_LENGTH), Integer.toString(((String) allArguments[0]).length()));
|
||||
span.tag(Constants.SPAN_TAG_KEY_LENGTH, Integer.toString(((String) allArguments[0]).length()));
|
||||
} else if (allArguments[0] instanceof byte[]) {
|
||||
span.tag(Tags.ofKey(SPAN_TAG_KEY_LENGTH), Integer.toString(((byte[]) allArguments[0]).length));
|
||||
span.tag(Constants.SPAN_TAG_KEY_LENGTH, Integer.toString(((byte[]) allArguments[0]).length));
|
||||
} else if (allArguments[0] instanceof File) {
|
||||
span.tag(Tags.ofKey(SPAN_TAG_KEY_LENGTH), Long.toString(((File) allArguments[0]).length()));
|
||||
span.tag(Constants.SPAN_TAG_KEY_LENGTH, Long.toString(((File) allArguments[0]).length()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,19 +19,18 @@
|
|||
package org.apache.skywalking.apm.plugin.jackson;
|
||||
|
||||
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.network.trace.component.ComponentsDefine;
|
||||
import org.apache.skywalking.apm.plugin.jackson.comm.Constants;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class WriteValueAsBytesInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
|
||||
public static final String OPERATION_NAME_JACKSON = "Jackson/";
|
||||
public static final String SPAN_TAG_KEY_LENGTH = "length";
|
||||
|
||||
@Override
|
||||
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments,
|
||||
|
|
@ -50,7 +49,7 @@ public class WriteValueAsBytesInterceptor implements InstanceMethodsAroundInterc
|
|||
return ret;
|
||||
}
|
||||
if (ret instanceof byte[]) {
|
||||
ContextManager.activeSpan().tag(Tags.ofKey(SPAN_TAG_KEY_LENGTH), Integer.toString(((byte[]) ret).length));
|
||||
ContextManager.activeSpan().tag(Constants.SPAN_TAG_KEY_LENGTH, Integer.toString(((byte[]) ret).length));
|
||||
}
|
||||
ContextManager.stopSpan();
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -19,19 +19,18 @@
|
|||
package org.apache.skywalking.apm.plugin.jackson;
|
||||
|
||||
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.network.trace.component.ComponentsDefine;
|
||||
import org.apache.skywalking.apm.plugin.jackson.comm.Constants;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class WriteValueAsStringInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
|
||||
public static final String OPERATION_NAME_JACKSON = "Jackson/";
|
||||
public static final String SPAN_TAG_KEY_LENGTH = "length";
|
||||
|
||||
@Override
|
||||
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments,
|
||||
|
|
@ -50,7 +49,7 @@ public class WriteValueAsStringInterceptor implements InstanceMethodsAroundInter
|
|||
return ret;
|
||||
}
|
||||
if (ret instanceof String) {
|
||||
ContextManager.activeSpan().tag(Tags.ofKey(SPAN_TAG_KEY_LENGTH), Integer.toString(((String) ret).length()));
|
||||
ContextManager.activeSpan().tag(Constants.SPAN_TAG_KEY_LENGTH, Integer.toString(((String) ret).length()));
|
||||
}
|
||||
ContextManager.stopSpan();
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* 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.jackson.comm;
|
||||
|
||||
import org.apache.skywalking.apm.agent.core.context.tag.AbstractTag;
|
||||
import org.apache.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
public class Constants {
|
||||
|
||||
public static final AbstractTag<String> SPAN_TAG_KEY_LENGTH = Tags.ofKey("length");
|
||||
}
|
||||
|
|
@ -30,7 +30,6 @@ import com.alibaba.nacos.api.naming.remote.request.ServiceQueryRequest;
|
|||
import com.alibaba.nacos.api.naming.remote.request.SubscribeServiceRequest;
|
||||
import com.alibaba.nacos.api.remote.request.Request;
|
||||
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.network.trace.component.ComponentsDefine;
|
||||
|
|
@ -49,74 +48,74 @@ public class NacosRequestOpt {
|
|||
OPTS.put(InstanceRequest.class, (request, peer) -> {
|
||||
AbstractSpan span = getNacosExitSpan(peer);
|
||||
span.setOperationName(span.getOperationName() + ((InstanceRequest) request).getType());
|
||||
span.tag(Tags.ofKey(NacosConstants.NAMESPACE), ((InstanceRequest) request).getNamespace());
|
||||
span.tag(Tags.ofKey(NacosConstants.GROUP), ((InstanceRequest) request).getGroupName());
|
||||
span.tag(Tags.ofKey(NacosConstants.SERVICE_NAME), ((InstanceRequest) request).getServiceName());
|
||||
span.tag(NacosConstants.NAME_SPACE_TAG, ((InstanceRequest) request).getNamespace());
|
||||
span.tag(NacosConstants.GROUP_TAG, ((InstanceRequest) request).getGroupName());
|
||||
span.tag(NacosConstants.SERVICE_NAME_TAG, ((InstanceRequest) request).getServiceName());
|
||||
});
|
||||
|
||||
OPTS.put(ServiceQueryRequest.class, (request, peer) -> {
|
||||
AbstractSpan span = getNacosExitSpan(peer);
|
||||
span.setOperationName(span.getOperationName() + NacosConstants.QUERY_SERVICE);
|
||||
span.tag(Tags.ofKey(NacosConstants.NAMESPACE), ((ServiceQueryRequest) request).getNamespace());
|
||||
span.tag(Tags.ofKey(NacosConstants.GROUP), ((ServiceQueryRequest) request).getGroupName());
|
||||
span.tag(Tags.ofKey(NacosConstants.SERVICE_NAME), ((ServiceQueryRequest) request).getServiceName());
|
||||
span.tag(NacosConstants.NAME_SPACE_TAG, ((ServiceQueryRequest) request).getNamespace());
|
||||
span.tag(NacosConstants.GROUP_TAG, ((ServiceQueryRequest) request).getGroupName());
|
||||
span.tag(NacosConstants.SERVICE_NAME_TAG, ((ServiceQueryRequest) request).getServiceName());
|
||||
});
|
||||
|
||||
OPTS.put(SubscribeServiceRequest.class, (request, peer) -> {
|
||||
AbstractSpan span = getNacosExitSpan(peer);
|
||||
span.setOperationName(span.getOperationName() + (((SubscribeServiceRequest) request).isSubscribe() ?
|
||||
NacosConstants.SUBSCRIBE_SERVICE : NacosConstants.UNSUBSCRIBE_SERVICE));
|
||||
span.tag(Tags.ofKey(NacosConstants.NAMESPACE), ((SubscribeServiceRequest) request).getNamespace());
|
||||
span.tag(Tags.ofKey(NacosConstants.GROUP), ((SubscribeServiceRequest) request).getGroupName());
|
||||
span.tag(Tags.ofKey(NacosConstants.SERVICE_NAME), ((SubscribeServiceRequest) request).getServiceName());
|
||||
span.tag(NacosConstants.NAME_SPACE_TAG, ((SubscribeServiceRequest) request).getNamespace());
|
||||
span.tag(NacosConstants.GROUP_TAG, ((SubscribeServiceRequest) request).getGroupName());
|
||||
span.tag(NacosConstants.SERVICE_NAME_TAG, ((SubscribeServiceRequest) request).getServiceName());
|
||||
});
|
||||
|
||||
OPTS.put(ServiceListRequest.class, (request, peer) -> {
|
||||
AbstractSpan span = getNacosExitSpan(peer);
|
||||
span.setOperationName(span.getOperationName() + NacosConstants.GET_SERVICE_LIST);
|
||||
span.tag(Tags.ofKey(NacosConstants.NAMESPACE), ((ServiceListRequest) request).getNamespace());
|
||||
span.tag(Tags.ofKey(NacosConstants.GROUP), ((ServiceListRequest) request).getGroupName());
|
||||
span.tag(Tags.ofKey(NacosConstants.SERVICE_NAME), ((ServiceListRequest) request).getServiceName());
|
||||
span.tag(NacosConstants.NAME_SPACE_TAG, ((ServiceListRequest) request).getNamespace());
|
||||
span.tag(NacosConstants.GROUP_TAG, ((ServiceListRequest) request).getGroupName());
|
||||
span.tag(NacosConstants.SERVICE_NAME_TAG, ((ServiceListRequest) request).getServiceName());
|
||||
});
|
||||
|
||||
OPTS.put(ConfigQueryRequest.class, (request, peer) -> {
|
||||
AbstractSpan span = getNacosExitSpan(peer);
|
||||
span.setOperationName(span.getOperationName() + NacosConstants.QUERY_CONFIG);
|
||||
span.tag(Tags.ofKey(NacosConstants.DATA_ID), ((ConfigQueryRequest) request).getDataId());
|
||||
span.tag(Tags.ofKey(NacosConstants.GROUP), ((ConfigQueryRequest) request).getGroup());
|
||||
span.tag(Tags.ofKey(NacosConstants.TENANT), ((ConfigQueryRequest) request).getTenant());
|
||||
span.tag(NacosConstants.DATA_ID_TAG, ((ConfigQueryRequest) request).getDataId());
|
||||
span.tag(NacosConstants.GROUP_TAG, ((ConfigQueryRequest) request).getGroup());
|
||||
span.tag(NacosConstants.TENANT_TAG, ((ConfigQueryRequest) request).getTenant());
|
||||
});
|
||||
|
||||
OPTS.put(ConfigPublishRequest.class, (request, peer) -> {
|
||||
AbstractSpan span = getNacosExitSpan(peer);
|
||||
span.setOperationName(span.getOperationName() + NacosConstants.PUBLISH_CONFIG);
|
||||
span.tag(Tags.ofKey(NacosConstants.DATA_ID), ((ConfigPublishRequest) request).getDataId());
|
||||
span.tag(Tags.ofKey(NacosConstants.GROUP), ((ConfigPublishRequest) request).getGroup());
|
||||
span.tag(Tags.ofKey(NacosConstants.TENANT), ((ConfigPublishRequest) request).getTenant());
|
||||
span.tag(NacosConstants.DATA_ID_TAG, ((ConfigPublishRequest) request).getDataId());
|
||||
span.tag(NacosConstants.GROUP_TAG, ((ConfigPublishRequest) request).getGroup());
|
||||
span.tag(NacosConstants.TENANT_TAG, ((ConfigPublishRequest) request).getTenant());
|
||||
});
|
||||
|
||||
OPTS.put(ConfigRemoveRequest.class, (request, peer) -> {
|
||||
AbstractSpan span = getNacosExitSpan(peer);
|
||||
span.setOperationName(span.getOperationName() + NacosConstants.REMOVE_CONFIG);
|
||||
span.tag(Tags.ofKey(NacosConstants.DATA_ID), ((ConfigRemoveRequest) request).getDataId());
|
||||
span.tag(Tags.ofKey(NacosConstants.GROUP), ((ConfigRemoveRequest) request).getGroup());
|
||||
span.tag(Tags.ofKey(NacosConstants.TENANT), ((ConfigRemoveRequest) request).getTenant());
|
||||
span.tag(NacosConstants.DATA_ID_TAG, ((ConfigRemoveRequest) request).getDataId());
|
||||
span.tag(NacosConstants.GROUP_TAG, ((ConfigRemoveRequest) request).getGroup());
|
||||
span.tag(NacosConstants.TENANT_TAG, ((ConfigRemoveRequest) request).getTenant());
|
||||
});
|
||||
|
||||
OPTS.put(NotifySubscriberRequest.class, (request, peer) -> {
|
||||
AbstractSpan span = getNacosEntrySpan(peer);
|
||||
span.setOperationName(span.getOperationName() + NacosConstants.NOTIFY_SUBSCRIBE_CHANGE);
|
||||
ServiceInfo serviceInfo = ((NotifySubscriberRequest) request).getServiceInfo();
|
||||
span.tag(Tags.ofKey(NacosConstants.GROUP), serviceInfo.getGroupName());
|
||||
span.tag(Tags.ofKey(NacosConstants.SERVICE_NAME), serviceInfo.getName());
|
||||
span.tag(NacosConstants.GROUP_TAG, serviceInfo.getGroupName());
|
||||
span.tag(NacosConstants.SERVICE_NAME_TAG, serviceInfo.getName());
|
||||
});
|
||||
|
||||
OPTS.put(ConfigChangeNotifyRequest.class, (request, peer) -> {
|
||||
AbstractSpan span = getNacosEntrySpan(peer);
|
||||
span.setOperationName(span.getOperationName() + NacosConstants.NOTIFY_CONFIG_CHANGE);
|
||||
span.tag(Tags.ofKey(NacosConstants.DATA_ID), ((ConfigChangeNotifyRequest) request).getDataId());
|
||||
span.tag(Tags.ofKey(NacosConstants.GROUP), ((ConfigChangeNotifyRequest) request).getGroup());
|
||||
span.tag(Tags.ofKey(NacosConstants.TENANT), ((ConfigChangeNotifyRequest) request).getTenant());
|
||||
span.tag(NacosConstants.DATA_ID_TAG, ((ConfigChangeNotifyRequest) request).getDataId());
|
||||
span.tag(NacosConstants.GROUP_TAG, ((ConfigChangeNotifyRequest) request).getGroup());
|
||||
span.tag(NacosConstants.TENANT_TAG, ((ConfigChangeNotifyRequest) request).getTenant());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,9 @@
|
|||
|
||||
package org.apache.skywalking.apm.plugin.nacos.v2.constant;
|
||||
|
||||
import org.apache.skywalking.apm.agent.core.context.tag.AbstractTag;
|
||||
import org.apache.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
public class NacosConstants {
|
||||
|
||||
public static final String NACOS_PREFIX = "Nacos/";
|
||||
|
|
@ -40,13 +43,13 @@ public class NacosConstants {
|
|||
|
||||
public static final String NOTIFY_CONFIG_CHANGE = "notifyConfigChange";
|
||||
|
||||
public static final String NAMESPACE = "namespace";
|
||||
public static final AbstractTag<String> NAME_SPACE_TAG = Tags.ofKey("namespace");
|
||||
|
||||
public static final String GROUP = "group";
|
||||
public static final AbstractTag<String> GROUP_TAG = Tags.ofKey("group");
|
||||
|
||||
public static final String SERVICE_NAME = "serviceName";
|
||||
public static final AbstractTag<String> SERVICE_NAME_TAG = Tags.ofKey("serviceName");
|
||||
|
||||
public static final String DATA_ID = "dataId";
|
||||
public static final AbstractTag<String> DATA_ID_TAG = Tags.ofKey("dataId");
|
||||
|
||||
public static final String TENANT = "tenant";
|
||||
public static final AbstractTag<String> TENANT_TAG = Tags.ofKey("tenant");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue