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

Service name is always "celery-worker" regardless of attempts to change it. #510

Closed
jrsmith3 opened this issue Jul 13, 2018 · 5 comments
Closed

Comments

@jrsmith3
Copy link

jrsmith3 commented Jul 13, 2018

I am trying to instrument my celery application with ddrtace and I cannot change its Datadog service name. The service name always shows up as "celery-worker" in the console even though a call to Pin.get_from shows the service name set to what I chose.

Here is some code showing what I tried:

>>> import celery
>>> from ddtrace import patch, Pin
>>> patch(celery=True)
>>> Pin.get_from(celery.Celery)
Pin(service=celery-worker, app=celery, app_type=worker, tags=None, tracer=<ddtrace.tracer.Tracer object at 0x7f53380c0dd0>)
>>> Pin.override(celery.Celery, service="my-service", app="my-app", app_type="my-app-type")
>>> Pin.get_from(celery.Celery)
Pin(service=my-service, app=my-app, app_type=my-app-type, tags=None, tracer=<ddtrace.tracer.Tracer object at 0x7f53380c0dd0>)
>>> # If I construct a Celery object I get the same output.
>>> c = celery.Celery("someapp")
>>> Pin.get_from(c)
Pin(service=my-service, app=my-app, app_type=my-app-type, tags=None, tracer=<ddtrace.tracer.Tracer object at 0x7f53380c0dd0>)

However, when I run my celery application, the Datadog console shows the service name as "celery-worker" in the "APM" -> "Services" window of the web console. I see similar behavior if I attempt to change the service name using tracer.set_service_info.

Does anyone know how to set the service name of a celery application? Thanks in advance.

@Kyle-Verhoog
Copy link
Member

Hey @jrsmith3!

Hmm it seems as though we are setting the service name regardless of any configuration provided. So this behaviour is expected.

Although this behaviour certainly does not seem ideal if a custom service name is provided. Thanks for reporting this, we'll get back to you about our plans around this soon!

@palazzem palazzem added this to the 0.12.2 milestone Jul 17, 2018
@palazzem
Copy link

@jrsmith3 we're testing a new way to instrument Celery and if the result is positive, this task will be resolved with the new configuration system. From your code, will be enough:

from ddtrace import config

config.celery['service_name'] = 'my-service'

# or task based
config.get_from(task)['service_name'] = 'another-service-for-this-task-only'

I will be sure this is shipped next week. Thanks for your patience.

@jrsmith3
Copy link
Author

@palazzem Perfect. Thanks for turning this around so quickly.

Question: the example you posted is an example of the future release, or can I use that code with the current release?

@palazzem
Copy link

You're welcome @jrsmith3! This example is for a future release. We're already using it for requests but the plan is to change entirely the API to use this simplified configuration (sidenote: no breaking changes will be included in any release). Next week is the ETA for the release.

Also we changed the way Celery instrumented because we had developers reporting that it wasn't working for them. The new approach is signals based. Would be great if you can test this new version before we ship, so that you can validate the new configuration and the new way Celery is instrumented.

Sounds good to you to try and install a beta release before we ship the 0.12.2?

@palazzem
Copy link

@jrsmith3 added the PR for this release (#540). We're actually covering only the Producer/Worker service name. With the current implementation it's not possible to change the service for a single task, but based on your example I guess this implementation is good enough. What do you think?

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

No branches or pull requests

3 participants