open-telemetry / open-telemetry/opentelemetry-python-contrib

Flaky celery test

Open
#5,009 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.1k
Forks
1.1k
Avg merge
4d 15h
Merged PRs (30d)
16

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with instrumentation/opentelemetry-instrumentation-celery/tests/test_tasks.py:123 and the task_raises definition in tests/celery_test_tasks.py:29. Run TestCeleryInstrumentation.test_task_raises under Python 3.14 and inspect why only one span is collected. Done means the test reliably observes the expected two spans without weakening its assertion.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.