add test case and fix some issue
This commit is contained in:
parent
20193495b4
commit
1f876948d2
|
|
@ -22,7 +22,7 @@ public class JedisClusterConstructorWithHostAndPortArgInterceptor implements Ins
|
|||
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext) {
|
||||
StringBuilder redisConnInfo = new StringBuilder();
|
||||
HostAndPort hostAndPort = (HostAndPort) interceptorContext.allArguments()[0];
|
||||
redisConnInfo.append(hostAndPort.toString()).append(";");
|
||||
redisConnInfo.append(hostAndPort.toString());
|
||||
context.set(KEY_OF_REDIS_CONN_INFO, redisConnInfo.toString());
|
||||
context.set(KEY_OF_REDIS_HOST, hostAndPort.getHost());
|
||||
context.set(KEY_OF_REDIS_PORT, hostAndPort.getPort());
|
||||
|
|
|
|||
|
|
@ -23,6 +23,6 @@ public class JedisClusterConstructorWithListHostAndPortArgInterceptor implements
|
|||
redisConnInfo.append(hostAndPort.toString()).append(";");
|
||||
}
|
||||
context.set(JedisMethodInterceptor.KEY_OF_REDIS_CONN_INFO, redisConnInfo.toString());
|
||||
context.set(JedisMethodInterceptor.KEY_OF_REDIS_HOSTS, redisConnInfo);
|
||||
context.set(JedisMethodInterceptor.KEY_OF_REDIS_HOSTS, redisConnInfo.toString());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,11 +46,17 @@ public class JedisMethodInterceptor extends NoCocurrencyAceessObject {
|
|||
this.whenEnter(context, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Span span = ContextManager.INSTANCE.createSpan(context.get(KEY_OF_REDIS_CONN_INFO, String.class) + " " + interceptorContext.methodName());
|
||||
Span span = ContextManager.INSTANCE.createSpan(interceptorContext.methodName());
|
||||
Tags.COMPONENT.set(span, REDIS_COMPONENT);
|
||||
Tags.DB_TYPE.set(span, REDIS_COMPONENT);
|
||||
tagPeer(span, context);
|
||||
Tags.SPAN_LAYER.asDB(span);
|
||||
if (StringUtil.isEmpty(context.get(KEY_OF_REDIS_HOST, String.class))) {
|
||||
Tags.PEERS.set(span, String.valueOf(context.get(KEY_OF_REDIS_HOSTS)));
|
||||
} else {
|
||||
Tags.PEER_HOST.set(span, context.get(KEY_OF_REDIS_HOST, String.class));
|
||||
Tags.PEER_PORT.set(span, (Integer) context.get(KEY_OF_REDIS_PORT));
|
||||
}
|
||||
|
||||
if (interceptorContext.allArguments().length > 0
|
||||
&& interceptorContext.allArguments()[0] instanceof String) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
package com.a.eye.skywalking.plugin.jedis.v2;
|
||||
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.ConstructorInterceptPoint;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.enhance.ConstructorInvokeContext;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import redis.clients.jedis.HostAndPort;
|
||||
|
||||
import static com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor.KEY_OF_REDIS_CONN_INFO;
|
||||
import static com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor.KEY_OF_REDIS_HOST;
|
||||
import static com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor.KEY_OF_REDIS_PORT;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class JedisClusterConstructorWithHostAndPortArgInterceptorTest {
|
||||
|
||||
private JedisClusterConstructorWithHostAndPortArgInterceptor interceptor;
|
||||
|
||||
@Mock
|
||||
private EnhancedClassInstanceContext instanceContext;
|
||||
@Mock
|
||||
private ConstructorInvokeContext invokeContext;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
interceptor = new JedisClusterConstructorWithHostAndPortArgInterceptor();
|
||||
|
||||
when(invokeContext.allArguments()).thenReturn(new Object[]{new HostAndPort("127.0.0.1", 6379)});
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onConstruct() throws Exception {
|
||||
interceptor.onConstruct(instanceContext, invokeContext);
|
||||
|
||||
verify(instanceContext, times(1)).set(KEY_OF_REDIS_CONN_INFO, "127.0.0.1:6379");
|
||||
verify(instanceContext, times(1)).set(KEY_OF_REDIS_HOST, "127.0.0.1");
|
||||
verify(instanceContext, times(1)).set(KEY_OF_REDIS_PORT, 6379);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
package com.a.eye.skywalking.plugin.jedis.v2;
|
||||
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.enhance.ConstructorInvokeContext;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import redis.clients.jedis.HostAndPort;
|
||||
|
||||
import static com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor.KEY_OF_REDIS_CONN_INFO;
|
||||
import static com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor.KEY_OF_REDIS_HOSTS;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class JedisClusterConstructorWithListHostAndPortArgInterceptorTest {
|
||||
|
||||
private JedisClusterConstructorWithListHostAndPortArgInterceptor interceptor;
|
||||
@Mock
|
||||
private EnhancedClassInstanceContext instanceContext;
|
||||
@Mock
|
||||
private ConstructorInvokeContext invokeContext;
|
||||
|
||||
private Set<HostAndPort> hostAndPortSet;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
hostAndPortSet = new HashSet<HostAndPort>();
|
||||
interceptor = new JedisClusterConstructorWithListHostAndPortArgInterceptor();
|
||||
hostAndPortSet.add(new HostAndPort("127.0.0.1", 6379));
|
||||
hostAndPortSet.add(new HostAndPort("127.0.0.1", 16379));
|
||||
|
||||
when(invokeContext.allArguments()).thenReturn(new Object[]{hostAndPortSet});
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onConstruct() throws Exception {
|
||||
interceptor.onConstruct(instanceContext, invokeContext);
|
||||
|
||||
verify(instanceContext, times(1)).set(KEY_OF_REDIS_CONN_INFO, "127.0.0.1:6379;127.0.0.1:16379;");
|
||||
verify(instanceContext, times(1)).set(KEY_OF_REDIS_HOSTS, "127.0.0.1:6379;127.0.0.1:16379;");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
package com.a.eye.skywalking.plugin.jedis.v2;
|
||||
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.enhance.ConstructorInvokeContext;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
import redis.clients.jedis.HostAndPort;
|
||||
import redis.clients.jedis.JedisShardInfo;
|
||||
import redis.clients.util.ShardInfo;
|
||||
|
||||
import static com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor.KEY_OF_REDIS_CONN_INFO;
|
||||
import static com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor.KEY_OF_REDIS_HOST;
|
||||
import static com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor.KEY_OF_REDIS_PORT;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class JedisConstructorWithShardInfoArgInterceptorTest {
|
||||
private JedisConstructorWithShardInfoArgInterceptor interceptor;
|
||||
@Mock
|
||||
private EnhancedClassInstanceContext instanceContext;
|
||||
@Mock
|
||||
private ConstructorInvokeContext invokeContext;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
interceptor = new JedisConstructorWithShardInfoArgInterceptor();
|
||||
|
||||
when(invokeContext.allArguments()).thenReturn(new Object[]{new JedisShardInfo("127.0.0.1", 6379)});
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onConstruct() throws Exception {
|
||||
|
||||
interceptor.onConstruct(instanceContext, invokeContext);
|
||||
verify(instanceContext, times(1)).set(KEY_OF_REDIS_CONN_INFO, "127.0.0.1:6379");
|
||||
verify(instanceContext, times(1)).set(KEY_OF_REDIS_HOST, "127.0.0.1");
|
||||
verify(instanceContext, times(1)).set(KEY_OF_REDIS_PORT, 6379);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
package com.a.eye.skywalking.plugin.jedis.v2;
|
||||
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.enhance.ConstructorInvokeContext;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
import static com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor.KEY_OF_REDIS_CONN_INFO;
|
||||
import static com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor.KEY_OF_REDIS_HOST;
|
||||
import static com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor.KEY_OF_REDIS_PORT;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class JedisConstructorWithStringArgInterceptorTest {
|
||||
|
||||
private JedisConstructorWithStringArgInterceptor interceptor;
|
||||
|
||||
@Mock
|
||||
private EnhancedClassInstanceContext instanceContext;
|
||||
@Mock
|
||||
private ConstructorInvokeContext invokeContext;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
interceptor = new JedisConstructorWithStringArgInterceptor();
|
||||
when(invokeContext.allArguments()).thenReturn(new Object[]{"127.0.0.1"});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onConstruct() throws Exception {
|
||||
interceptor.onConstruct(instanceContext, invokeContext);
|
||||
|
||||
verify(instanceContext, times(1)).set(KEY_OF_REDIS_CONN_INFO, "127.0.0.1:6379");
|
||||
verify(instanceContext, times(1)).set(KEY_OF_REDIS_HOST, "127.0.0.1");
|
||||
verify(instanceContext, times(1)).set(KEY_OF_REDIS_PORT, 6379);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void onConstructWithPort(){
|
||||
when(invokeContext.allArguments()).thenReturn(new Object[]{"127.0.0.1", 16379});
|
||||
interceptor.onConstruct(instanceContext, invokeContext);
|
||||
|
||||
verify(instanceContext, times(1)).set(KEY_OF_REDIS_CONN_INFO, "127.0.0.1:16379");
|
||||
verify(instanceContext, times(1)).set(KEY_OF_REDIS_HOST, "127.0.0.1");
|
||||
verify(instanceContext, times(1)).set(KEY_OF_REDIS_PORT, 16379);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
package com.a.eye.skywalking.plugin.jedis.v2;
|
||||
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.enhance.ConstructorInvokeContext;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import static com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor.KEY_OF_REDIS_CONN_INFO;
|
||||
import static com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor.KEY_OF_REDIS_HOST;
|
||||
import static com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor.KEY_OF_REDIS_PORT;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest(URI.class)
|
||||
public class JedisConstructorWithUriArgInterceptorTest {
|
||||
|
||||
private JedisConstructorWithUriArgInterceptor interceptor;
|
||||
|
||||
@Mock
|
||||
private EnhancedClassInstanceContext instanceContext;
|
||||
@Mock
|
||||
private ConstructorInvokeContext invokeContext;
|
||||
private URI uri = URI.create("http://127.0.0.1:6379");
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
interceptor = new JedisConstructorWithUriArgInterceptor();
|
||||
|
||||
when(invokeContext.allArguments()).thenReturn(new Object[]{uri});
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void onConstruct() throws Exception {
|
||||
interceptor.onConstruct(instanceContext, invokeContext);
|
||||
|
||||
verify(instanceContext, times(1)).set(KEY_OF_REDIS_CONN_INFO, "127.0.0.1:6379");
|
||||
verify(instanceContext, times(1)).set(KEY_OF_REDIS_HOST, "127.0.0.1");
|
||||
verify(instanceContext, times(1)).set(KEY_OF_REDIS_PORT, 6379);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,152 @@
|
|||
package com.a.eye.skywalking.plugin.jedis.v2;
|
||||
|
||||
import com.a.eye.skywalking.api.context.TracerContext;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
import com.a.eye.skywalking.sniffer.mock.context.MockTracerContextListener;
|
||||
import com.a.eye.skywalking.sniffer.mock.context.SegmentAssert;
|
||||
import com.a.eye.skywalking.trace.LogData;
|
||||
import com.a.eye.skywalking.trace.Span;
|
||||
import com.a.eye.skywalking.trace.TraceSegment;
|
||||
import com.a.eye.skywalking.trace.tag.Tags;
|
||||
|
||||
import org.hamcrest.CoreMatchers;
|
||||
import org.hamcrest.MatcherAssert;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import static com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor.KEY_OF_REDIS_HOST;
|
||||
import static com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor.KEY_OF_REDIS_HOSTS;
|
||||
import static com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor.KEY_OF_REDIS_PORT;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class JedisMethodInterceptorTest {
|
||||
|
||||
private JedisMethodInterceptor interceptor;
|
||||
|
||||
private MockTracerContextListener mockTracerContextListener;
|
||||
|
||||
@Mock
|
||||
private EnhancedClassInstanceContext classInstanceContext;
|
||||
@Mock
|
||||
private InstanceMethodInvokeContext methodInvokeContext;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
interceptor = new JedisMethodInterceptor();
|
||||
mockTracerContextListener = new MockTracerContextListener();
|
||||
|
||||
TracerContext.ListenerManager.add(mockTracerContextListener);
|
||||
|
||||
when(classInstanceContext.get(KEY_OF_REDIS_HOST, String.class)).thenReturn("127.0.0.1");
|
||||
when(classInstanceContext.get(KEY_OF_REDIS_PORT)).thenReturn(6379);
|
||||
when(methodInvokeContext.methodName()).thenReturn("set");
|
||||
when(methodInvokeContext.allArguments()).thenReturn(new Object[]{"OperationKey"});
|
||||
when(classInstanceContext.isContain("__$invokeCounterKey")).thenReturn(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIntercept() {
|
||||
when(classInstanceContext.get("__$invokeCounterKey", Integer.class)).thenReturn(0);
|
||||
interceptor.beforeMethod(classInstanceContext, methodInvokeContext, null);
|
||||
when(classInstanceContext.get("__$invokeCounterKey", Integer.class)).thenReturn(1);
|
||||
interceptor.afterMethod(classInstanceContext, methodInvokeContext, null);
|
||||
|
||||
mockTracerContextListener.assertSize(1);
|
||||
mockTracerContextListener.assertTraceSegment(0, new SegmentAssert() {
|
||||
@Override
|
||||
public void call(TraceSegment traceSegment) {
|
||||
assertThat(traceSegment.getSpans().size(), is(1));
|
||||
Span span = traceSegment.getSpans().get(0);
|
||||
assertRedisSpan(span);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInterceptWithMultiHost() {
|
||||
when(classInstanceContext.get("__$invokeCounterKey", Integer.class)).thenReturn(0);
|
||||
when(classInstanceContext.get(KEY_OF_REDIS_HOST, String.class)).thenReturn(null);
|
||||
when(classInstanceContext.get(KEY_OF_REDIS_HOSTS)).thenReturn("127.0.0.1:6379;127.0.0.1:16379;");
|
||||
|
||||
interceptor.beforeMethod(classInstanceContext, methodInvokeContext, null);
|
||||
when(classInstanceContext.get("__$invokeCounterKey", Integer.class)).thenReturn(1);
|
||||
interceptor.afterMethod(classInstanceContext, methodInvokeContext, null);
|
||||
|
||||
mockTracerContextListener.assertSize(1);
|
||||
mockTracerContextListener.assertTraceSegment(0, new SegmentAssert() {
|
||||
@Override
|
||||
public void call(TraceSegment traceSegment) {
|
||||
assertThat(traceSegment.getSpans().size(), is(1));
|
||||
Span span = traceSegment.getSpans().get(0);
|
||||
assertRedisSpan(span, "127.0.0.1:6379;127.0.0.1:16379;");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInterceptWithException() {
|
||||
when(classInstanceContext.get("__$invokeCounterKey", Integer.class)).thenReturn(0);
|
||||
interceptor.beforeMethod(classInstanceContext, methodInvokeContext, null);
|
||||
interceptor.handleMethodException(new RuntimeException(), classInstanceContext, methodInvokeContext);
|
||||
when(classInstanceContext.get("__$invokeCounterKey", Integer.class)).thenReturn(1);
|
||||
interceptor.afterMethod(classInstanceContext, methodInvokeContext, null);
|
||||
|
||||
mockTracerContextListener.assertSize(1);
|
||||
mockTracerContextListener.assertTraceSegment(0, new SegmentAssert() {
|
||||
@Override
|
||||
public void call(TraceSegment traceSegment) {
|
||||
assertThat(traceSegment.getSpans().size(), is(1));
|
||||
Span span = traceSegment.getSpans().get(0);
|
||||
assertRedisSpan(span);
|
||||
assertThat(span.getLogs().size(),is(1));
|
||||
assertLogData(span.getLogs().get(0));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void assertLogData(LogData logData) {
|
||||
MatcherAssert.assertThat(logData.getFields().size(), is(4));
|
||||
MatcherAssert.assertThat(logData.getFields().get("event"), CoreMatchers.<Object>is("error"));
|
||||
assertEquals(logData.getFields().get("error.kind"), RuntimeException.class.getName());
|
||||
assertNull(logData.getFields().get("message"));
|
||||
}
|
||||
|
||||
private void assertRedisSpan(Span span) {
|
||||
assertThat(span.getOperationName(), is("set"));
|
||||
assertThat(Tags.PEER_HOST.get(span), is("127.0.0.1"));
|
||||
assertThat(Tags.PEER_PORT.get(span), is(6379));
|
||||
assertThat(Tags.COMPONENT.get(span), is("Redis"));
|
||||
assertThat(Tags.DB_STATEMENT.get(span), is("set OperationKey"));
|
||||
assertThat(Tags.DB_TYPE.get(span), is("Redis"));
|
||||
assertTrue(Tags.SPAN_LAYER.isDB(span));
|
||||
}
|
||||
|
||||
private void assertRedisSpan(Span span, String exceptedPeerHosts){
|
||||
assertThat(span.getOperationName(), is("set"));
|
||||
assertThat(Tags.PEERS.get(span), is(exceptedPeerHosts));
|
||||
assertThat(Tags.COMPONENT.get(span), is("Redis"));
|
||||
assertThat(Tags.DB_STATEMENT.get(span), is("set OperationKey"));
|
||||
assertThat(Tags.DB_TYPE.get(span), is("Redis"));
|
||||
assertTrue(Tags.SPAN_LAYER.isDB(span));
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
TracerContext.ListenerManager.remove(mockTracerContextListener);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue