Skip to content

Commit

Permalink
Skip creating span for redisearch methods in _traced_execute_command
Browse files Browse the repository at this point in the history
  • Loading branch information
mpozniak95 committed Jun 26, 2024
1 parent 191ef9d commit 15e09d3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def response_hook(span, instance, response):
from opentelemetry.instrumentation.redis.package import _instruments
from opentelemetry.instrumentation.redis.util import (
_args_or_none,
_check_skip,
_extract_conn_attributes,
_format_command_args,
_set_span_attribute,
Expand Down Expand Up @@ -184,7 +185,8 @@ def _instrument(
def _traced_execute_command(func, instance, args, kwargs):
query = _format_command_args(args)
name = _build_span_name(instance, args)

if _check_skip(name):
return func(*args, **kwargs)
with tracer.start_as_current_span(
name, kind=trace.SpanKind.CLIENT
) as span:
Expand All @@ -205,7 +207,8 @@ def _traced_execute_pipeline(func, instance, args, kwargs):
resource,
span_name,
) = _build_span_meta_data_for_pipeline(instance)

if _check_skip(span_name):
return func(*args, **kwargs)
with tracer.start_as_current_span(
span_name, kind=trace.SpanKind.CLIENT
) as span:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ def _format_command_args(args):
return out_str


def _check_skip(name):
skip_list = ["FT.SEARCH", "FT.CREATE", "FT.AGGREGATE"]
for method in skip_list:
if method in name:
return True
return False


def _set_span_attribute(span, name, value):
if value is not None:
if value != "":
Expand Down

0 comments on commit 15e09d3

Please sign in to comment.