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

Code-level metrics are span attributes that the Java agent attaches to your application's spans, pinpointing the exact function and class 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 Java agent version 7.10.0 or higher, and enabled by default for version 7.11.0 and higher. See [Java agent configuration: Config file](https://docs.newrelic.com/docs/apm/agents/java-agent/configuration/java-agent-configuration-config-file/#code-level-metrics) for instructions on how to enabled or disable it.

## Agent attributes

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

| **Name**         | **Description**                                                                | **Example**           |
| ---------------- | ------------------------------------------------------------------------------ | --------------------- |
| `code.function`  | The name of the instrumented function (Java method).                           | retrieveData          |
| `code.namespace` | The namespace (fully qualified class name) in which `code.function` is defined | com.example.MyService |

> #### ⚠️ IMPORTANT
>
> Spans created using the API method `NewRelic.getAgent().getTransaction().startSegment()` will not contain these attributes. To create a span that contain these attributes annotate a method with `@Trace` or use XML instrumentation.
