Skip to content

Flaky celery test #5009

Description

@xrmx

This is with Python 3.14:

=================================== FAILURES ===================================
__________________ TestCeleryInstrumentation.test_task_raises __________________

self = <tests.test_tasks.TestCeleryInstrumentation testMethod=test_task_raises>

    def test_task_raises(self):
        CeleryInstrumentor().instrument()
    
        result = task_raises.delay()
    
        timeout = time.time() + 60 * 1  # 1 minutes from now
        while not result.ready():
            if time.time() > timeout:
                break
            time.sleep(0.05)
    
        spans = self.sorted_spans(self.memory_exporter.get_finished_spans())
>       self.assertEqual(len(spans), 2)
E       AssertionError: 1 != 2

instrumentation/opentelemetry-instrumentation-celery/tests/test_tasks.py:123: AssertionError
----------------------------- Captured stdout call -----------------------------
 
 -------------- celery@runnervmgx7h7 v5.3.6 (emerald-rush)
--- ***** ----- 
-- ******* ---- Linux-6.17.0-1022-azure-x86_64-with-glibc2.39 2026-08-28 09:04:22
- *** --- * --- 
- ** ---------- [config]
- ** ---------- .> app:         __main__:0x7f29ba8b6510
- ** ---------- .> transport:   memory://localhost//
- ** ---------- .> results:     rpc://
- *** --- * --- .> concurrency: 1 (solo)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** ----- 
 -------------- [queues]
                .> celery           exchange=celery(direct) key=celery
                

----------------------------- Captured stderr call -----------------------------
[2026-08-28 09:04:22,731: WARNING/MainProcess] No hostname was supplied. Reverting to default 'localhost'
[2026-08-28 09:04:22,734: WARNING/MainProcess] No hostname was supplied. Reverting to default 'localhost'
[2026-08-28 09:04:23,742: ERROR/MainProcess] Task tests.celery_test_tasks.task_raises[b0d8851d-0ffb-467f-8721-c75b3d3703e9] raised unexpected: CustomError('The task failed!')
Traceback (most recent call last):
  File "/home/runner/work/opentelemetry-python-contrib/opentelemetry-python-contrib/.tox/py314-test-instrumentation-celery/lib/python3.14/site-packages/celery/app/trace.py", line 477, in trace_task
    R = retval = fun(*args, **kwargs)
                 ~~~^^^^^^^^^^^^^^^^^
  File "/home/runner/work/opentelemetry-python-contrib/opentelemetry-python-contrib/.tox/py314-test-instrumentation-celery/lib/python3.14/site-packages/celery/app/trace.py", line 760, in __protected_call__
    return self.run(*args, **kwargs)
           ~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/runner/work/opentelemetry-python-contrib/opentelemetry-python-contrib/instrumentation/opentelemetry-instrumentation-celery/tests/celery_test_tasks.py", line 29, in task_raises
    raise CustomError("The task failed!")
tests.celery_test_tasks.CustomError: The task failed!
[2026-08-28 09:04:24,736: WARNING/MainProcess] Attempting to uninstrument while already uninstrumented
------------------------------ Captured log call -------------------------------
WARNING  kombu.connection:connection.py:669 No hostname was supplied. Reverting to default 'localhost'
WARNING  kombu.connection:connection.py:669 No hostname was supplied. Reverting to default 'localhost'
ERROR    celery.app.trace:trace.py:270 Task tests.celery_test_tasks.task_raises[b0d8851d-0ffb-467f-8721-c75b3d3703e9] raised unexpected: CustomError('The task failed!')
Traceback (most recent call last):
  File "/home/runner/work/opentelemetry-python-contrib/opentelemetry-python-contrib/.tox/py314-test-instrumentation-celery/lib/python3.14/site-packages/celery/app/trace.py", line 477, in trace_task
    R = retval = fun(*args, **kwargs)
                 ~~~^^^^^^^^^^^^^^^^^
  File "/home/runner/work/opentelemetry-python-contrib/opentelemetry-python-contrib/.tox/py314-test-instrumentation-celery/lib/python3.14/site-packages/celery/app/trace.py", line 760, in __protected_call__
    return self.run(*args, **kwargs)
           ~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/runner/work/opentelemetry-python-contrib/opentelemetry-python-contrib/instrumentation/opentelemetry-instrumentation-celery/tests/celery_test_tasks.py", line 29, in task_raises
    raise CustomError("The task failed!")
tests.celery_test_tasks.CustomError: The task failed!
WARNING  opentelemetry.instrumentation.instrumentor:instrumentor.py:130 Attempting to uninstrument while already uninstrumented

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