Skip to content

Commit 1b2107b

Browse files
committed
use initialize instead of sitecustomize
1 parent a877aa1 commit 1b2107b

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

taskiq/instrumentation.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ async def main():
4949
"Cannot instrument. Please install 'taskiq[opentelemetry]'.",
5050
) from exc
5151

52-
52+
from opentelemetry.instrumentation.auto_instrumentation import initialize
5353
from opentelemetry.instrumentation.instrumentor import ( # type: ignore[attr-defined]
5454
BaseInstrumentor,
5555
)
@@ -65,20 +65,19 @@ async def main():
6565
logger = logging.getLogger("taskiq.opentelemetry")
6666

6767

68-
def _worker_function_with_sitecustomize(
68+
def _worker_function_with_initialize(
6969
worker_function: Callable[[WorkerArgs], None],
7070
*args: Any,
7171
**kwargs: Any,
7272
) -> None:
73-
import opentelemetry.instrumentation.auto_instrumentation.sitecustomize # noqa
74-
73+
initialize()
7574
return worker_function(*args, **kwargs)
7675

7776

7877
def _worker_function_factory(
7978
worker_function: Callable[[WorkerArgs], None],
8079
) -> Callable[[WorkerArgs], None]:
81-
return partial(_worker_function_with_sitecustomize, worker_function)
80+
return partial(_worker_function_with_initialize, worker_function)
8281

8382

8483
class TaskiqInstrumentor(BaseInstrumentor):

0 commit comments

Comments
 (0)