Skip to content

Commit afd8c4a

Browse files
committed
making pymysql follow semantic conventions
1 parent d7d7e96 commit afd8c4a

File tree

2 files changed

+35
-29
lines changed

2 files changed

+35
-29
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@
5050
from opentelemetry.instrumentation.pymysql.version import __version__
5151

5252
_CONNECTION_ATTRIBUTES = {
53-
"database": "db",
54-
"port": "port",
55-
"host": "host",
56-
"user": "user",
53+
"db.namespace": "db",
54+
"server.port": "port",
55+
"server.address": "host",
56+
"db.user": "user",
5757
}
5858
_DATABASE_SYSTEM = "mysql"
5959

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

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,11 @@
1717

1818
import redis
1919
import redis.asyncio
20-
21-
from redis.exceptions import ResponseError
22-
from redis.commands.search.indexDefinition import IndexDefinition, IndexType
2320
from redis.commands.search.aggregation import AggregateRequest
21+
from redis.commands.search.field import TextField, VectorField
22+
from redis.commands.search.indexDefinition import IndexDefinition, IndexType
2423
from redis.commands.search.query import Query
25-
from redis.commands.search.field import (
26-
TextField,
27-
VectorField,
28-
)
24+
from redis.exceptions import ResponseError
2925

3026
from opentelemetry import trace
3127
from opentelemetry.instrumentation.redis import RedisInstrumentor
@@ -644,34 +640,44 @@ def prepare_data(self):
644640
self.redis_client.ft("idx:test_vss").dropindex(True)
645641
except ResponseError:
646642
print("No such index")
647-
item = {"name": "test",
648-
"value": "test_value",
649-
"embeddings": [0.1] * 256}
643+
item = {
644+
"name": "test",
645+
"value": "test_value",
646+
"embeddings": [0.1] * 256,
647+
}
650648
pipeline = self.redis_client.pipeline()
651649
pipeline.json().set(f"test:001", "$", item)
652650
res = pipeline.execute()
653651
assert False not in res
654652

655653
def create_index(self):
656-
schema = (
657-
TextField("$.name", no_stem=True, as_name="name"),
658-
TextField("$.value", no_stem=True, as_name="value"),
659-
VectorField("$.embeddings",
660-
"FLAT",
661-
{
662-
"TYPE": "FLOAT32",
663-
"DIM": self.embedding_dim,
664-
"DISTANCE_METRIC": "COSINE",
665-
},
666-
as_name="vector",),
667-
)
668-
definition = IndexDefinition(prefix=["test:"], index_type=IndexType.JSON)
669-
res = self.redis_client.ft("idx:test_vss").create_index(fields=schema, definition=definition)
654+
schema = (
655+
TextField("$.name", no_stem=True, as_name="name"),
656+
TextField("$.value", no_stem=True, as_name="value"),
657+
VectorField(
658+
"$.embeddings",
659+
"FLAT",
660+
{
661+
"TYPE": "FLOAT32",
662+
"DIM": self.embedding_dim,
663+
"DISTANCE_METRIC": "COSINE",
664+
},
665+
as_name="vector",
666+
),
667+
)
668+
definition = IndexDefinition(
669+
prefix=["test:"], index_type=IndexType.JSON
670+
)
671+
res = self.redis_client.ft("idx:test_vss").create_index(
672+
fields=schema, definition=definition
673+
)
670674
assert "OK" in str(res)
671675

672676
def test_redis_create_index(self):
673677
spans = self.memory_exporter.get_finished_spans()
674-
span = next(span for span in spans if span.name == "redis.create_index")
678+
span = next(
679+
span for span in spans if span.name == "redis.create_index"
680+
)
675681
assert "redis.create_index.fields" in span.attributes
676682

677683
def test_redis_query(self):

0 commit comments

Comments
 (0)