---
title: Code-level metrics
source: https://docs.newrelic.com/docs/apm/agents/python-agent/supported-features/python-code-level-metrics
---

Code-level metrics are span attributes that the Python agent attaches to your application's spans, pinpointing the exact function and file responsible for a given span. This allows you to be more proactive about addressing performance issues as you review your code. You can view these attributes on individual spans in [distributed tracing](https://docs.newrelic.com/docs/distributed-tracing/ui-data/understand-use-distributed-tracing-data/), or query them directly with [NRQL](https://docs.newrelic.com/docs/nrql/get-started/introduction-nrql-new-relics-query-language/).

> #### ⚠️ IMPORTANT
>
> Code-level metrics are available for Python agent version 7.10.0.175 and higher and are enabled by default. To change this configuration, check out our [documentation](https://docs.newrelic.com/docs/apm/agents/python-agent/configuration/python-agent-configuration/#code-level-metrics).

## Agent attributes

The Python agent reports and attaches the following attributes to spans produced by your application:

| **Name**         | **Description**                                                               | **Example**                      |
| ---------------- | ----------------------------------------------------------------------------- | -------------------------------- |
| `code.function`  | The name of the instrumented function                                         | validate_credentials             |
| `code.filepath`  | The absolute path to the source code file in which `code.function` is defined | /usr/local/apps/test-app/main.py |
| `code.lineno`    | The line number where `code.function` is defined in code.filepath             | 639                              |
| `code.namespace` | The namespace (class/ module name) in which `code.function` is defined        | example.service.MyService        |

> #### ⚠️ IMPORTANT
>
> Not every function in your application code will be instrumented with the above attributes. In some cases, the agent will directly wrap base framework code (ie. Django, Flask, etc.) that is invoked within your application, and these attributes won't be attached.
