Skip to content

Instrumenting the same broker twice adds duplicate OpenTelemetry middleware #709

Open

Description

@IlyaKhalafi
from taskiq import InMemoryBroker
from taskiq.instrumentation import TaskiqInstrumentor

broker = InMemoryBroker()
instrumentor = TaskiqInstrumentor()
instrumentor.instrument_broker(broker)
instrumentor.instrument_broker(broker)
print(len(broker.middlewares))

On current main this prints 2. The method writes _is_instrumented_by_opentelemetry but checks is_instrumented_by_opentelemetry, so its existing duplicate-instrumentation guard never sees the flag. Repeated setup should keep one middleware.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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