io.opentracing.contrib.redis.common.TracingConfiguration Java Examples

The following examples show how to use io.opentracing.contrib.redis.common.TracingConfiguration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TracingLettuce51Test.java    From java-redis-client with Apache License 2.0 6 votes vote down vote up
@Test
public void sync() {
  RedisClient client = RedisClient.create("redis://localhost");

  StatefulRedisConnection<String, String> connection =
      new TracingStatefulRedisConnection<>(client.connect(),
          new TracingConfiguration.Builder(mockTracer).build());
  RedisCommands<String, String> commands = connection.sync();

  assertEquals("OK", commands.set("key", "value"));
  assertEquals("value", commands.get("key"));

  connection.close();

  client.shutdown();

  List<MockSpan> spans = mockTracer.finishedSpans();
  assertEquals(2, spans.size());
}
 
Example #2
Source File: TracingJedisPool.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
public TracingJedisPool(final GenericObjectPoolConfig poolConfig, final String host,
    final int port,
    final int timeout, final String password, final boolean ssl,
    final SSLSocketFactory sslSocketFactory, final SSLParameters sslParameters,
    final HostnameVerifier hostnameVerifier, TracingConfiguration tracingConfiguration) {
  super(poolConfig, host, port, timeout, password, ssl, sslSocketFactory, sslParameters,
      hostnameVerifier);
  this.tracingConfiguration = tracingConfiguration;
}
 
Example #3
Source File: TracingJedisPoolTest.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Test
public void testPoolReturnsTracedJedis() {
  JedisPool pool = new TracingJedisPool(new TracingConfiguration.Builder(mockTracer).build());

  Jedis jedis = pool.getResource();
  assertEquals("OK", jedis.set("key", "value"));
  assertEquals("value", jedis.get("key"));

  jedis.close();

  List<MockSpan> spans = mockTracer.finishedSpans();
  assertEquals(2, spans.size());
}
 
Example #4
Source File: TracingJedisPool.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
public TracingJedisPool(final GenericObjectPoolConfig poolConfig, final String host,
    final int port, final boolean ssl,
    final SSLSocketFactory sslSocketFactory, final SSLParameters sslParameters,
    final HostnameVerifier hostnameVerifier, TracingConfiguration tracingConfiguration) {
  super(poolConfig, host, port, ssl, sslSocketFactory, sslParameters, hostnameVerifier);
  this.tracingConfiguration = tracingConfiguration;
}
 
Example #5
Source File: TracingJedisPool.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
public TracingJedisPool(final GenericObjectPoolConfig poolConfig, final String host,
    final int port,
    final int timeout, final String password, final boolean ssl,
    TracingConfiguration tracingConfiguration) {
  super(poolConfig, host, port, timeout, password, ssl);
  this.tracingConfiguration = tracingConfiguration;
}
 
Example #6
Source File: TracingJedisSentinelPool.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
public TracingJedisSentinelPool(TracingConfiguration tracingConfiguration, String masterName,
    Set<String> sentinels,
    final GenericObjectPoolConfig poolConfig, final int connectionTimeout, final int soTimeout,
    final String password, final int database, final String clientName) {
  super(masterName, sentinels, poolConfig, connectionTimeout, soTimeout, password, database,
      clientName);
  this.tracingConfiguration = tracingConfiguration;
}
 
Example #7
Source File: TracingLettuce52Test.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Test
public void async_continue_span() throws Exception {
  final MockSpan parent = mockTracer.buildSpan("test").start();
  try (Scope ignored = mockTracer.activateSpan(parent)) {
    Span activeSpan = mockTracer.activeSpan();

    RedisClient client = RedisClient.create("redis://localhost");

    StatefulRedisConnection<String, String> connection =
        new TracingStatefulRedisConnection<>(client.connect(),
            new TracingConfiguration.Builder(mockTracer).build());

    RedisAsyncCommands<String, String> commands = connection.async();

    assertEquals("OK",
        commands.set("key2", "value2").toCompletableFuture().thenApply(s -> {
          assertSame(activeSpan, mockTracer.activeSpan());
          return s;
        }).get(15, TimeUnit.SECONDS));

    connection.close();

    client.shutdown();
  }
  parent.finish();
  List<MockSpan> spans = mockTracer.finishedSpans();
  assertEquals(2, spans.size());
}
 
Example #8
Source File: TracingRedisAsyncCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
/**
 * @param commands redis async commands
 * @param tracingConfiguration tracing configuration
 */
public TracingRedisAsyncCommands(RedisAsyncCommands<K, V> commands,
    TracingConfiguration tracingConfiguration) {
  this.commands = commands;
  this.tracingConfiguration = tracingConfiguration;
  this.helper = new TracingHelper(tracingConfiguration);
}
 
Example #9
Source File: TracingJedisPool.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
public TracingJedisPool(final GenericObjectPoolConfig poolConfig, final String host,
    final int port, final int timeout,
    final String password, final int database, final boolean ssl,
    final SSLSocketFactory sslSocketFactory, final SSLParameters sslParameters,
    final HostnameVerifier hostnameVerifier, TracingConfiguration tracingConfiguration) {
  super(poolConfig, host, port, timeout, password, database, ssl, sslSocketFactory, sslParameters,
      hostnameVerifier);
  this.tracingConfiguration = tracingConfiguration;
}
 
Example #10
Source File: TracingJedisPoolTest.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldReturnResourceToThePoolAndStayConnected() {
  //given
  TracingJedisPool pool = new TracingJedisPool(
      new TracingConfiguration.Builder(mockTracer).build());
  Jedis resource = pool.getResource();
  assertTrue(resource.isConnected());

  //when
  pool.returnResource(resource);

  //then
  assertTrue(resource.isConnected());
}
 
Example #11
Source File: TracingLettuce50Test.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Test
public void async_continue_span() throws Exception {
  final MockSpan parent = mockTracer.buildSpan("test").start();
  try (Scope ignored = mockTracer.activateSpan(parent)) {
    Span activeSpan = mockTracer.activeSpan();

    RedisClient client = RedisClient.create("redis://localhost");

    StatefulRedisConnection<String, String> connection =
        new TracingStatefulRedisConnection<>(client.connect(),
            new TracingConfiguration.Builder(mockTracer).build());

    RedisAsyncCommands<String, String> commands = connection.async();

    assertEquals("OK",
        commands.set("key2", "value2").toCompletableFuture().thenApply(s -> {
          assertSame(activeSpan, mockTracer.activeSpan());
          return s;
        }).get(15, TimeUnit.SECONDS));

    connection.close();

    client.shutdown();
  }
  parent.finish();
  List<MockSpan> spans = mockTracer.finishedSpans();
  assertEquals(2, spans.size());
}
 
Example #12
Source File: RedisConnectionFactoryBeanPostProcessor.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
  if (bean instanceof RedisConnectionFactory) {
    bean = new TracingRedisConnectionFactory((RedisConnectionFactory) bean,
        new TracingConfiguration.Builder(tracer).traceWithActiveSpanOnly(false).build());
  }
  return bean;
}
 
Example #13
Source File: TracingRedisAdvancedClusterCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
public TracingRedisAdvancedClusterCommands(RedisAdvancedClusterCommands<K, V> commands,
    TracingConfiguration tracingConfiguration) {

  this.commands = commands;
  this.helper = new TracingHelper(tracingConfiguration);
  this.tracingConfiguration = tracingConfiguration;
}
 
Example #14
Source File: TracingJedisSentinelPool.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
public TracingJedisSentinelPool(TracingConfiguration tracingConfiguration, String masterName,
    Set<String> sentinels,
    final GenericObjectPoolConfig poolConfig, int timeout, final String password,
    final int database, final String clientName) {
  super(masterName, sentinels, poolConfig, timeout, timeout, password, database, clientName);
  this.tracingConfiguration = tracingConfiguration;
}
 
Example #15
Source File: TracingJedisPool.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
public TracingJedisPool(final GenericObjectPoolConfig poolConfig, final String host,
    final int port, final int timeout,
    final String password, final int database, final String clientName, final boolean ssl,
    TracingConfiguration tracingConfiguration) {
  super(poolConfig, host, port, timeout, password, database, clientName, ssl);
  this.tracingConfiguration = tracingConfiguration;
}
 
Example #16
Source File: TracingRedisAsyncCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
/**
 * @param commands redis async commands
 * @param tracingConfiguration tracing configuration
 */
public TracingRedisAsyncCommands(RedisAsyncCommands<K, V> commands,
    TracingConfiguration tracingConfiguration) {
  this.commands = commands;
  this.tracingConfiguration = tracingConfiguration;
  this.helper = new TracingHelper(tracingConfiguration);
}
 
Example #17
Source File: TracingJedisWrapper.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
public TracingJedisWrapper(final String host, final int port, final int connectionTimeout,
    final int soTimeout,
    final boolean ssl, final SSLSocketFactory sslSocketFactory, final SSLParameters sslParameters,
    final HostnameVerifier hostnameVerifier, TracingConfiguration tracingConfiguration) {
  this.wrapped = new TracingJedisWrapper(
      new Jedis(host, port, connectionTimeout, soTimeout, ssl, sslSocketFactory, sslParameters,
          hostnameVerifier), tracingConfiguration);
  this.helper = new TracingHelper(tracingConfiguration);
}
 
Example #18
Source File: TracingJedisPool.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
public TracingJedisPool(final GenericObjectPoolConfig poolConfig, final URI uri,
    final int timeout,
    final SSLSocketFactory sslSocketFactory, final SSLParameters sslParameters,
    final HostnameVerifier hostnameVerifier, TracingConfiguration tracingConfiguration) {
  super(poolConfig, uri, timeout, sslSocketFactory, sslParameters, hostnameVerifier);
  this.tracingConfiguration = tracingConfiguration;
}
 
Example #19
Source File: TracingJedisPool.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
public TracingJedisPool(final GenericObjectPoolConfig poolConfig, final String host,
    final int port, final int timeout,
    final boolean ssl, final SSLSocketFactory sslSocketFactory, final SSLParameters sslParameters,
    final HostnameVerifier hostnameVerifier, TracingConfiguration tracingConfiguration) {
  super(poolConfig, host, port, timeout, ssl, sslSocketFactory, sslParameters, hostnameVerifier);
  this.tracingConfiguration = tracingConfiguration;
}
 
Example #20
Source File: MockConfiguration.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Bean
public RedisConnectionFactory redisConnectionFactory() {
  RedisConnectionFactory factory = mock(RedisConnectionFactory.class);
  when(factory.getConnection())
      .thenReturn(new TracingRedisConnection(mockRedisConnection(),
          new TracingConfiguration.Builder(mockTracer()).traceWithActiveSpanOnly(false).build()));
  when(factory.getClusterConnection()).thenReturn(
      new TracingRedisClusterConnection(mockRedisClusterConnection(),
          new TracingConfiguration.Builder(mockTracer()).traceWithActiveSpanOnly(false).build()));
  return factory;
}
 
Example #21
Source File: TracingJedisPool.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
public TracingJedisPool(final GenericObjectPoolConfig poolConfig, final String host,
    final int port,
    final int timeout, final String password,
    TracingConfiguration tracingConfiguration) {
  super(poolConfig, host, port, timeout, password);
  this.tracingConfiguration = tracingConfiguration;
}
 
Example #22
Source File: TracingJedisPool.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
public TracingJedisPool(final GenericObjectPoolConfig poolConfig, final String host,
    final int port,
    final int connectionTimeout, final int soTimeout, final String password, final int database,
    final String clientName, final boolean ssl, final SSLSocketFactory sslSocketFactory,
    final SSLParameters sslParameters, final HostnameVerifier hostnameVerifier,
    TracingConfiguration tracingConfiguration) {

  super(poolConfig, host, port, connectionTimeout, soTimeout, password, database, clientName, ssl,
      sslSocketFactory, sslParameters, hostnameVerifier);
  this.tracingConfiguration = tracingConfiguration;
}
 
Example #23
Source File: SpringDataRedisTestConfiguration.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Bean
public RedisConnectionFactory redisConnectionFactory() {
  LettuceConnectionFactory lettuceConnectionFactory = new LettuceConnectionFactory();
  lettuceConnectionFactory.afterPropertiesSet();
  return new TracingRedisConnectionFactory(lettuceConnectionFactory,
      new TracingConfiguration.Builder(tracer()).build());
}
 
Example #24
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
public TracingJedisCluster(Set<HostAndPort> jedisClusterNode, int connectionTimeout,
    int soTimeout,
    int maxAttempts, String password, GenericObjectPoolConfig poolConfig,
    TracingConfiguration tracingConfiguration) {
  super(jedisClusterNode, connectionTimeout, soTimeout, maxAttempts, password, poolConfig);
  this.helper = new TracingHelper(tracingConfiguration);
}
 
Example #25
Source File: TracingRedissonTest.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Test
public void test_config_span_name() throws Exception {
  Config config = new Config();
  config.useSingleServer().setAddress("redis://127.0.0.1:6379");

  RedissonClient customClient = new TracingRedissonClient(Redisson.create(config),
      new TracingConfiguration.Builder(tracer)
          .traceWithActiveSpanOnly(true)
          .withSpanNameProvider(operation -> "Redis." + operation)
          .build());

  final MockSpan parent = tracer.buildSpan("test").start();
  try (Scope ignore = tracer.activateSpan(parent)) {
    RMap<String, String> map = customClient.getMap("map_config_span_name");
    map.getAsync("key").get(15, TimeUnit.SECONDS);
  }
  parent.finish();

  await().atMost(15, TimeUnit.SECONDS).until(reportedSpansSize(), equalTo(2));

  List<MockSpan> spans = tracer.finishedSpans();
  assertEquals(2, spans.size());
  MockSpan redisSpan = spans.get(0);
  assertEquals("Redis.getAsync", redisSpan.operationName());

  assertNull(tracer.activeSpan());
  customClient.shutdown();
}
 
Example #26
Source File: TracingJedisSentinelPool.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
public TracingJedisSentinelPool(TracingConfiguration tracingConfiguration, String masterName,
    Set<String> sentinels,
    final GenericObjectPoolConfig poolConfig, int timeout, final String password,
    final int database, Function<String, String> customSpanName) {
  super(masterName, sentinels, poolConfig, timeout, timeout, password, database);
  this.tracingConfiguration = tracingConfiguration;
}
 
Example #27
Source File: TracingJedisPoolTest.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldReturnResourceToThePoolOnCloseAndStayConnected() {
  //given
  JedisPool pool = new TracingJedisPool(new TracingConfiguration.Builder(mockTracer).build());
  Jedis resource = pool.getResource();
  assertTrue(resource.isConnected());

  //when
  resource.close();

  //then - valid resource should not be destroyed but returned to pool & stay connected for at least {@link BaseGenericObjectPool#getMinEvictableIdleTimeMillis()}
  assertTrue(resource.isConnected());
}
 
Example #28
Source File: TracingJedisPool.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
public TracingJedisPool(final GenericObjectPoolConfig poolConfig, final String host,
    final int port, final int timeout,
    final String password, final int database, final String clientName, final boolean ssl,
    TracingConfiguration tracingConfiguration) {
  super(poolConfig, host, port, timeout, password, database, clientName, ssl);
  this.tracingConfiguration = tracingConfiguration;
}
 
Example #29
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
public TracingJedisCluster(Set<HostAndPort> jedisClusterNode, int connectionTimeout,
    int soTimeout, int maxAttempts,
    GenericObjectPoolConfig poolConfig, TracingConfiguration tracingConfiguration,
    Function<String, String> customSpanNameProvider) {
  super(jedisClusterNode, connectionTimeout, soTimeout, maxAttempts, poolConfig);
  this.helper = new TracingHelper(tracingConfiguration);
}
 
Example #30
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
public TracingJedisCluster(Set<HostAndPort> jedisClusterNode, int connectionTimeout,
    int soTimeout,
    int maxAttempts, GenericObjectPoolConfig poolConfig,
    TracingConfiguration tracingConfiguration) {
  super(jedisClusterNode, connectionTimeout, soTimeout, maxAttempts, poolConfig);
  this.helper = new TracingHelper(tracingConfiguration);
}