@@ -107,7 +107,7 @@ def response_hook(span, instance, response):
107
107
)
108
108
from opentelemetry .instrumentation .redis .version import __version__
109
109
from opentelemetry .instrumentation .utils import unwrap
110
- from opentelemetry .semconv .trace import SpanAttributes , DbSystemValues
110
+ from opentelemetry .semconv .trace import SpanAttributes
111
111
from opentelemetry .trace import Span , StatusCode
112
112
113
113
_DEFAULT_SERVICE = "redis"
@@ -240,9 +240,7 @@ def _traced_execute_pipeline(func, instance, args, kwargs):
240
240
241
241
def _add_create_attributes (span , args ):
242
242
_set_span_attribute (
243
- span ,
244
- "redis.create_index.index" ,
245
- _value_or_none (args , 1 )
243
+ span , "redis.create_index.index" , _value_or_none (args , 1 )
246
244
)
247
245
# According to: https://github.com/redis/redis-py/blob/master/redis/commands/search/commands.py#L155 schema is last argument for execute command
248
246
try :
@@ -253,10 +251,12 @@ def _add_create_attributes(span, args):
253
251
field_attribute = ""
254
252
# Schema in format:
255
253
# [first_field_name, first_field_type, first_field_some_attribute1, first_field_some_attribute2, second_field_name, ...]
256
- field_types = ["NUMERIC" , "TEXT" , "GEO" , "TAG" , "VECTOR" ]
254
+ field_types = ["NUMERIC" , "TEXT" , "GEO" , "TAG" , "VECTOR" ]
257
255
for index in range (len (schema )):
258
256
if schema [index ] in field_types :
259
- field_attribute += f"Field(name: { schema [index - 1 ]} , type: { schema [index ]} );"
257
+ field_attribute += (
258
+ f"Field(name: { schema [index - 1 ]} , type: { schema [index ]} );"
259
+ )
260
260
_set_span_attribute (
261
261
span ,
262
262
"redis.create_index.fields" ,
@@ -265,14 +265,10 @@ def _add_create_attributes(span, args):
265
265
266
266
def _add_search_attributes (span , response , args ):
267
267
_set_span_attribute (
268
- span ,
269
- "redis.search.index" ,
270
- _value_or_none (args , 1 )
268
+ span , "redis.search.index" , _value_or_none (args , 1 )
271
269
)
272
270
_set_span_attribute (
273
- span ,
274
- "redis.search.query" ,
275
- _value_or_none (args , 2 )
271
+ span , "redis.search.query" , _value_or_none (args , 2 )
276
272
)
277
273
# Parse response from search
278
274
# https://redis.io/docs/latest/commands/ft.search/
@@ -288,12 +284,16 @@ def _add_search_attributes(span, response, args):
288
284
return
289
285
if number_of_returned_documents :
290
286
for document_number in range (number_of_returned_documents ):
291
- document_index = _value_or_none (response , 1 + 2 * document_number )
287
+ document_index = _value_or_none (
288
+ response , 1 + 2 * document_number
289
+ )
292
290
if document_index :
293
- document = response [2 + 2 * document_number ]
291
+ document = response [2 + 2 * document_number ]
294
292
for attribute_name_index in range (0 , len (document ), 2 ):
295
293
_set_span_attribute (
296
- span , f"redis.search.xdoc_{ document_index } .{ document [attribute_name_index ]} " , document [attribute_name_index + 1 ]
294
+ span ,
295
+ f"redis.search.xdoc_{ document_index } .{ document [attribute_name_index ]} " ,
296
+ document [attribute_name_index + 1 ],
297
297
)
298
298
299
299
pipeline_class = (
0 commit comments