Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typing for redis #3118

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def response_hook(span, instance, response):

from __future__ import annotations

from typing import TYPE_CHECKING, Any, Callable, Collection
from typing import TYPE_CHECKING, Any, Callable, Collection, Optional, Union

import redis
from wrapt import wrap_function_wrapper
Expand Down Expand Up @@ -159,7 +159,8 @@ def response_hook(span, instance, response):


def _set_connection_attributes(
span: Span, conn: RedisInstance | AsyncRedisInstance
span: Span,
conn: Union[AsyncRedisInstance, RedisInstance],
) -> None:
if not span.is_recording() or not hasattr(conn, "connection_pool"):
return
Expand All @@ -170,7 +171,8 @@ def _set_connection_attributes(


def _build_span_name(
instance: RedisInstance | AsyncRedisInstance, cmd_args: tuple[Any, ...]
instance: Union[AsyncRedisInstance, RedisInstance],
cmd_args: tuple[Any, ...],
) -> str:
if len(cmd_args) > 0 and cmd_args[0]:
if cmd_args[0] == "FT.SEARCH":
Expand All @@ -185,7 +187,7 @@ def _build_span_name(


def _build_span_meta_data_for_pipeline(
instance: PipelineInstance | AsyncPipelineInstance,
instance: Union[AsyncPipelineInstance, PipelineInstance],
) -> tuple[list[Any], str, str]:
try:
command_stack = (
Expand Down Expand Up @@ -217,8 +219,8 @@ def _build_span_meta_data_for_pipeline(
# pylint: disable=R0915
def _instrument(
tracer: Tracer,
request_hook: _RequestHookT | None = None,
response_hook: _ResponseHookT | None = None,
request_hook: Optional[_RequestHookT] = None,
response_hook: Optional[_ResponseHookT] = None,
):
def _traced_execute_command(
func: Callable[..., R],
Expand Down
Loading