skaji: @jd Any news?
I would like to set datadog unix socket path via DD_TRACE_AGENT_URL. Thanks! 
jd: My bad, I miss the approval from @brettlangdon. I'll rebase and repush.
diff --git a/ddtrace/tracer.py b/ddtrace/tracer.py
index bc238ca5d..8ecba7564 100644
--- a/ddtrace/tracer.py
+++ b/ddtrace/tracer.py
@@ -38,11 +38,14 @@ class Tracer(object):
     DEFAULT_HOSTNAME = environ.get('DD_AGENT_HOST', environ.get('DATADOG_TRACE_AGENT_HOSTNAME', 'localhost'))
     DEFAULT_PORT = int(environ.get('DD_TRACE_AGENT_PORT', 8126))
     DEFAULT_DOGSTATSD_PORT = int(get_env('dogstatsd', 'port', 8125))
+    DEFAULT_AGENT_URL = environ.get('DD_TRACE_AGENT_URL', 'http://%s:%d' % (DEFAULT_HOSTNAME, DEFAULT_PORT))
 
-    def __init__(self):
+    def __init__(self, url=DEFAULT_AGENT_URL):
         """
         Create a new ``Tracer`` instance. A global tracer is already initialized
         for common usage, so there is no need to initialize your own ``Tracer``.
+
+        :param url: The Datadog agent URL.
         """
         self.log = log
         self.sampler = None
@@ -52,11 +55,36 @@ class Tracer(object):
         self._dogstatsd_host = self.DEFAULT_HOSTNAME
         self._dogstatsd_port = self.DEFAULT_DOGSTATSD_PORT
 
+        uds_path = None
+        https = None
+        hostname = self.DEFAULT_HOSTNAME
+        port = self.DEFAULT_PORT
+        if url is not None:
+            url_parsed = compat.parse.urlparse(url)
+            if url_parsed.scheme in ('http', 'https'):
+                hostname = url_parsed.hostname
+                port = url_parsed.port
+                https = url_parsed.scheme == 'https'
+                # FIXME This is needed because of the way of configure() works right now, where it considers `port=None`
+                # to be "no port set so let's use the default".
+                # It should go away when we remove configure()
+                if port is None:
+                    if https:
+                        port = 443
+                    else:
+                        port = 80
+            elif url_parsed.scheme == 'unix':
+                uds_path = url_parsed.path
+            else:
+                raise ValueError('Unknown scheme `%s` for agent URL' % url_parsed.scheme)
+
         # Apply the default configuration
         self.configure(
             enabled=True,
-            hostname=self.DEFAULT_HOSTNAME,
-            port=self.DEFAULT_PORT,
+            hostname=hostname,
+            port=port,
+            https=https,
+            uds_path=uds_path,
             sampler=AllSampler(),
             context_provider=DefaultContextProvider(),
         )
@@ -112,6 +140,7 @@ class Tracer(object):
         """Returns the current Tracer Context Provider"""
         return self._context_provider
 
+    # TODO: deprecate this method and make sure users create a new tracer if they need different parameters
     def configure(self, enabled=None, hostname=None, port=None, uds_path=None, https=None,
                   dogstatsd_host=None, dogstatsd_port=None, sampler=None, context_provider=None,
                   wrap_executor=None, priority_sampling=None, settings=None, collect_metrics=None):
@@ -172,13 +201,16 @@ class Tracer(object):
         if hostname is not None or port is not None or uds_path is not None or https is not None or \
                 filters is not None or priority_sampling is not None:
             # Preserve hostname and port when overriding filters or priority sampling
-            default_hostname = self.DEFAULT_HOSTNAME
-            default_port = self.DEFAULT_PORT
+            # This is clumsy and a good reason to get rid of this configure() API
             if hasattr(self, 'writer') and hasattr(self.writer, 'api'):
                 default_hostname = self.writer.api.hostname
                 default_port = self.writer.api.port
                 if https is None:
                     https = self.writer.api.https
+            else:
+                default_hostname = self.DEFAULT_HOSTNAME
+                default_port = self.DEFAULT_PORT
+
             self.writer = AgentWriter(
                 hostname or default_hostname,
                 port or default_port,
diff --git a/docs/installation_quickstart.rst b/docs/installation_quickstart.rst
index ec19ddc2b..0f158f30f 100644
--- a/docs/installation_quickstart.rst
+++ b/docs/installation_quickstart.rst
@@ -34,6 +34,28 @@ For more advanced usage of ``ddtrace-run`` refer to the documentation :ref:`here
 To find out how to trace your own code manually refer to the documentation :ref:`here<basic usage>`.
 
 
+Configuration
+~~~~~~~~~~~~~
+
+You can configure some parameters of the library by setting environment
+variable before starting your application and importing the library:
+
+.. list-table::
+   :header-rows: 1
+   :widths: 1 1 2
+
+   * - Configuration Variable
+     - Configuration Type
+     - Default Value
+     - Value Description
+   * - ``DD_TRACE_AGENT_URL``
+     - URL
+     - ``http://localhost:8126``
+     - The URL to use to connect the Datadog agent. The url can starts with
+       ``http://`` to connect using HTTP or with ``unix://`` to use a Unix
+       Domain Socket.
+
+
 OpenTracing
 -----------
 

Request: set uds_path via an environment variable
dd-trace-py supports unix domain socket connection https://github.com/DataDog/dd-trace-py/pull/975.

It would be nice dd-trace-py allows us to set uds_path via an environment variable,
say `DATADOG_TRACE_UDS_PATH=/path/to/apm.socket`.
diff --git a/tests/test_tracer.py b/tests/test_tracer.py
index 51e93de41..22d822727 100644
--- a/tests/test_tracer.py
+++ b/tests/test_tracer.py
@@ -8,6 +8,7 @@ import sys
 from unittest.case import SkipTest
 
 import mock
+import pytest
 
 import ddtrace
 from ddtrace.ext import system
@@ -499,3 +500,30 @@ def test_excepthook():
         mock.call('datadog.tracer.uncaught_exceptions', 1, tags=['class:Foobar']),
     ))
     assert called
+
+
+def test_tracer_url():
+    t = ddtrace.Tracer()
+    assert t.writer.api.hostname == 'localhost'
+    assert t.writer.api.port == 8126
+
+    t = ddtrace.Tracer(url='http://foobar:12')
+    assert t.writer.api.hostname == 'foobar'
+    assert t.writer.api.port == 12
+
+    t = ddtrace.Tracer(url='unix:///foobar')
+    assert t.writer.api.uds_path == '/foobar'
+
+    t = ddtrace.Tracer(url='http://localhost')
+    assert t.writer.api.hostname == 'localhost'
+    assert t.writer.api.port == 80
+    assert not t.writer.api.https
+
+    t = ddtrace.Tracer(url='https://localhost')
+    assert t.writer.api.hostname == 'localhost'
+    assert t.writer.api.port == 443
+    assert t.writer.api.https
+
+    with pytest.raises(ValueError) as e:
+        t = ddtrace.Tracer(url='foo://foobar:12')
+        assert str(e) == 'Unknown scheme `https` for agent URL'

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-mock opentracing mock
apt-get update apt-get install -y gcc
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
coverage==7.8.0
-e git+https://github.com/DataDog/dd-trace-py.git@3576559cfcfe8491bb4deef498c059080f3162f6#egg=ddtrace
exceptiongroup==1.2.2
iniconfig==2.1.0
mock==5.2.0
opentracing==2.4.0
packaging==24.2
pluggy==1.5.0
psutil==7.0.0
pytest==8.3.5
pytest-cov==6.0.0
pytest-mock==3.14.0
tomli==2.2.1

name: dd-trace-py
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - coverage==7.8.0
      - exceptiongroup==1.2.2
      - iniconfig==2.1.0
      - mock==5.2.0
      - opentracing==2.4.0
      - packaging==24.2
      - pluggy==1.5.0
      - psutil==7.0.0
      - pytest==8.3.5
      - pytest-cov==6.0.0
      - pytest-mock==3.14.0
      - tomli==2.2.1
prefix: /opt/conda/envs/dd-trace-py

tests/test_tracer.py::test_tracer_url
tests/test_tracer.py::TracerTestCase::test_adding_services tests/test_tracer.py::TracerTestCase::test_configure_runtime_worker tests/test_tracer.py::TracerTestCase::test_default_provider_get tests/test_tracer.py::TracerTestCase::test_default_provider_set tests/test_tracer.py::TracerTestCase::test_default_provider_trace tests/test_tracer.py::TracerTestCase::test_global_context tests/test_tracer.py::TracerTestCase::test_only_root_span_runtime tests/test_tracer.py::TracerTestCase::test_span_no_runtime_tags tests/test_tracer.py::TracerTestCase::test_start_child_from_context tests/test_tracer.py::TracerTestCase::test_start_child_span tests/test_tracer.py::TracerTestCase::test_start_child_span_attributes tests/test_tracer.py::TracerTestCase::test_start_span tests/test_tracer.py::TracerTestCase::test_start_span_optional tests/test_tracer.py::TracerTestCase::test_tracer tests/test_tracer.py::TracerTestCase::test_tracer_current_root_span_missing_context tests/test_tracer.py::TracerTestCase::test_tracer_current_span tests/test_tracer.py::TracerTestCase::test_tracer_current_span_missing_context tests/test_tracer.py::TracerTestCase::test_tracer_disabled tests/test_tracer.py::TracerTestCase::test_tracer_disabled_mem_leak tests/test_tracer.py::TracerTestCase::test_tracer_global_tags tests/test_tracer.py::TracerTestCase::test_tracer_pid tests/test_tracer.py::TracerTestCase::test_tracer_vars tests/test_tracer.py::TracerTestCase::test_tracer_wrap tests/test_tracer.py::TracerTestCase::test_tracer_wrap_class tests/test_tracer.py::TracerTestCase::test_tracer_wrap_default_name tests/test_tracer.py::TracerTestCase::test_tracer_wrap_exception tests/test_tracer.py::TracerTestCase::test_tracer_wrap_factory tests/test_tracer.py::TracerTestCase::test_tracer_wrap_factory_nested tests/test_tracer.py::TracerTestCase::test_tracer_wrap_multiple_calls tests/test_tracer.py::TracerTestCase::test_tracer_wrap_span_nesting tests/test_tracer.py::TracerTestCase::test_tracer_wrap_span_nesting_current_root_span tests/test_tracer.py::test_installed_excepthook tests/test_tracer.py::test_excepthook
docs/installation_quickstart.rst ddtrace/tracer.py
docs/installation_quickstart.rst ddtrace/tracer.py