From f34abb07ee8b8e102ab4693d9d6cef1aad95fb2b Mon Sep 17 00:00:00 2001 From: Liudmila Molkova Date: Thu, 9 Sep 2021 09:37:30 -0700 Subject: [PATCH] Define HTTP attributes that should be provided at span creation time --- CHANGELOG.md | 3 +++ semantic_conventions/trace/http.yaml | 11 +++++++++++ specification/trace/semantic_conventions/http.md | 14 ++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 774dd8ee067..7881d96e979 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,9 @@ release. - Don't set Span.Status for 4xx http status codes for SERVER spans. ([#1998](https://github.com/open-telemetry/opentelemetry-specification/pull/1998)) +- Define http tracing attributes provided at span creation time + ([#1919](https://github.com/open-telemetry/opentelemetry-specification/pull/1916)) + ### Compatibility ### OpenTelemetry Protocol diff --git a/semantic_conventions/trace/http.yaml b/semantic_conventions/trace/http.yaml index 55b81f433ce..20adebca11c 100644 --- a/semantic_conventions/trace/http.yaml +++ b/semantic_conventions/trace/http.yaml @@ -10,6 +10,7 @@ groups: type: string required: always brief: 'HTTP request method.' + sampling_relevant: true examples: ["GET", "POST", "HEAD"] - id: url type: string @@ -19,10 +20,12 @@ groups: note: > `http.url` MUST NOT contain credentials passed via URL in form of `https://username:password@www.example.com/`. In such case the attribute's value should be `https://www.example.com/`. + sampling_relevant: true examples: ['https://www.foo.bar/search?q=OpenTelemetry#SemConv'] - id: target type: string brief: 'The full request target as passed in a HTTP request line or equivalent.' + sampling_relevant: true examples: ['/path/12314/?q=ddds#123'] - id: host type: string @@ -35,10 +38,12 @@ groups: in certain cases, according the aforementioned [section of RFC 7230](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is not set the attribute MUST NOT be set. + sampling_relevant: true examples: ['www.example.org'] - id: scheme type: string brief: 'The URI scheme identifying the used protocol.' + sampling_relevant: true examples: ["http", "https"] - id: status_code type: int @@ -99,6 +104,12 @@ groups: brief: > The size of the uncompressed response payload body after transport decoding. Not set if transport encoding not used. examples: 5493 + - ref: net.peer.name + sampling_relevant: true + - ref: net.peer.ip + sampling_relevant: true + - ref: net.peer.port + sampling_relevant: true constraints: - include: network diff --git a/specification/trace/semantic_conventions/http.md b/specification/trace/semantic_conventions/http.md index b5050a783e8..348ea10044d 100644 --- a/specification/trace/semantic_conventions/http.md +++ b/specification/trace/semantic_conventions/http.md @@ -71,6 +71,9 @@ Don't set the span status description if the reason can be inferred from `http.s | `http.request_content_length_uncompressed` | int | The size of the uncompressed request payload body after transport decoding. Not set if transport encoding not used. | `5493` | No | | `http.response_content_length` | int | The size of the response payload body in bytes. This is the number of bytes transferred excluding headers and is often, but not always, present as the [Content-Length](https://tools.ietf.org/html/rfc7230#section-3.3.2) header. For requests using transport encoding, this should be the compressed size. | `3495` | No | | `http.response_content_length_uncompressed` | int | The size of the uncompressed response payload body after transport decoding. Not set if transport encoding not used. | `5493` | No | +| [`net.peer.ip`](span-general.md) | string | Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6) | `127.0.0.1` | No | +| [`net.peer.name`](span-general.md) | string | Remote hostname or similar, see note below. | `example.com` | No | +| [`net.peer.port`](span-general.md) | int | Remote port number. | `80`; `8080`; `443` | No | **[1]:** `http.url` MUST NOT contain credentials passed via URL in form of `https://username:password@www.example.com/`. In such case the attribute's value should be `https://www.example.com/`. @@ -87,6 +90,17 @@ Don't set the span status description if the reason can be inferred from `http.s | `2.0` | HTTP 2 | | `SPDY` | SPDY protocol. | | `QUIC` | QUIC protocol. | + +Following attributes MUST be provided **at span creation time** (when provided at all): + +* `http.method` +* `http.url` +* `http.target` +* `http.host` +* `http.scheme` +* [`net.peer.ip`](span-general.md) +* [`net.peer.name`](span-general.md) +* [`net.peer.port`](span-general.md) It is recommended to also use the general [network attributes][], especially `net.peer.ip`. If `net.transport` is not specified, it can be assumed to be `IP.TCP` except if `http.flavor` is `QUIC`, in which case `IP.UDP` is assumed.