---
title: Python
description: Collect metrics, traces, and logs from your Python applications.
breadcrumbs: Docs > Integrations > Python
---

# Python

## Overview{% #overview %}

The Python integration allows you to collect and monitor your Python application logs, traces, and custom metrics.

## Setup{% #setup %}

### Metric collection{% #metric-collection %}

See the dedicated documentation for [collecting Python custom metrics with DogStatsD](https://docs.datadoghq.com/developers/dogstatsd/?tab=python).

### Trace collection{% #trace-collection %}

See the dedicated documentation for [instrumenting your Python application](https://docs.datadoghq.com/tracing/setup/python/) to send its traces to Datadog.

### Log collection{% #log-collection %}

*Available for Agent v6.0+*

See the dedicated documentation on how to [setup Python log collection](https://docs.datadoghq.com/logs/log_collection/python/) to forward your logs to Datadog.

### Profile collection{% #profile-collection %}

See the dedicated documentation for [enabling the Python profiler](https://docs.datadoghq.com/profiler/enabling/python/).

### Code Security{% #code-security %}

See the dedicated documentation for [enabling Code Security for your Python application](https://docs.datadoghq.com/security/code_security/).

### App & API Protection (AAP){% #app--api-protection-aap %}

See the dedicated documentation for [securing your Python application](https://docs.datadoghq.com/security/application_security/setup/python/) to enable App & API Protection (AAP).

## Data Collected{% #data-collected %}

### Metrics{% #metrics %}

|  |
|  |
| **runtime.python.cpu.time.sys**(gauge)                | Number of seconds executing in the kernel*Shown as second*      |
| **runtime.python.cpu.time.user**(gauge)               | Number of seconds executing outside the kernel*Shown as second* |
| **runtime.python.cpu.percent**(gauge)                 | CPU utilization percentage*Shown as percent*                    |
| **runtime.python.cpu.ctx\_switch.voluntary**(gauge)   | Number of voluntary context switches*Shown as invocation*       |
| **runtime.python.cpu.ctx\_switch.involuntary**(gauge) | Number of involuntary context switches*Shown as invocation*     |
| **runtime.python.gc.count.gen0**(gauge)               | Number of generation 0 objects*Shown as resource*               |
| **runtime.python.gc.count.gen1**(gauge)               | Number of generation 1 objects*Shown as resource*               |
| **runtime.python.gc.count.gen2**(gauge)               | Number of generation 2 objects*Shown as resource*               |
| **runtime.python.mem.rss**(gauge)                     | Resident set memory*Shown as byte*                              |
| **runtime.python.thread\_count**(gauge)               | Number of threads*Shown as thread*                              |

## Troubleshooting{% #troubleshooting %}

Need help? Contact [Datadog support](https://docs.datadoghq.com/help/).

## Further Reading{% #further-reading %}

- [Tracing asynchronous Python code with Datadog APM](https://www.datadoghq.com/blog/tracing-async-python-code/)
- [Python logging formats: How to collect and centralize Python logs](https://www.datadoghq.com/blog/python-logging-best-practices/)
