Skip to content

Commit b70565d

Browse files
anuraagaarminruOberon00
authored
Add peer.service semantic convention to indicate the name of a target… (open-telemetry#652)
* Add peer.service semantic convention to indicate the name of a target remote service. * Apply suggestions from code review Co-authored-by: Armin Ruech <[email protected]> * Simplify * Remove fallback wording * Needs to be configured using instrumentation * CHANGELOG * Clarify relationship with rpc.service and peer.service and some examples * Clarify example * Move peer.service / rpc.service relationship explanation to rpc doc. * Apply suggestions from code review Co-authored-by: Christian Neumüller <[email protected]> * Update specification/trace/semantic_conventions/span-general.md Co-authored-by: Christian Neumüller <[email protected]> * Cleanup * Tweak * Update specification/trace/semantic_conventions/rpc.md Co-authored-by: Armin Ruech <[email protected]> * Update CHANGELOG.md Co-authored-by: Armin Ruech <[email protected]> * Apply suggestions from code review Co-authored-by: Armin Ruech <[email protected]> * Update specification/trace/semantic_conventions/span-general.md Co-authored-by: Armin Ruech <[email protected]> * TOC * Apply suggestions from code review Co-authored-by: Armin Ruech <[email protected]> Co-authored-by: Armin Ruech <[email protected]> Co-authored-by: Christian Neumüller <[email protected]>
1 parent 4daee3a commit b70565d

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ the release.
1616
* Configuration should be stored not per Tracer but in the TracerProvider.
1717
* Active spans are not per Tracer.
1818
- Add semantic conventions for process resource.
19+
- Add peer.service to provide a user-configured name for a remote service
1920

2021
## v0.5.0 (06-02-2020)
2122

specification/trace/semantic_conventions/rpc.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,19 @@ Furthermore, setting [net.transport][] is required for non-IP connection like na
6565

6666
#### Service name
6767

68-
On the server process receiving and handling the remote procedure call, the service name provided in `rpc.service` does not necessarily have to match the [`service.name` resource attribute][]. One process can expose multiple RPC endpoints and thus have multiple RPC service names. From a deployment perspective, as expressed by the `service.*` resource attributes, it will be treated as one deployed service with one `service.name`.
68+
On the server process receiving and handling the remote procedure call, the service name provided in `rpc.service` does not necessarily have to match the [`service.name`][] resource attribute.
69+
One process can expose multiple RPC endpoints and thus have multiple RPC service names. From a deployment perspective, as expressed by the `service.*` resource attributes, it will be treated as one deployed service with one `service.name`.
70+
Likewise, on clients sending RPC requests to a server, the service name provided in `rpc.service` does not have to match the [`peer.service`][] span attribute.
6971

7072
As an example, given a process deployed as `QuoteService`, this would be the name that goes into the `service.name` resource attribute which applies to the entire process.
7173
This process could expose two RPC endpoints, one called `CurrencyQuotes` (= `rpc.service`) with a method called `getMeanRate` (= `rpc.method`) and the other endpoint called `StockQuotes` (= `rpc.service`) with two methods `getCurrentBid` and `getLastClose` (= `rpc.method`).
74+
In this example, spans representing client request should have their `peer.service` attribute set to `QuoteService` as well to match the server's `service.name` resource attribute.
75+
Generally, a user SHOULD NOT set `peer.service` to a fully qualified RPC service name.
7276

7377
[network attributes]: span-general.md#general-network-connection-attributes
7478
[net.transport]: span-general.md#nettransport-attribute
75-
[`service.name` resource attribute]: ../../resource/semantic_conventions/README.md#service
79+
[`service.name`]: ../../resource/semantic_conventions/README.md#service
80+
[`peer.service`]: span-general.md#general-remote-service-attributes
7681

7782
### Distinction from HTTP spans
7883

specification/trace/semantic_conventions/span-general.md

+17
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ Particular operations may refer to or require some of these attributes.
99
<!-- toc -->
1010

1111
- [General network connection attributes](#general-network-connection-attributes)
12+
* [`net.transport` attribute](#nettransport-attribute)
13+
* [`net.*.name` attributes](#netname-attributes)
14+
- [General remote service attributes](#general-remote-service-attributes)
1215
- [General identity attributes](#general-identity-attributes)
1316

1417
<!-- tocstop -->
@@ -67,6 +70,20 @@ If `net.transport` is `"unix"` or `"pipe"`, the absolute path to the file repres
6770
If there is no such file (e.g., anonymous pipe),
6871
the name should explicitly be set to the empty string to distinguish it from the case where the name is just unknown or not covered by the instrumentation.
6972

73+
## General remote service attributes
74+
75+
This attribute may be used for any operation that accesses some remote service.
76+
Users can define what the name of a service is based on their particular semantics in their distributed system.
77+
Instrumentations SHOULD provide a way for users to configure this name.
78+
79+
| Attribute name | Notes and examples |
80+
| :-------------- | :-------------------------------------------------------------------------------- |
81+
| `peer.service` | The [`service.name`](../../resource/semantic_conventions/README.md#service) of the remote service. SHOULD be equal to the actual `service.name` resource attribute of the remote service if any. |
82+
83+
Examples of `peer.service` that users may specify:
84+
- A Redis cache of auth tokens as `peer.service="AuthTokenCache"`.
85+
- A gRPC service `rpc.service="io.opentelemetry.AuthService"` may be hosted in both a gateway, `peer.service="ExternalApiService"` and a backend, `peer.service="AuthService"`.
86+
7087
## General identity attributes
7188

7289
These attributes may be used for any operation with an authenticated and/or authorized enduser.

0 commit comments

Comments
 (0)