def test_extract_memcached_connection_metadata(self): # create the TracedCache instance for a Flask app tracer = Tracer() Cache = get_traced_cache(tracer, service=self.SERVICE) app = Flask(__name__) config = { "CACHE_TYPE": "memcached", "CACHE_MEMCACHED_SERVERS": ["127.0.0.1:{}".format(MEMCACHED_CONFIG['port'])], } traced_cache = Cache(app, config=config) # extract client data meta = _extract_conn_tags(traced_cache.cache._client) expected_meta = {'out.host': '127.0.0.1', 'out.port': MEMCACHED_CONFIG['port']} assert meta == expected_meta
def test_extract_redis_connection_metadata(self): # create the TracedCache instance for a Flask app tracer = Tracer() Cache = get_traced_cache(tracer, service=self.SERVICE) app = Flask(__name__) config = { "CACHE_TYPE": "redis", "CACHE_REDIS_PORT": REDIS_CONFIG['port'], } traced_cache = Cache(app, config=config) # extract client data meta = _extract_conn_tags(traced_cache.cache._client) expected_meta = {'out.host': 'localhost', 'out.port': REDIS_CONFIG['port'], 'out.redis_db': 0} assert meta == expected_meta
def test_extract_redis_connection_metadata(self): # create the TracedCache instance for a Flask app tracer = Tracer() Cache = get_traced_cache(tracer, service=self.SERVICE) app = Flask(__name__) config = { "CACHE_TYPE": "redis", "CACHE_REDIS_PORT": REDIS_CONFIG['port'], } traced_cache = Cache(app, config=config) # extract client data meta = _extract_conn_tags(traced_cache.cache._client) expected_meta = {'out.host': 'localhost', 'out.port': REDIS_CONFIG['port'], 'out.redis_db': 0} eq_(meta, expected_meta)
def test_extract_memcached_connection_metadata(self): # create the TracedCache instance for a Flask app tracer = Tracer() Cache = get_traced_cache(tracer, service=self.SERVICE) app = Flask(__name__) config = { "CACHE_TYPE": "memcached", "CACHE_MEMCACHED_SERVERS": ["127.0.0.1:{}".format(MEMCACHED_CONFIG['port'])], } traced_cache = Cache(app, config=config) # extract client data meta = _extract_conn_tags(traced_cache.cache._client) expected_meta = {'out.host': '127.0.0.1', 'out.port': MEMCACHED_CONFIG['port']} eq_(meta, expected_meta)
def test_extract_memcached_multiple_connection_metadata(self): # create the TracedCache instance for a Flask app tracer = Tracer() Cache = get_traced_cache(tracer, service=self.SERVICE) app = Flask(__name__) config = { "CACHE_TYPE": "memcached", "CACHE_MEMCACHED_SERVERS": [ "127.0.0.1:{}".format(MEMCACHED_CONFIG["port"]), "localhost:{}".format(MEMCACHED_CONFIG["port"]), ], } traced_cache = Cache(app, config=config) # extract client data meta = _extract_conn_tags(_extract_client(traced_cache.cache)) expected_meta = { "out.host": "127.0.0.1", "out.port": MEMCACHED_CONFIG["port"], } assert meta == expected_meta