dd-trace-py
dd-trace-py copied to clipboard
Proposal: turning off auto-start of tracer
Hi,
I've been using datadog for APM stuff for a bit, and one thing that bugs me is I can't not have the global tracer object running in the background. I don't use dd-trace-run to run my application, I manually configure it in the app, which works fine. However, when developing, we get - DATADOG TRACER DIAGNOSTIC - Agent not reachable. Exception raised: [Errno 61] Connection refused
messages on stderr. Not the end of the world, but still annoying. Is there any way to just have the tracer off until I manually boot it up? I can set DD_TRACE_STARTUP_LOGS
, but that doesn't fix it, just hides it.
The fact that it automatically runs as soon as you import it is a bit disappointing.
@alexcarruthers thanks for the feedback!
Yeah all the initialization and stuff at import is a bit of a tradeoff between onboarding/debugging and noise. I definitely hear you about the noise. We're considering alternative approaches to the logging which should be scheduled soon.
As you found, DD_TRACE_STARTUP_LOGS
will disable the brunt of startup cost of trying to query the agent and collect system information. With that disabled all the tracer is really doing at startup is initializing which shouldn't be too bad. By "running"/"on" do you mean the starting of threads used by the tracer? These should have pretty small costs involved (the trace writer thread actually isn't started until the first write occurs).
Nevertheless, having startup costs associated with import is typically not a good thing. One way we could do this is by putting off this initialization until patch
/patch_all()
is called or the user decides to initialize the tracer themselves which would give the user control as to when this cost occurs (ddtrace-run of course would still initialize it at startup since it's required). I'll give this some more thought and run it by the team 🙂
I'm interested in this as well. It would be nice to be able to have ddtrace only load with say DD_AGENT_HOST set. Or to be able to turn it off. DD_TRACE_STARTUP_LOGS=false
isn't working for me, I still get messages from ddtrace.
In production it's desirable, but for local development and use by end users it's a bit annoying.
I'd also like to be able to delay Tracer initialization since when configuring ddtrace from code it gets fiddly to override DD_SERVICE and DD_ENV before Tracer has read those env vars.
Manually doing what the Github Action was supposed to do (fixed in https://github.com/DataDog/dd-trace-py/pull/7835):
This issue has been automatically closed after six months of inactivity. If it's a feature request, it has been added to the maintainers' internal backlog and will be included in an upcoming round of feature prioritization. Please comment or reopen if you think this issue was closed in error.