From a16f6f657e3ca45aea1fc85566dafeeb3cf1a7b0 Mon Sep 17 00:00:00 2001 From: zhangxin Date: Wed, 26 Apr 2017 15:26:47 +0800 Subject: [PATCH] refactory method name --- .../span/interceptor/SpanSetTagInterceptor.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanSetTagInterceptor.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanSetTagInterceptor.java index e9cf6e2e4..a2c2a3881 100644 --- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanSetTagInterceptor.java +++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanSetTagInterceptor.java @@ -26,7 +26,7 @@ public class SpanSetTagInterceptor implements InstanceMethodsAroundInterceptor { @Override public void beforeMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, MethodInterceptResult result) { - String key = fetchTagKeyFromArguments(interceptorContext.allArguments()); + String key = adaptTag((String)interceptorContext.allArguments()[0]); Object value = interceptorContext.allArguments()[1]; if (value instanceof String) ContextManager.activeSpan().setTag(key, (String)value); @@ -39,14 +39,14 @@ public class SpanSetTagInterceptor implements InstanceMethodsAroundInterceptor { } /** - * Fetch tag key of {@link Span#setTag}. + * Adapt {@link Tags} of open tracing. * * @return tag key */ - private String fetchTagKeyFromArguments(Object[] arguments) { - String key = (String)arguments[0]; + private String adaptTag(String tagKey) { + String key = tagKey; - if (isPeerHostPrefix(key)) { + if (isPeerTag(key)) { key = KEY_OF_PEER_HOST_TAG; } @@ -54,13 +54,15 @@ public class SpanSetTagInterceptor implements InstanceMethodsAroundInterceptor { } /** + * Check current tag is peer tag. + * * Skywalking put the tag value of {@link Tags#PEER_HOSTNAME}, {@link Tags#PEER_HOST_IPV4} and * {@link Tags#PEER_HOST_IPV6} into {@link com.a.eye.skywalking.trace.tag.Tags#PEER_HOST} which * facilitate analysis. * * @param key tag key */ - private boolean isPeerHostPrefix(String key) { + private boolean isPeerTag(String key) { return Tags.PEER_HOST_IPV4.equals(key) || Tags.PEER_HOST_IPV6.equals(key) || Tags.PEER_HOSTNAME.equals(key); }