• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.circleci/H01-Dec-2021-1,102999

.dd-ci/H01-Dec-2021-4844

.github/H01-Dec-2021-763673

benchmarks/H01-Dec-2021-1,078788

ddtrace/H07-May-2022-136,391103,123

ddtrace.egg-info/H03-May-2022-4335

docs/H03-May-2022-2,5501,548

hooks/H01-Dec-2021-164107

releasenotes/H01-Dec-2021-1,5311,272

scripts/H01-Dec-2021-1,016712

templates/integration/H01-Dec-2021-7545

tests/H01-Dec-2021-72,87059,118

.coveragercH A D01-Dec-2021207 129

.gitignoreH A D01-Dec-20211.6 KiB12096

.gitlab-ci.ymlH A D01-Dec-2021726 2723

.mergify.ymlH A D01-Dec-20211 KiB4341

.readthedocs.ymlH A D01-Dec-2021207 1411

CHANGELOG.mdH A D01-Dec-202180.6 KiB1,9991,391

Dockerfile.busterH A D01-Dec-20213.2 KiB9784

LICENSEH A D01-Dec-2021186 74

LICENSE.ApacheH A D01-Dec-202111.1 KiB201169

LICENSE.BSD3H A D01-Dec-20211.5 KiB2522

NOTICEH A D01-Dec-2021146 53

PKG-INFOH A D01-Dec-20211.6 KiB4335

README.mdH A D01-Dec-20216.3 KiB161108

conftest.pyH A D01-Dec-20213.1 KiB8143

ddtrace_gevent_check.pyH A D01-Dec-2021447 1411

docker-compose.ymlH A D01-Dec-20214.7 KiB162155

mypy.iniH A D01-Dec-2021252 1411

pyproject.tomlH A D01-Dec-20211.1 KiB4743

riotfile.pyH A D01-Dec-202145 KiB1,3341,256

setup.cfgH A D01-Dec-2021199 128

setup.pyH A D03-May-20228.4 KiB265220

tox.iniH A D01-Dec-202112.4 KiB326312

README.md

1# dd-trace-py
2
3[![CircleCI](https://circleci.com/gh/DataDog/dd-trace-py/tree/master.svg?style=svg)](https://circleci.com/gh/DataDog/dd-trace-py/tree/master)
4[![Pyversions](https://img.shields.io/pypi/pyversions/ddtrace.svg?style=flat)](https://pypi.org/project/ddtrace/)
5[![PypiVersions](https://img.shields.io/pypi/v/ddtrace.svg)](https://pypi.org/project/ddtrace/)
6[![OpenTracing Badge](https://img.shields.io/badge/OpenTracing-enabled-blue.svg)](https://ddtrace.readthedocs.io/en/stable/installation_quickstart.html#opentracing)
7
8`ddtrace` is Datadog's tracing library for Python. It is used to trace requests
9as they flow across web servers, databases and microservices so that developers
10have great visibility into bottlenecks and troublesome requests.
11
12## Getting Started
13
14For a basic product overview, installation and quick start, check out our
15[setup documentation][setup docs].
16
17For more advanced usage and configuration, check out our [API
18documentation][api docs].
19
20For descriptions of terminology used in APM, take a look at the [official
21documentation][visualization docs].
22
23[setup docs]: https://docs.datadoghq.com/tracing/setup/python/
24[api docs]: https://ddtrace.readthedocs.io/
25[visualization docs]: https://docs.datadoghq.com/tracing/visualization/
26
27## Development
28
29### Contributing
30
31See [docs/contributing.rst](docs/contributing.rst).
32
33### Pre-commit Hooks
34
35The tracer library uses formatting/linting tools including black, flake8, and mypy.
36While these are run in each CI pipeline for pull requests, they are automated to run
37when you call `git commit` as pre-commit hooks to catch any formatting errors before
38you commit. To initialize the pre-commit hook script to run in your development
39branch, run the following command:
40
41    $ hooks/autohook.sh install
42
43### Set up your environment
44
45#### Set up docker
46
47The test suite requires many backing services such as PostgreSQL, MySQL, Redis
48and more. We use `docker` and `docker-compose` to run the services in our CI
49and for development. To run the test matrix, please [install docker][docker] and
50[docker-compose][docker-compose] using the instructions provided by your platform. Then
51launch them through:
52
53    $ docker-compose up -d
54
55[docker]: https://www.docker.com/products/docker
56[docker-compose]: https://www.docker.com/products/docker-compose
57
58#### Set up Python
59
601. Clone the repository locally: `git clone https://github.com/DataDog/dd-trace-py`
612. The tests for this project run on various versions of Python. We recommend
62   using a Python version management tool, such as
63   [pyenv](https://github.com/pyenv/pyenv), to utilize multiple versions of
64   Python. Install Pyenv: https://github.com/pyenv/pyenv#installation
653. Install the relevant versions of Python in Pyenv: `pyenv install 3.9.1, 2.7.18, 3.5.10, 3.6.12, 3.7.9, 3.8.7, 3.10.0`
664. Make those versions available globally: `pyenv global 3.9.1, 2.7.18, 3.5.10, 3.6.12, 3.7.9, 3.8.7, 3.10.0`
67
68### Testing
69
70#### Running Tests in docker
71
72Once your docker-compose environment is running, you can use the shell script to
73execute tests within a Docker image. You can start the container with a bash shell:
74
75    $ scripts/ddtest
76
77You can now run tests as you would do in your local environment. We use
78[tox][tox] as well as [riot][riot], a new tool that we developed for addressing
79our specific needs with an ever growing matrix of tests. You can list the tests
80managed by each:
81
82    $ tox -l
83    $ riot list
84
85You can run multiple tests by using regular expressions:
86
87    $ scripts/run-tox-scenario '^futures_contrib-'
88    $ riot run psycopg
89
90[tox]: https://github.com/tox-dev/tox/
91[riot]: https://github.com/DataDog/riot/
92
93#### Running Tests locally
94
951. Install riot: `pip install riot`.
962. Create the base virtual environments: `riot -v generate`.
973. You can list the available test suites with `riot list`.
984. Certain tests might require running service containers in order to emulate
99   the necessary testing environment. You can spin up individual containers with
100   `docker-compose up -d <SERVICE_NAME>`, where `<SERVICE_NAME>` should match a
101   service specified in the `docker-compose.yml` file.
1025. Run a test suite: `riot -v run <RUN_FLAGS> <TEST_SUITE_NAME>`.
103   1. Optionally, use the `-s` and `-x` flags: `-s` prevents riot from
104      reinstalling the dev package; `-x` forces an exit after the first failed
105      test suite. To limit the tests to a particular version of Python, use the
106      `-p` flag: `riot -v run -p <PYTHON_VERSION>`.
107
108The `run` command uses regex syntax, which in some cases will cause multiple
109test suites to run. Use the following syntax to ensure only an individual suite
110runs: `^<TEST_SUITE_NAME>$` where `^` signifies the start of a string and `$`
111signifies the end of a string. For example, use `riot -v run -s -x ^redis$` to
112run only the redis suite.
113
114#### Use the APM Test Agent
115
116The APM test agent can emulate the APM endpoints of the Datadog agent. Spin up
117the `testagent` container along with any other service container:
118
119    $ docker-compose up -d testagent <SERVICE_CONTAINER>
120
121Run the test agent as a proxy in your tests:
122
123    $ DD_TRACE_AGENT_URL=http://localhost:9126/ riot -v run <RUN_FLAGS> --pass-env <TEST_SUITE_NAME>
124
125`--pass-env` injects the environment variables of the current shell session into
126the command. Here's an example command for running the redis test suite along
127with the test agent, limited to tests for Python 3.9:
128
129    $ DD_TRACE_AGENT_URL=http://localhost:9126/ riot -v run -p 3.9 -s -x --pass-env '^redis$'
130
131Read more about the APM test agent:
132https://github.com/datadog/dd-apm-test-agent#readme
133
134### Continuous Integration
135
136We use CircleCI 2.0 for our continuous integration.
137
138#### Configuration
139
140The CI tests are configured through [config.yml](.circleci/config.yml).
141
142#### Running Locally
143
144The CI tests can be run locally using the `circleci` CLI. More information about
145the CLI can be found at https://circleci.com/docs/2.0/local-cli/.
146
147After installing the `circleci` CLI, you can run jobs by name. For example:
148
149    $ circleci build --job django
150
151### Release Notes
152
153This project follows [semver](https://semver.org/) and so bug fixes, breaking
154changes, new features, etc must be accompanied by a release note. To generate a
155release note:
156
157    $ riot run reno new <short-description-of-change>
158
159Document the changes in the generated file, remove the irrelevant sections and
160commit the release note with the change.
161