Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not recording celery beat tasks #110

Open
Horiol opened this issue Mar 14, 2020 · 0 comments
Open

Not recording celery beat tasks #110

Horiol opened this issue Mar 14, 2020 · 0 comments

Comments

@Horiol
Copy link

Horiol commented Mar 14, 2020

Hello, I'm trying to get traces of the celery tasks and I'm using a celery beat process to schedule the tasks but I can't receive anything if the task is executed from beat.

Example code:
tasks.py

from celery import Celery
from opentracing_instrumentation.client_hooks import celery as celery_hooks

# from custom_celery import CeleryTracing
from tracer import init_tracer
import periodic

tracer = init_tracer('test')

celery_hooks.install_patches()
app = Celery('tasks', broker='redis://localhost:6379/0')

periodic.py

from celery import shared_task


@shared_task()
def add(x=1, y=1):
    return x + y

beat.py

from celery import Celery
from tracer import init_tracer

tracer = init_tracer('beat-liveclips')

beat_schedule = {
    "print-in-ten-seconds-task": {
        "task": "periodic.add",
        "schedule": 10.0,
        "args":[3,5]
    }
}

app = Celery(broker='redis://localhost:6379/0')
app.conf.beat_schedule = beat_schedule

tracer.py

import logging
from jaeger_client import Config

def init_tracer(service):
    logging.getLogger('').handlers = []
    logging.basicConfig(format='%(message)s', level=logging.DEBUG)

    config = Config(
        config={
            'sampler': {
                'type': 'const',
                'param': 1,
            },
            'logging': True,
        },
        service_name=service,
    )

    return config.initialize_tracer()

and then, you have to execute the worker and the beat with the following commands:
celery -A tasks worker --loglevel=info
celery -A beat beat --loglevel=info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant