mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-07-29 21:23:55 +08:00
Fix flaky celery docker test (#652)
The test was actually generating 2 spans but on very fast systems we only saw one as the test ran faster than the message would travel through the broker, trigger a task and generate 2nd span. Switched from .delay() to .apply() so only one span is generated which is enough for the test in question.
This commit is contained in:
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
import celery
|
import celery
|
||||||
from celery.exceptions import Retry
|
from celery.exceptions import Retry
|
||||||
from flaky import flaky
|
|
||||||
from pytest import mark
|
from pytest import mark
|
||||||
|
|
||||||
import opentelemetry.instrumentation.celery
|
import opentelemetry.instrumentation.celery
|
||||||
@ -559,8 +558,6 @@ def test_apply_async_previous_style_tasks(
|
|||||||
) == async_run_span.attributes.get(SpanAttributes.MESSAGING_MESSAGE_ID)
|
) == async_run_span.attributes.get(SpanAttributes.MESSAGING_MESSAGE_ID)
|
||||||
|
|
||||||
|
|
||||||
# FIXME find a permanent solution for the flakiness of this test
|
|
||||||
@flaky
|
|
||||||
def test_custom_tracer_provider(celery_app, memory_exporter):
|
def test_custom_tracer_provider(celery_app, memory_exporter):
|
||||||
@celery_app.task
|
@celery_app.task
|
||||||
def fn_task():
|
def fn_task():
|
||||||
@ -576,7 +573,7 @@ def test_custom_tracer_provider(celery_app, memory_exporter):
|
|||||||
CeleryInstrumentor().uninstrument()
|
CeleryInstrumentor().uninstrument()
|
||||||
CeleryInstrumentor().instrument(tracer_provider=tracer_provider)
|
CeleryInstrumentor().instrument(tracer_provider=tracer_provider)
|
||||||
|
|
||||||
fn_task.delay()
|
fn_task.apply()
|
||||||
|
|
||||||
spans_list = memory_exporter.get_finished_spans()
|
spans_list = memory_exporter.get_finished_spans()
|
||||||
assert len(spans_list) == 1
|
assert len(spans_list) == 1
|
||||||
|
Reference in New Issue
Block a user