# RPC

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

---

- [Remote Procedure Call (RPC) Attributes](#remote-procedure-call-rpc-attributes)
- [Deprecated RPC Attributes](#deprecated-rpc-attributes)

## Remote Procedure Call (RPC) Attributes

This document defines attributes for remote procedure calls.

**Attributes:**

| Key | Stability | Value Type | Description | Example Values |
| --- | --- | --- | --- | --- |
| <a id="rpc-method" href="#rpc-method">`rpc.method`</a> | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | string | The fully-qualified logical name of the method from the RPC interface perspective. [1] | `com.example.ExampleService/exampleMethod`; `EchoService/Echo`; `_OTHER` |
| <a id="rpc-method-original" href="#rpc-method-original">`rpc.method_original`</a> | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | string | The original name of the method used by the client. | `com.myservice.EchoService/catchAll`; `com.myservice.EchoService/unknownMethod`; `InvalidMethod` |
| <a id="rpc-request-header" href="#rpc-request-header">`rpc.request.header.<key>`</a> | ![Release Candidate](https://img.shields.io/badge/-rc-mediumorchid) | string[] | RPC request headers or metadata, `<key>` being the normalized header name (lowercase), the value being the header values. [2] | `["1.2.3.4", "1.2.3.5"]` |
| <a id="rpc-response-header" href="#rpc-response-header">`rpc.response.header.<key>`</a> | ![Release Candidate](https://img.shields.io/badge/-rc-mediumorchid) | string[] | RPC response headers or metadata sent before the response payload, `<key>` being the normalized header name (lowercase), the value being the header values. [3] | `["attribute_value"]` |
| <a id="rpc-response-trailer" href="#rpc-response-trailer">`rpc.response.trailer.<key>`</a> | ![Release Candidate](https://img.shields.io/badge/-rc-mediumorchid) | string[] | RPC response trailers or metadata sent after the response payload, `<key>` being the normalized trailer name (lowercase), the value being the trailer values. [4] | `["attribute_value"]` |
| <a id="rpc-status-code" href="#rpc-status-code">`rpc.status_code`</a> | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | string | Status code of the RPC returned by the RPC server or generated by the client [5] | `OK`; `DEADLINE_EXCEEDED`; `-32602` |
| <a id="rpc-system-name" href="#rpc-system-name">`rpc.system.name`</a> | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | string | The Remote Procedure Call (RPC) system. [6] | `grpc`; `dubbo`; `connectrpc` [(see more)](#rpc-system-name-values) |

**[1] `rpc.method`:** The method name MAY have unbounded cardinality in edge or error cases.

Some RPC frameworks or libraries provide a fixed set of recognized methods
for client stubs and server implementations. Instrumentations for such
frameworks MUST set this attribute to the original method name only
when the method is recognized by the framework or library.

When the method is not recognized, for example, when the server receives
a request for a method that is not predefined on the server, or when
instrumentation is not able to reliably detect if the method is predefined,
the attribute MUST be set to `_OTHER`.

If the RPC instrumentation could end up converting valid RPC methods to
`_OTHER`, then it SHOULD provide a way to configure the list of recognized
RPC methods.

The `rpc.method` can be different from the name of any implementing
method/function.
The `code.function.name` attribute may be used to record the fully-qualified
method actually executing the call on the server side, or the
RPC client stub method on the client side.

**[2] `rpc.request.header.<key>`:** Instrumentations SHOULD require an explicit configuration of which headers are to be captured.
Including all request headers can be a security risk - explicit configuration helps avoid leaking sensitive information.

For example, a header `my-custom-key` with value `["1.2.3.4", "1.2.3.5"]` SHOULD be recorded as
the `rpc.request.header.my-custom-key` attribute with value `["1.2.3.4", "1.2.3.5"]`

The attribute value MUST consist of either multiple header values as an array of
strings or a single-item array containing a possibly comma-concatenated string,
depending on the way the RPC library provides access to headers.

Values that the RPC system exposes as binary data, or that are otherwise not valid
UTF-8 strings, SHOULD be base64-encoded when recorded.

**[3] `rpc.response.header.<key>`:** Instrumentations SHOULD require an explicit configuration of which headers are to be captured.
Including all response headers can be a security risk - explicit configuration helps avoid leaking sensitive information.

For example, a header `my-custom-key` with value `["attribute_value"]` SHOULD be recorded as
the `rpc.response.header.my-custom-key` attribute with value `["attribute_value"]`

The attribute value MUST consist of either multiple header values as an array of
strings or a single-item array containing a possibly comma-concatenated string,
depending on the way the RPC library provides access to headers.

Values that the RPC system exposes as binary data, or that are otherwise not valid
UTF-8 strings, SHOULD be base64-encoded when recorded.

**[4] `rpc.response.trailer.<key>`:** Instrumentations SHOULD require an explicit configuration of which trailers are to be captured.
Including all response trailers can be a security risk - explicit configuration helps avoid leaking sensitive information.

For example, a trailer `my-custom-key` with value `["attribute_value"]` SHOULD be recorded as
the `rpc.response.trailer.my-custom-key` attribute with value `["attribute_value"]`

The attribute value MUST consist of either multiple trailer values as an array of
strings or a single-item array containing a possibly comma-concatenated string,
depending on the way the RPC library provides access to trailers.

Values that the RPC system exposes as binary data, or that are otherwise not valid
UTF-8 strings, SHOULD be base64-encoded when recorded.

**[5] `rpc.status_code`:** Usually it represents an error code, but may also represent partial success, warning, or differentiate between various types of successful outcomes.
The value MAY use a standardized string representation of a numeric status code, if one exists, instead of the numeric code. The value MAY be a synthetic status provided by the client library rather than returned by the remote service.
Semantic conventions for individual RPC frameworks SHOULD document what `rpc.status_code` means in the context of that system and which values are considered to represent errors.

**[6] `rpc.system.name`:** The client and server RPC systems may differ for the same RPC interaction. For example, a client may use Apache Dubbo or Connect RPC to communicate with a server that uses gRPC since both protocols provide compatibility with gRPC.

---

<a id="rpc-system-name-values"></a>

`rpc.system.name` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.

| Value | Description | Stability |
| --- | --- | --- |
| `connectrpc` | [Connect RPC](https://connectrpc.com/) | ![Development](https://img.shields.io/badge/-development-blue) |
| `dubbo` | [Apache Dubbo](https://dubbo.apache.org/) | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
| `grpc` | [gRPC](https://grpc.io/) | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
| `jsonrpc` | [JSON-RPC](https://www.jsonrpc.org/) | ![Development](https://img.shields.io/badge/-development-blue) |

## Deprecated RPC Attributes

Deprecated rpc message attributes.

**Attributes:**

| Key | Stability | Value Type | Description | Example Values |
| --- | --- | --- | --- | --- |
| <a id="message-compressed-size" href="#message-compressed-size">`message.compressed_size`</a> | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Deprecated, no replacement at this time. | int | Deprecated, no replacement at this time. | |
| <a id="message-id" href="#message-id">`message.id`</a> | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Deprecated, no replacement at this time. | int | Deprecated, no replacement at this time. | |
| <a id="message-type" href="#message-type">`message.type`</a> | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Deprecated, no replacement at this time. | string | Deprecated, no replacement at this time. | `SENT`; `RECEIVED` [(see more)](#message-type-values) |
| <a id="message-uncompressed-size" href="#message-uncompressed-size">`message.uncompressed_size`</a> | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Deprecated, no replacement at this time. | int | Deprecated, no replacement at this time. | |
| <a id="rpc-connect-rpc-error-code" href="#rpc-connect-rpc-error-code">`rpc.connect_rpc.error_code`</a> | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `rpc.status_code`. | string | Deprecated, use `rpc.status_code` attribute instead. | `cancelled`; `unknown`; `invalid_argument` [(see more)](#rpc-connect-rpc-error-code-values) |
| <a id="rpc-connect-rpc-request-metadata" href="#rpc-connect-rpc-request-metadata">`rpc.connect_rpc.request.metadata.<key>`</a> | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `rpc.request.header`. | string[] | Deprecated, use `rpc.request.header` instead. | `["1.2.3.4", "1.2.3.5"]` |
| <a id="rpc-connect-rpc-response-metadata" href="#rpc-connect-rpc-response-metadata">`rpc.connect_rpc.response.metadata.<key>`</a> | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Split to `rpc.response.header` for metadata sent before the response payload and `rpc.response.trailer` for metadata sent after it. | string[] | Deprecated, use `rpc.response.header` and `rpc.response.trailer`. | `["attribute_value"]` |
| <a id="rpc-grpc-request-metadata" href="#rpc-grpc-request-metadata">`rpc.grpc.request.metadata.<key>`</a> | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `rpc.request.header`. | string[] | Deprecated, use `rpc.request.header` instead. | `["1.2.3.4", "1.2.3.5"]` |
| <a id="rpc-grpc-response-metadata" href="#rpc-grpc-response-metadata">`rpc.grpc.response.metadata.<key>`</a> | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Split to `rpc.response.header` for metadata sent before the response payload and `rpc.response.trailer` for metadata sent after it. | string[] | Deprecated, use `rpc.response.header` and `rpc.response.trailer`. | `["attribute_value"]` |
| <a id="rpc-grpc-status-code" href="#rpc-grpc-status-code">`rpc.grpc.status_code`</a> | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Use string representation of the gRPC status code on the `rpc.status_code` attribute. | int | Deprecated, use string representation on the `rpc.status_code` attribute instead. | `0`; `1`; `2` [(see more)](#rpc-grpc-status-code-values) |
| <a id="rpc-jsonrpc-error-code" href="#rpc-jsonrpc-error-code">`rpc.jsonrpc.error_code`</a> | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Use string representation of the error code on the `rpc.status_code` attribute. | int | Deprecated, use string representation on the `rpc.status_code` attribute instead. | `-32700`; `100` |
| <a id="rpc-jsonrpc-error-message" href="#rpc-jsonrpc-error-message">`rpc.jsonrpc.error_message`</a> | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Use the span status description when reporting JSON-RPC spans. | string | Deprecated, use the span status description when reporting JSON-RPC spans. | `Parse error`; `User already exists` |
| <a id="rpc-jsonrpc-request-id" href="#rpc-jsonrpc-request-id">`rpc.jsonrpc.request_id`</a> | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `jsonrpc.request.id`. | string | Deprecated, use `jsonrpc.request.id` instead. | `10`; `request-7`; `` |
| <a id="rpc-jsonrpc-version" href="#rpc-jsonrpc-version">`rpc.jsonrpc.version`</a> | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `jsonrpc.protocol.version`. | string | Deprecated, use `jsonrpc.protocol.version` instead. | `2.0`; `1.0` |
| <a id="rpc-message-compressed-size" href="#rpc-message-compressed-size">`rpc.message.compressed_size`</a> | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Deprecated, no replacement at this time. | int | Compressed size of the message in bytes. | |
| <a id="rpc-message-id" href="#rpc-message-id">`rpc.message.id`</a> | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Deprecated, no replacement at this time. | int | MUST be calculated as two different counters starting from `1` one for sent messages and one for received message. [7] | |
| <a id="rpc-message-type" href="#rpc-message-type">`rpc.message.type`</a> | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Deprecated, no replacement at this time. | string | Whether this is a received or sent message. | `SENT`; `RECEIVED` [(see more)](#rpc-message-type-values) |
| <a id="rpc-message-uncompressed-size" href="#rpc-message-uncompressed-size">`rpc.message.uncompressed_size`</a> | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Deprecated, no replacement at this time. | int | Uncompressed size of the message in bytes. | |
| <a id="rpc-request-metadata" href="#rpc-request-metadata">`rpc.request.metadata.<key>`</a> | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `rpc.request.header`. | string[] | Deprecated, use `rpc.request.header` instead. | `["1.2.3.4", "1.2.3.5"]` |
| <a id="rpc-response-metadata" href="#rpc-response-metadata">`rpc.response.metadata.<key>`</a> | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Split to `rpc.response.header` for metadata sent before the response payload and `rpc.response.trailer` for metadata sent after it. | string[] | Deprecated, use `rpc.response.header` and `rpc.response.trailer`. | `["attribute_value"]` |
| <a id="rpc-response-status-code" href="#rpc-response-status-code">`rpc.response.status_code`</a> | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `rpc.status_code`. | string | Deprecated, use `rpc.status_code` instead. | `OK`; `DEADLINE_EXCEEDED`; `-32602` |
| <a id="rpc-service" href="#rpc-service">`rpc.service`</a> | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Value should be included in `rpc.method` which is expected to be a fully-qualified name. | string | Deprecated, use fully-qualified `rpc.method` instead. | `myservice.EchoService` |
| <a id="rpc-system" href="#rpc-system">`rpc.system`</a> | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `rpc.system.name`. | string | Deprecated, use `rpc.system.name` attribute instead. | `grpc`; `java_rmi`; `dotnet_wcf` [(see more)](#rpc-system-values) |

**[7] `rpc.message.id`:** This way we guarantee that the values will be consistent between different implementations.

---

<a id="message-type-values"></a>

`message.type` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.

| Value | Description | Stability |
| --- | --- | --- |
| `RECEIVED` | received | ![Development](https://img.shields.io/badge/-development-blue) |
| `SENT` | sent | ![Development](https://img.shields.io/badge/-development-blue) |

---

<a id="rpc-connect-rpc-error-code-values"></a>

`rpc.connect_rpc.error_code` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.

| Value | Description | Stability |
| --- | --- | --- |
| `aborted` | aborted | ![Development](https://img.shields.io/badge/-development-blue) |
| `already_exists` | already_exists | ![Development](https://img.shields.io/badge/-development-blue) |
| `cancelled` | cancelled | ![Development](https://img.shields.io/badge/-development-blue) |
| `data_loss` | data_loss | ![Development](https://img.shields.io/badge/-development-blue) |
| `deadline_exceeded` | deadline_exceeded | ![Development](https://img.shields.io/badge/-development-blue) |
| `failed_precondition` | failed_precondition | ![Development](https://img.shields.io/badge/-development-blue) |
| `internal` | internal | ![Development](https://img.shields.io/badge/-development-blue) |
| `invalid_argument` | invalid_argument | ![Development](https://img.shields.io/badge/-development-blue) |
| `not_found` | not_found | ![Development](https://img.shields.io/badge/-development-blue) |
| `out_of_range` | out_of_range | ![Development](https://img.shields.io/badge/-development-blue) |
| `permission_denied` | permission_denied | ![Development](https://img.shields.io/badge/-development-blue) |
| `resource_exhausted` | resource_exhausted | ![Development](https://img.shields.io/badge/-development-blue) |
| `unauthenticated` | unauthenticated | ![Development](https://img.shields.io/badge/-development-blue) |
| `unavailable` | unavailable | ![Development](https://img.shields.io/badge/-development-blue) |
| `unimplemented` | unimplemented | ![Development](https://img.shields.io/badge/-development-blue) |
| `unknown` | unknown | ![Development](https://img.shields.io/badge/-development-blue) |

---

<a id="rpc-grpc-status-code-values"></a>

`rpc.grpc.status_code` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.

| Value | Description | Stability |
| --- | --- | --- |
| `0` | OK | ![Development](https://img.shields.io/badge/-development-blue) |
| `1` | CANCELLED | ![Development](https://img.shields.io/badge/-development-blue) |
| `2` | UNKNOWN | ![Development](https://img.shields.io/badge/-development-blue) |
| `3` | INVALID_ARGUMENT | ![Development](https://img.shields.io/badge/-development-blue) |
| `4` | DEADLINE_EXCEEDED | ![Development](https://img.shields.io/badge/-development-blue) |
| `5` | NOT_FOUND | ![Development](https://img.shields.io/badge/-development-blue) |
| `6` | ALREADY_EXISTS | ![Development](https://img.shields.io/badge/-development-blue) |
| `7` | PERMISSION_DENIED | ![Development](https://img.shields.io/badge/-development-blue) |
| `8` | RESOURCE_EXHAUSTED | ![Development](https://img.shields.io/badge/-development-blue) |
| `9` | FAILED_PRECONDITION | ![Development](https://img.shields.io/badge/-development-blue) |
| `10` | ABORTED | ![Development](https://img.shields.io/badge/-development-blue) |
| `11` | OUT_OF_RANGE | ![Development](https://img.shields.io/badge/-development-blue) |
| `12` | UNIMPLEMENTED | ![Development](https://img.shields.io/badge/-development-blue) |
| `13` | INTERNAL | ![Development](https://img.shields.io/badge/-development-blue) |
| `14` | UNAVAILABLE | ![Development](https://img.shields.io/badge/-development-blue) |
| `15` | DATA_LOSS | ![Development](https://img.shields.io/badge/-development-blue) |
| `16` | UNAUTHENTICATED | ![Development](https://img.shields.io/badge/-development-blue) |

---

<a id="rpc-message-type-values"></a>

`rpc.message.type` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.

| Value | Description | Stability |
| --- | --- | --- |
| `RECEIVED` | received | ![Development](https://img.shields.io/badge/-development-blue) |
| `SENT` | sent | ![Development](https://img.shields.io/badge/-development-blue) |

---

<a id="rpc-system-values"></a>

`rpc.system` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.

| Value | Description | Stability |
| --- | --- | --- |
| `apache_dubbo` | Apache Dubbo | ![Development](https://img.shields.io/badge/-development-blue) |
| `connect_rpc` | Connect RPC | ![Development](https://img.shields.io/badge/-development-blue) |
| `dotnet_wcf` | .NET WCF | ![Development](https://img.shields.io/badge/-development-blue) |
| `grpc` | gRPC | ![Development](https://img.shields.io/badge/-development-blue) |
| `java_rmi` | Java RMI | ![Development](https://img.shields.io/badge/-development-blue) |
| `jsonrpc` | JSON-RPC | ![Development](https://img.shields.io/badge/-development-blue) |
| `onc_rpc` | [ONC RPC (Sun RPC)](https://datatracker.ietf.org/doc/html/rfc5531) | ![Development](https://img.shields.io/badge/-development-blue) |
