dd-trace-py icon indicating copy to clipboard operation
dd-trace-py copied to clipboard

Remove side-effect on `ddtrace` import

Open jirikuncar opened this issue 3 years ago • 0 comments

Current situation

ddtrace.tracer is automatically created on ddtrace import. As a side-effect the AgentWriter instance is automatically created which might result in spawning new thread.

Requirements

  1. Allow integrations (mostly CI Visibility) to control tracer configuration on startup.
  2. Keep backwards compatibility for accessing ddtrace.tracer.

Proposed changes

  1. Configuration changes might come as a result of #3703.
  2. Add __getattr__ method to ddtrace/__init__.py that will return Tracer() instance when tracer property is accessed.
    • Question: Do we want to keep the "global" tracer with import side effect as the "official" API in other module and if yes, where (ddtrace.init:tracer or ddtrace.global:tracer or other)?

jirikuncar avatar May 30 '22 10:05 jirikuncar