Skip to content

Commit 6888ed9

Browse files
committed
chore: align valkey package with merged main and finalize 3.9 drop
- Bump valkey requires-python to >=3.10 and remove 3.9 classifier/tox factor - Remove unreachable return statement after warning in uninstrument_client - Add redis-valkey-base to opentelemetry-contrib-instrumentations - Update bootstrap_gen with redis-valkey-base and bump valkey to 0.63b0.dev - Migrate redis/valkey docker functional tests to SERVER_ADDRESS/SERVER_PORT - Update valkey docker tests to use db.redis.* attributes per semconv decision
1 parent 1c3fa8c commit 6888ed9

8 files changed

Lines changed: 39 additions & 45 deletions

File tree

instrumentation/opentelemetry-instrumentation-valkey/pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dynamic = ["version"]
88
description = "OpenTelemetry Valkey instrumentation"
99
readme = "README.rst"
1010
license = "Apache-2.0"
11-
requires-python = ">=3.9"
11+
requires-python = ">=3.10"
1212
authors = [
1313
{ name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" },
1414
]
@@ -18,7 +18,6 @@ classifiers = [
1818
"License :: OSI Approved :: Apache Software License",
1919
"Programming Language :: Python",
2020
"Programming Language :: Python :: 3",
21-
"Programming Language :: Python :: 3.9",
2221
"Programming Language :: Python :: 3.10",
2322
"Programming Language :: Python :: 3.11",
2423
"Programming Language :: Python :: 3.12",

instrumentation/opentelemetry-instrumentation-valkey/src/opentelemetry/instrumentation/valkey/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,6 @@ def uninstrument_client(
469469
_logger.warning(
470470
"Attempting to un-instrument Valkey connection that wasn't instrumented"
471471
)
472-
return
473472

474473
def instrumentation_dependencies(self) -> Collection[str]:
475474
return _instruments

instrumentation/opentelemetry-instrumentation-valkey/tests/test_valkey.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,7 @@ def test_attributes_default(self):
247247
"valkey",
248248
)
249249
self.assertEqual(span.attributes["db.redis.database_index"], 0)
250-
self.assertEqual(
251-
span.attributes[SERVER_ADDRESS], "localhost"
252-
)
250+
self.assertEqual(span.attributes[SERVER_ADDRESS], "localhost")
253251
self.assertEqual(span.attributes[SERVER_PORT], 6379)
254252

255253
def test_attributes_tcp(self):
@@ -269,9 +267,7 @@ def test_attributes_tcp(self):
269267
"valkey",
270268
)
271269
self.assertEqual(span.attributes["db.redis.database_index"], 1)
272-
self.assertEqual(
273-
span.attributes[SERVER_ADDRESS], "1.1.1.1"
274-
)
270+
self.assertEqual(span.attributes[SERVER_ADDRESS], "1.1.1.1")
275271
self.assertEqual(span.attributes[SERVER_PORT], 6380)
276272

277273
def test_attributes_unix_socket(self):

opentelemetry-contrib-instrumentations/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ dependencies = [
6767
"opentelemetry-instrumentation-pymysql==0.63b0.dev",
6868
"opentelemetry-instrumentation-pyramid==0.63b0.dev",
6969
"opentelemetry-instrumentation-redis==0.63b0.dev",
70+
"opentelemetry-instrumentation-redis-valkey-base==0.63b0.dev",
7071
"opentelemetry-instrumentation-remoulade==0.63b0.dev",
7172
"opentelemetry-instrumentation-requests==0.63b0.dev",
7273
"opentelemetry-instrumentation-sqlalchemy==0.63b0.dev",

opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,14 @@
203203
},
204204
{
205205
"library": "valkey[libvalkey] >= 6.1.0",
206-
"instrumentation": "opentelemetry-instrumentation-valkey==0.55b0.dev",
206+
"instrumentation": "opentelemetry-instrumentation-valkey==0.63b0.dev",
207207
},
208208
]
209209
default_instrumentations = [
210210
"opentelemetry-instrumentation-asyncio==0.63b0.dev",
211211
"opentelemetry-instrumentation-dbapi==0.63b0.dev",
212212
"opentelemetry-instrumentation-logging==0.63b0.dev",
213+
"opentelemetry-instrumentation-redis-valkey-base==0.63b0.dev",
213214
"opentelemetry-instrumentation-sqlite3==0.63b0.dev",
214215
"opentelemetry-instrumentation-threading==0.63b0.dev",
215216
"opentelemetry-instrumentation-urllib==0.63b0.dev",

tests/opentelemetry-docker-tests/tests/redis/test_redis_functional.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
DB_REDIS_DATABASE_INDEX,
2121
DB_STATEMENT,
2222
)
23-
from opentelemetry.semconv._incubating.attributes.net_attributes import (
24-
NET_PEER_NAME,
25-
NET_PEER_PORT,
23+
from opentelemetry.semconv.attributes.server_attributes import (
24+
SERVER_ADDRESS,
25+
SERVER_PORT,
2626
)
2727
from opentelemetry.test.test_base import TestBase
2828

@@ -42,8 +42,8 @@ def _check_span(self, span, name):
4242
self.assertEqual(span.name, name)
4343
self.assertIs(span.status.status_code, trace.StatusCode.UNSET)
4444
self.assertEqual(span.attributes.get(DB_REDIS_DATABASE_INDEX), 0)
45-
self.assertEqual(span.attributes[NET_PEER_NAME], "localhost")
46-
self.assertEqual(span.attributes[NET_PEER_PORT], 6379)
45+
self.assertEqual(span.attributes[SERVER_ADDRESS], "localhost")
46+
self.assertEqual(span.attributes[SERVER_PORT], 6379)
4747

4848
def test_long_command_sanitized(self):
4949
RedisInstrumentor().uninstrument()
@@ -266,8 +266,8 @@ def _check_span(self, span, name):
266266
self.assertEqual(span.name, name)
267267
self.assertIs(span.status.status_code, trace.StatusCode.UNSET)
268268
self.assertEqual(span.attributes.get(DB_REDIS_DATABASE_INDEX), 0)
269-
self.assertEqual(span.attributes[NET_PEER_NAME], "localhost")
270-
self.assertEqual(span.attributes[NET_PEER_PORT], 6379)
269+
self.assertEqual(span.attributes[SERVER_ADDRESS], "localhost")
270+
self.assertEqual(span.attributes[SERVER_PORT], 6379)
271271

272272
def test_long_command(self):
273273
async_call(self.redis_client.mget(*range(1000)))
@@ -564,8 +564,8 @@ def tearDown(self):
564564
def _check_span(self, span, name):
565565
self.assertEqual(span.name, name)
566566
self.assertIs(span.status.status_code, trace.StatusCode.UNSET)
567-
self.assertEqual(span.attributes[NET_PEER_NAME], "localhost")
568-
self.assertEqual(span.attributes[NET_PEER_PORT], 6379)
567+
self.assertEqual(span.attributes[SERVER_ADDRESS], "localhost")
568+
self.assertEqual(span.attributes[SERVER_PORT], 6379)
569569
self.assertEqual(span.attributes[DB_REDIS_DATABASE_INDEX], 10)
570570

571571
def test_get(self):

tests/opentelemetry-docker-tests/tests/valkey/test_valkey_functional.py

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020

2121
from opentelemetry import trace
2222
from opentelemetry.instrumentation.valkey import ValkeyInstrumentor
23+
from opentelemetry.semconv.attributes.server_attributes import (
24+
SERVER_ADDRESS,
25+
SERVER_PORT,
26+
)
2327
from opentelemetry.semconv.trace import SpanAttributes
2428
from opentelemetry.test.test_base import TestBase
2529

@@ -38,11 +42,9 @@ def tearDown(self):
3842
def _check_span(self, span, name):
3943
self.assertEqual(span.name, name)
4044
self.assertIs(span.status.status_code, trace.StatusCode.UNSET)
41-
self.assertEqual(span.attributes.get("db.valkey.database_index"), 0)
42-
self.assertEqual(
43-
span.attributes[SpanAttributes.NET_PEER_NAME], "localhost"
44-
)
45-
self.assertEqual(span.attributes[SpanAttributes.NET_PEER_PORT], 16379)
45+
self.assertEqual(span.attributes.get("db.redis.database_index"), 0)
46+
self.assertEqual(span.attributes[SERVER_ADDRESS], "localhost")
47+
self.assertEqual(span.attributes[SERVER_PORT], 16379)
4648

4749
def test_long_command_sanitized(self):
4850
ValkeyInstrumentor().uninstrument()
@@ -91,7 +93,7 @@ def test_basics_sanitized(self):
9193
self.assertEqual(
9294
span.attributes.get(SpanAttributes.DB_STATEMENT), "GET ?"
9395
)
94-
self.assertEqual(span.attributes.get("db.valkey.args_length"), 2)
96+
self.assertEqual(span.attributes.get("db.redis.args_length"), 2)
9597

9698
def test_basics(self):
9799
self.assertIsNone(self.valkey_client.get("cheese"))
@@ -102,7 +104,7 @@ def test_basics(self):
102104
self.assertEqual(
103105
span.attributes.get(SpanAttributes.DB_STATEMENT), "GET ?"
104106
)
105-
self.assertEqual(span.attributes.get("db.valkey.args_length"), 2)
107+
self.assertEqual(span.attributes.get("db.redis.args_length"), 2)
106108

107109
def test_pipeline_traced_sanitized(self):
108110
ValkeyInstrumentor().uninstrument()
@@ -122,7 +124,7 @@ def test_pipeline_traced_sanitized(self):
122124
span.attributes.get(SpanAttributes.DB_STATEMENT),
123125
"SET ? ?\nRPUSH ? ?\nHGETALL ?",
124126
)
125-
self.assertEqual(span.attributes.get("db.valkey.pipeline_length"), 3)
127+
self.assertEqual(span.attributes.get("db.redis.pipeline_length"), 3)
126128

127129
def test_pipeline_traced(self):
128130
with self.valkey_client.pipeline(transaction=False) as pipeline:
@@ -139,7 +141,7 @@ def test_pipeline_traced(self):
139141
span.attributes.get(SpanAttributes.DB_STATEMENT),
140142
"SET ? ?\nRPUSH ? ?\nHGETALL ?",
141143
)
142-
self.assertEqual(span.attributes.get("db.valkey.pipeline_length"), 3)
144+
self.assertEqual(span.attributes.get("db.redis.pipeline_length"), 3)
143145

144146
def test_pipeline_immediate_sanitized(self):
145147
ValkeyInstrumentor().uninstrument()
@@ -223,7 +225,7 @@ def test_basics(self):
223225
self.assertEqual(
224226
span.attributes.get(SpanAttributes.DB_STATEMENT), "GET ?"
225227
)
226-
self.assertEqual(span.attributes.get("db.valkey.args_length"), 2)
228+
self.assertEqual(span.attributes.get("db.redis.args_length"), 2)
227229

228230
def test_pipeline_traced(self):
229231
with self.valkey_client.pipeline(transaction=False) as pipeline:
@@ -240,7 +242,7 @@ def test_pipeline_traced(self):
240242
span.attributes.get(SpanAttributes.DB_STATEMENT),
241243
"SET ? ?\nRPUSH ? ?\nHGETALL ?",
242244
)
243-
self.assertEqual(span.attributes.get("db.valkey.pipeline_length"), 3)
245+
self.assertEqual(span.attributes.get("db.redis.pipeline_length"), 3)
244246

245247
def test_parent(self):
246248
"""Ensure OpenTelemetry works with valkey."""
@@ -282,11 +284,9 @@ def tearDown(self):
282284
def _check_span(self, span, name):
283285
self.assertEqual(span.name, name)
284286
self.assertIs(span.status.status_code, trace.StatusCode.UNSET)
285-
self.assertEqual(span.attributes.get("db.valkey.database_index"), 0)
286-
self.assertEqual(
287-
span.attributes[SpanAttributes.NET_PEER_NAME], "localhost"
288-
)
289-
self.assertEqual(span.attributes[SpanAttributes.NET_PEER_PORT], 16379)
287+
self.assertEqual(span.attributes.get("db.redis.database_index"), 0)
288+
self.assertEqual(span.attributes[SERVER_ADDRESS], "localhost")
289+
self.assertEqual(span.attributes[SERVER_PORT], 16379)
290290

291291
def test_long_command(self):
292292
async_call(self.valkey_client.mget(*range(1000)))
@@ -313,7 +313,7 @@ def test_basics(self):
313313
self.assertEqual(
314314
span.attributes.get(SpanAttributes.DB_STATEMENT), "GET ?"
315315
)
316-
self.assertEqual(span.attributes.get("db.valkey.args_length"), 2)
316+
self.assertEqual(span.attributes.get("db.redis.args_length"), 2)
317317

318318
def test_execute_command_traced_full_time(self):
319319
"""Command should be traced for coroutine execution time, not creation time."""
@@ -358,7 +358,7 @@ async def pipeline_simple():
358358
span.attributes.get(SpanAttributes.DB_STATEMENT),
359359
"SET ? ?\nRPUSH ? ?\nHGETALL ?",
360360
)
361-
self.assertEqual(span.attributes.get("db.valkey.pipeline_length"), 3)
361+
self.assertEqual(span.attributes.get("db.redis.pipeline_length"), 3)
362362

363363
def test_pipeline_traced_full_time(self):
364364
"""Command should be traced for coroutine execution time, not creation time."""
@@ -482,7 +482,7 @@ def test_basics(self):
482482
self.assertEqual(
483483
span.attributes.get(SpanAttributes.DB_STATEMENT), "GET ?"
484484
)
485-
self.assertEqual(span.attributes.get("db.valkey.args_length"), 2)
485+
self.assertEqual(span.attributes.get("db.redis.args_length"), 2)
486486

487487
def test_execute_command_traced_full_time(self):
488488
"""Command should be traced for coroutine execution time, not creation time."""
@@ -527,7 +527,7 @@ async def pipeline_simple():
527527
span.attributes.get(SpanAttributes.DB_STATEMENT),
528528
"SET ? ?\nRPUSH ? ?\nHGETALL ?",
529529
)
530-
self.assertEqual(span.attributes.get("db.valkey.pipeline_length"), 3)
530+
self.assertEqual(span.attributes.get("db.redis.pipeline_length"), 3)
531531

532532
def test_pipeline_traced_full_time(self):
533533
"""Command should be traced for coroutine execution time, not creation time."""
@@ -593,11 +593,9 @@ def tearDown(self):
593593
def _check_span(self, span, name):
594594
self.assertEqual(span.name, name)
595595
self.assertIs(span.status.status_code, trace.StatusCode.UNSET)
596-
self.assertEqual(
597-
span.attributes[SpanAttributes.NET_PEER_NAME], "localhost"
598-
)
599-
self.assertEqual(span.attributes[SpanAttributes.NET_PEER_PORT], 16379)
600-
self.assertEqual(span.attributes["db.valkey.database_index"], 10)
596+
self.assertEqual(span.attributes[SERVER_ADDRESS], "localhost")
597+
self.assertEqual(span.attributes[SERVER_PORT], 16379)
598+
self.assertEqual(span.attributes["db.redis.database_index"], 10)
601599

602600
def test_get(self):
603601
self.assertIsNone(self.valkey_client.get("foo"))

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ envlist =
440440
lint-processor-baggage
441441

442442
; opentelemetry-instrumentation-valkey
443-
py3{9,10,11,12,13,14}-test-instrumentation-valkey
443+
py3{10,11,12,13,14}-test-instrumentation-valkey
444444
pypy3-test-instrumentation-valkey
445445
lint-instrumentation-valkey
446446

0 commit comments

Comments
 (0)