|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | 03-May-2022 | - |
| .circleci/ | H | 01-Dec-2021 | - | 1,102 | 999 |
| .dd-ci/ | H | 01-Dec-2021 | - | 48 | 44 |
| .github/ | H | 01-Dec-2021 | - | 763 | 673 |
| benchmarks/ | H | 01-Dec-2021 | - | 1,078 | 788 |
| ddtrace/ | H | 07-May-2022 | - | 136,391 | 103,123 |
| ddtrace.egg-info/ | H | 03-May-2022 | - | 43 | 35 |
| docs/ | H | 03-May-2022 | - | 2,550 | 1,548 |
| hooks/ | H | 01-Dec-2021 | - | 164 | 107 |
| releasenotes/ | H | 01-Dec-2021 | - | 1,531 | 1,272 |
| scripts/ | H | 01-Dec-2021 | - | 1,016 | 712 |
| templates/integration/ | H | 01-Dec-2021 | - | 75 | 45 |
| tests/ | H | 01-Dec-2021 | - | 72,870 | 59,118 |
| .coveragerc | H A D | 01-Dec-2021 | 207 | 12 | 9 |
| .gitignore | H A D | 01-Dec-2021 | 1.6 KiB | 120 | 96 |
| .gitlab-ci.yml | H A D | 01-Dec-2021 | 726 | 27 | 23 |
| .mergify.yml | H A D | 01-Dec-2021 | 1 KiB | 43 | 41 |
| .readthedocs.yml | H A D | 01-Dec-2021 | 207 | 14 | 11 |
| CHANGELOG.md | H A D | 01-Dec-2021 | 80.6 KiB | 1,999 | 1,391 |
| Dockerfile.buster | H A D | 01-Dec-2021 | 3.2 KiB | 97 | 84 |
| LICENSE | H A D | 01-Dec-2021 | 186 | 7 | 4 |
| LICENSE.Apache | H A D | 01-Dec-2021 | 11.1 KiB | 201 | 169 |
| LICENSE.BSD3 | H A D | 01-Dec-2021 | 1.5 KiB | 25 | 22 |
| NOTICE | H A D | 01-Dec-2021 | 146 | 5 | 3 |
| PKG-INFO | H A D | 01-Dec-2021 | 1.6 KiB | 43 | 35 |
| README.md | H A D | 01-Dec-2021 | 6.3 KiB | 161 | 108 |
| conftest.py | H A D | 01-Dec-2021 | 3.1 KiB | 81 | 43 |
| ddtrace_gevent_check.py | H A D | 01-Dec-2021 | 447 | 14 | 11 |
| docker-compose.yml | H A D | 01-Dec-2021 | 4.7 KiB | 162 | 155 |
| mypy.ini | H A D | 01-Dec-2021 | 252 | 14 | 11 |
| pyproject.toml | H A D | 01-Dec-2021 | 1.1 KiB | 47 | 43 |
| riotfile.py | H A D | 01-Dec-2021 | 45 KiB | 1,334 | 1,256 |
| setup.cfg | H A D | 01-Dec-2021 | 199 | 12 | 8 |
| setup.py | H A D | 03-May-2022 | 8.4 KiB | 265 | 220 |
| tox.ini | H A D | 01-Dec-2021 | 12.4 KiB | 326 | 312 |
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