# General attributes

Site [llms.txt](/llms.txt)

---

**Status**: [Development][DocumentStatus]

The attributes described in this section are not specific to a particular operation but rather generic.
They may be used in any Span they apply to.
Particular operations may refer to or require some of these attributes.

<!-- START doctoc -->

- [Network attributes](#network-attributes)
- [General remote service attributes](#general-remote-service-attributes)
  - [Service identities](#service-identities)
- [General thread attributes](#general-thread-attributes)
- [Source code attributes](#source-code-attributes)

<!-- END doctoc -->

<!-- Keep old anchor IDs -->
<a id="server-and-client-attributes"></a>
<a id="server-client-and-shared-network-attributes"></a>

## Network attributes

Network communication is described by several families of attributes: `client.*` / `server.*`,
`source.*` / `destination.*`, and `network.local.*` / `network.peer.*`. Their definitions live in
the attribute registry:

- [`client.*`](/docs/specs/semconv/registry/attributes/client.md) and [`server.*`](/docs/specs/semconv/registry/attributes/server.md)
- [`source.*`](/docs/specs/semconv/registry/attributes/source.md) and [`destination.*`](/docs/specs/semconv/registry/attributes/destination.md)
- [`network.*`](/docs/specs/semconv/registry/attributes/network.md)

For help choosing among these families, see
[Choosing network address and port attributes](/docs/specs/semconv/network/choosing-network-attributes.md).

## General remote service attributes

<a id="service-peer"></a>

### Service identities

The resource's `service.name` and `service.namespace` identify the service producing the telemetry.
The `client.service.*` and `server.service.*` attributes identify the services participating in the
interaction, using the same logical roles as `client.address` and `server.address`.
An observer can record both the client and server service identities on the same signal.

For example, when `shoppingcart` calls `payments`:

| Observation point | Resource `service.name` | Span `client.service.name` | Span `server.service.name` |
| --- | --- | --- | --- |
| Client | `shoppingcart` | `shoppingcart`, if recorded | `payments` |
| Server | `payments` | `shoppingcart` | `payments`, if recorded |

The local service identity is already available on the resource, so recording it again on the span
is usually unnecessary.

Service identity attributes are included in the
[client](/docs/specs/semconv/network/choosing-network-attributes.md#client) and
[server](/docs/specs/semconv/network/choosing-network-attributes.md#server) attribute groups.

## General thread attributes

<!-- semconv thread -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->

**Status:** ![Development](https://img.shields.io/badge/-development-blue)

These attributes may be used for any operation to store information about a thread that started a span.

**Attributes:**

| Key | Stability | [Requirement Level](/docs/specs/semconv/general/attribute-requirement-level/) | Value Type | Description | Example Values |
| --- | --- | --- | --- | --- | --- |
| [`thread.id`](/docs/specs/semconv/registry/attributes/thread.md) | ![Development](https://img.shields.io/badge/-development-blue) | `Recommended` | int | Current "managed" thread ID (as opposed to OS thread ID). [1] | `42` |
| [`thread.name`](/docs/specs/semconv/registry/attributes/thread.md) | ![Development](https://img.shields.io/badge/-development-blue) | `Recommended` | string | Current thread name. [2] | `main` |

**[1] `thread.id`:** Examples of where the value can be extracted from:

| Language or platform | Source |
| --- | --- |
| JVM | `Thread.currentThread().threadId()` |
| .NET | `Thread.CurrentThread.ManagedThreadId` |
| Python | `threading.current_thread().ident` |
| Ruby | `Thread.current.object_id` |
| C++ | `std::this_thread::get_id()` |
| Erlang | `erlang:self()` |

**[2] `thread.name`:** Examples of where the value can be extracted from:

| Language or platform | Source |
| --- | --- |
| JVM | `Thread.currentThread().getName()` |
| .NET | `Thread.CurrentThread.Name` |
| Python | `threading.current_thread().name` |
| Ruby | `Thread.current.name` |
| Erlang | `erlang:process_info(self(), registered_name)` |

<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->

## Source code attributes

**Status**: [Release Candidate][DocumentStatus]

Often a span is closely tied to a certain unit of code that is logically responsible for handling
the operation that the span describes (usually the method that starts the span).
For an HTTP server span, this would be the function that handles the incoming request, for example.
The [code attributes](/docs/specs/semconv/registry/attributes/code/) allow to report this unit of code
and therefore to provide more context.

[DocumentStatus]: /docs/specs/otel/document-status/
