Skip to content

Commit 748022a

Browse files
committed
Reformat files
1 parent 59b7c91 commit 748022a

File tree

1 file changed

+15
-15
lines changed
  • instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis

1 file changed

+15
-15
lines changed

Diff for: instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/__init__.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def response_hook(span, instance, response):
107107
)
108108
from opentelemetry.instrumentation.redis.version import __version__
109109
from opentelemetry.instrumentation.utils import unwrap
110-
from opentelemetry.semconv.trace import SpanAttributes, DbSystemValues
110+
from opentelemetry.semconv.trace import SpanAttributes
111111
from opentelemetry.trace import Span, StatusCode
112112

113113
_DEFAULT_SERVICE = "redis"
@@ -240,9 +240,7 @@ def _traced_execute_pipeline(func, instance, args, kwargs):
240240

241241
def _add_create_attributes(span, args):
242242
_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)
246244
)
247245
# According to: https://github.com/redis/redis-py/blob/master/redis/commands/search/commands.py#L155 schema is last argument for execute command
248246
try:
@@ -253,10 +251,12 @@ def _add_create_attributes(span, args):
253251
field_attribute = ""
254252
# Schema in format:
255253
# [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"]
257255
for index in range(len(schema)):
258256
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+
)
260260
_set_span_attribute(
261261
span,
262262
"redis.create_index.fields",
@@ -265,14 +265,10 @@ def _add_create_attributes(span, args):
265265

266266
def _add_search_attributes(span, response, args):
267267
_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)
271269
)
272270
_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)
276272
)
277273
# Parse response from search
278274
# https://redis.io/docs/latest/commands/ft.search/
@@ -288,12 +284,16 @@ def _add_search_attributes(span, response, args):
288284
return
289285
if number_of_returned_documents:
290286
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+
)
292290
if document_index:
293-
document = response[2+2*document_number]
291+
document = response[2 + 2 * document_number]
294292
for attribute_name_index in range(0, len(document), 2):
295293
_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],
297297
)
298298

299299
pipeline_class = (

0 commit comments

Comments
 (0)