Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions scripts/integration_registry/registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ integrations:
max: 0.13.1
flask-caching:
min: 1.10.1
max: 2.3.0
max: 2.5.1

- integration_name: futures
is_external_package: false
Expand Down Expand Up @@ -1102,9 +1102,9 @@ integrations:
tested_versions_by_dependency:
google-cloud-aiplatform:
min: 1.71.1
max: 1.71.1
max: 2.7.0
vertexai:
min: 1.71.1
min: 1.43.0
max: 1.71.1

- integration_name: vertica
Expand Down
48 changes: 48 additions & 0 deletions supported_versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -1798,6 +1798,18 @@
"1.10.1",
"2.3.0"
]
},
{
"testedRuntimes": {
"python": [
"3.14",
"3.15"
]
},
"supportedRange": ">=0.13",
"tested": [
"2.5.1"
]
}
]
},
Expand Down Expand Up @@ -2806,6 +2818,18 @@
"1.30.0",
"2.3.0"
]
},
{
"testedRuntimes": {
"python": [
"3.15"
]
},
"supportedRange": ">=1.10.0",
"tested": [
"1.30.0",
"2.3.0"
]
}
]
},
Expand Down Expand Up @@ -4566,6 +4590,18 @@
"tested": [
"1.71.1"
]
},
{
"testedRuntimes": {
"python": [
"3.14",
"3.15"
]
},
"supportedRange": ">=1.71.1",
"tested": [
"2.7.0"
]
}
]
},
Expand All @@ -4587,6 +4623,18 @@
"tested": [
"1.71.1"
]
},
{
"testedRuntimes": {
"python": [
"3.14",
"3.15"
]
},
"supportedRange": ">=1.71.1",
"tested": [
"1.43.0"
]
}
]
},
Expand Down
13 changes: 13 additions & 0 deletions tests/contrib/flask_cache/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
try:
import flask_caching # noqa: F401
except ImportError:
# Legacy Flask-Cache only understands the short backend names.
SIMPLE_CACHE = "simple"
REDIS_CACHE = "redis"
MEMCACHED_CACHE = "memcached"
else:
# flask-caching 2.5 removed the short aliases ("simple", "redis", ...); the full class
# paths work on every flask-caching version we test (>=1.10).
SIMPLE_CACHE = "flask_caching.backends.SimpleCache"
REDIS_CACHE = "flask_caching.backends.RedisCache"
MEMCACHED_CACHE = "flask_caching.backends.MemcachedCache"
33 changes: 18 additions & 15 deletions tests/contrib/flask_cache/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

from ..config import MEMCACHED_CONFIG
from ..config import REDIS_CONFIG
from . import MEMCACHED_CACHE
from . import REDIS_CACHE
from . import SIMPLE_CACHE


class FlaskCacheTest(TracerTestCase):
Expand All @@ -23,7 +26,7 @@ def setUp(self):
# create the TracedCache instance for a Flask app
Cache = get_traced_cache(service=self.SERVICE)
app = Flask(__name__)
self.cache = Cache(app, config={"CACHE_TYPE": "simple"})
self.cache = Cache(app, config={"CACHE_TYPE": SIMPLE_CACHE})

def test_simple_cache_get(self):
self.cache.get("á_complex_operation")
Expand All @@ -39,7 +42,7 @@ def test_simple_cache_get(self):

expected_meta = {
"flask_cache.key": "á_complex_operation",
"flask_cache.backend": "simple",
"flask_cache.backend": SIMPLE_CACHE,
"component": "flask_cache",
}

Expand Down Expand Up @@ -84,7 +87,7 @@ def test_simple_cache_set(self):

expected_meta = {
"flask_cache.key": "á_complex_operation",
"flask_cache.backend": "simple",
"flask_cache.backend": SIMPLE_CACHE,
"component": "flask_cache",
}

Expand All @@ -104,7 +107,7 @@ def test_simple_cache_add(self):

expected_meta = {
"flask_cache.key": "á_complex_number",
"flask_cache.backend": "simple",
"flask_cache.backend": SIMPLE_CACHE,
"component": "flask_cache",
}

Expand All @@ -124,7 +127,7 @@ def test_simple_cache_delete(self):

expected_meta = {
"flask_cache.key": "á_complex_operation",
"flask_cache.backend": "simple",
"flask_cache.backend": SIMPLE_CACHE,
"component": "flask_cache",
}

Expand All @@ -144,7 +147,7 @@ def test_simple_cache_delete_many(self):

expected_meta = {
"flask_cache.key": "['complex_operation', 'another_complex_op']",
"flask_cache.backend": "simple",
"flask_cache.backend": SIMPLE_CACHE,
"component": "flask_cache",
}

Expand All @@ -163,7 +166,7 @@ def test_simple_cache_clear(self):
self.assertEqual(span.error, 0)

expected_meta = {
"flask_cache.backend": "simple",
"flask_cache.backend": SIMPLE_CACHE,
"component": "flask_cache",
}

Expand All @@ -183,7 +186,7 @@ def test_simple_cache_get_many(self):

expected_meta = {
"flask_cache.key": "['first_complex_op', 'second_complex_op']",
"flask_cache.backend": "simple",
"flask_cache.backend": SIMPLE_CACHE,
"component": "flask_cache",
}

Expand Down Expand Up @@ -268,7 +271,7 @@ def test_simple_cache_set_many(self):
self.assertEqual(span.span_type, "cache")
self.assertEqual(span.error, 0)

self.assertEqual(span.get_tag("flask_cache.backend"), "simple")
self.assertEqual(span.get_tag("flask_cache.backend"), SIMPLE_CACHE)
self.assertTrue("first_complex_op" in span.get_tag("flask_cache.key"))
self.assertTrue("second_complex_op" in span.get_tag("flask_cache.key"))

Expand All @@ -277,7 +280,7 @@ def test_default_span_tags(self):
with self.cache._TracedCache__trace("flask_cache.cmd") as span:
self.assertEqual(span.service, self.SERVICE)
self.assertEqual(span.span_type, "cache")
self.assertEqual(span.get_tag(CACHE_BACKEND), "simple")
self.assertEqual(span.get_tag(CACHE_BACKEND), SIMPLE_CACHE)
self.assertTrue(net.TARGET_HOST not in span.get_tags())
self.assertTrue("network.destination.port" not in span.get_tags())

Expand All @@ -286,15 +289,15 @@ def test_default_span_tags_for_redis(self):
Cache = get_traced_cache(service=self.SERVICE)
app = Flask(__name__)
config = {
"CACHE_TYPE": "redis",
"CACHE_TYPE": REDIS_CACHE,
"CACHE_REDIS_PORT": self.TEST_REDIS_PORT,
}
cache = Cache(app, config=config)
# test tags and attributes
with cache._TracedCache__trace("flask_cache.cmd") as span:
self.assertEqual(span.service, self.SERVICE)
self.assertEqual(span.span_type, "cache")
self.assertEqual(span.get_tag(CACHE_BACKEND), "redis")
self.assertEqual(span.get_tag(CACHE_BACKEND), REDIS_CACHE)
self.assertEqual(span.get_tag(net.TARGET_HOST), "localhost")
self.assertEqual(span.get_metric("network.destination.port"), self.TEST_REDIS_PORT)

Expand All @@ -303,15 +306,15 @@ def test_default_span_tags_memcached(self):
Cache = get_traced_cache(service=self.SERVICE)
app = Flask(__name__)
config = {
"CACHE_TYPE": "memcached",
"CACHE_TYPE": MEMCACHED_CACHE,
"CACHE_MEMCACHED_SERVERS": [f"127.0.0.1:{self.TEST_MEMCACHED_PORT}"],
}
cache = Cache(app, config=config)
# test tags and attributes
with cache._TracedCache__trace("flask_cache.cmd") as span:
self.assertEqual(span.service, self.SERVICE)
self.assertEqual(span.span_type, "cache")
self.assertEqual(span.get_tag(CACHE_BACKEND), "memcached")
self.assertEqual(span.get_tag(CACHE_BACKEND), MEMCACHED_CACHE)
self.assertEqual(span.get_tag(net.TARGET_HOST), "127.0.0.1")
self.assertEqual(span.get_metric("network.destination.port"), self.TEST_MEMCACHED_PORT)

Expand All @@ -326,7 +329,7 @@ def setUp(self):
# create the TracedCache instance for a Flask app
Cache = get_traced_cache()
app = Flask(__name__)
self.cache = Cache(app, config={"CACHE_TYPE": "simple"})
self.cache = Cache(app, config={"CACHE_TYPE": SIMPLE_CACHE})

@TracerTestCase.run_in_subprocess(env_overrides=dict(DD_SERVICE="mysvc"))
def test_schematization_service_default(self):
Expand Down
14 changes: 8 additions & 6 deletions tests/contrib/flask_cache/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

from ..config import MEMCACHED_CONFIG
from ..config import REDIS_CONFIG
from . import MEMCACHED_CACHE
from . import REDIS_CACHE


class FlaskCacheUtilsTest(unittest.TestCase):
Expand All @@ -19,7 +21,7 @@ def test_extract_redis_connection_metadata(self):
Cache = get_traced_cache(service=self.SERVICE)
app = Flask(__name__)
config = {
"CACHE_TYPE": "redis",
"CACHE_TYPE": REDIS_CACHE,
"CACHE_REDIS_PORT": REDIS_CONFIG["port"],
}
traced_cache = Cache(app, config=config)
Expand All @@ -38,7 +40,7 @@ def test_extract_memcached_connection_metadata(self):
Cache = get_traced_cache(service=self.SERVICE)
app = Flask(__name__)
config = {
"CACHE_TYPE": "memcached",
"CACHE_TYPE": MEMCACHED_CACHE,
"CACHE_MEMCACHED_SERVERS": ["127.0.0.1:{}".format(MEMCACHED_CONFIG["port"])],
}
traced_cache = Cache(app, config=config)
Expand All @@ -56,7 +58,7 @@ def test_extract_memcached_multiple_connection_metadata(self):
Cache = get_traced_cache(service=self.SERVICE)
app = Flask(__name__)
config = {
"CACHE_TYPE": "memcached",
"CACHE_TYPE": MEMCACHED_CACHE,
"CACHE_MEMCACHED_SERVERS": [
"127.0.0.1:{}".format(MEMCACHED_CONFIG["port"]),
"localhost:{}".format(MEMCACHED_CONFIG["port"]),
Expand All @@ -77,7 +79,7 @@ def test_resource_from_cache_with_prefix(self):
Cache = get_traced_cache(service=self.SERVICE)
app = Flask(__name__)
config = {
"CACHE_TYPE": "redis",
"CACHE_TYPE": REDIS_CACHE,
"CACHE_REDIS_PORT": REDIS_CONFIG["port"],
"CACHE_KEY_PREFIX": "users",
}
Expand All @@ -92,7 +94,7 @@ def test_resource_from_cache_with_empty_prefix(self):
Cache = get_traced_cache(service=self.SERVICE)
app = Flask(__name__)
config = {
"CACHE_TYPE": "redis",
"CACHE_TYPE": REDIS_CACHE,
"CACHE_REDIS_PORT": REDIS_CONFIG["port"],
"CACHE_KEY_PREFIX": "",
}
Expand All @@ -106,7 +108,7 @@ def test_resource_from_cache_without_prefix(self):
# create the TracedCache instance for a Flask app
Cache = get_traced_cache(service=self.SERVICE)
app = Flask(__name__)
traced_cache = Cache(app, config={"CACHE_TYPE": "redis"})
traced_cache = Cache(app, config={"CACHE_TYPE": REDIS_CACHE})
# expect only the resource name
expected_resource = "get"
resource = _resource_from_cache_prefix("GET", traced_cache.config)
Expand Down
Loading
Loading