Skip to content

ZADD is broken - Instrumentation Redis init - Lumigo Opentelemetry 1.0.118 #547

@pasolid

Description

@pasolid

Last version of Lumigo Opentelemetry 1.0.118, the Redis instrumentation breaks Redis ZADD functionality

Exact placeumigo_opentelemetry/instrumentations/redis/__init__.p:
fix: update opentelemetry dependencies to patch security vulnerability

# when this hook is called, but only includes the command name for some
# versions so we need to set it ourselves.
add_body_attribute(span, " ".join(args), "db.statement")

Expected behavior

When calling the redis client zadd operation with multiple values like this:

redis_client.zadd("zset", {"One": 10, "Two": 20, "Three": 30})

it should add all values into the ZSet.

Actual result

The operation fails with next error:

args = ('ZADD', 'zset', 10, 'One', 20, 'Two', ...), kwargs = {}
    def request_hook(
        span: Span, instance: Connection, args: List[Any], kwargs: Dict[Any, Any]
    ) -> None:
        # a db.statement attribute is automatically added by the RedisInstrumentor
        # when this hook is called, but only includes the command name for some
        # versions so we need to set it ourselves.
>       add_body_attribute(span, " ".join(args), "db.statement")
E       TypeError: sequence item 2: expected str instance, int found
/usr/local/lib/python3.7/site-packages/lumigo_opentelemetry/instrumentations/redis/__init__.py:28: TypeError

Workaround

To downgrade to version 1.0.117

Potential solution

Revert to using json.dumps(args) or split into two parts:

  1. redis command which usually comes first
  2. redis command attributes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions