Skip to content

Commit

Permalink
Define HTTP attributes that should be provided at span creation time
Browse files Browse the repository at this point in the history
  • Loading branch information
lmolkova committed Oct 12, 2021
1 parent 639c744 commit f34abb0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions semantic_conventions/trace/http.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ groups:
type: string
required: always
brief: 'HTTP request method.'
sampling_relevant: true
examples: ["GET", "POST", "HEAD"]
- id: url
type: string
Expand All @@ -19,10 +20,12 @@ groups:
note: >
`http.url` MUST NOT contain credentials passed via URL in form of `https://username:[email protected]/`.
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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions specification/trace/semantic_conventions/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:[email protected]/`. In such case the attribute's value should be `https://www.example.com/`.

Expand All @@ -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)
<!-- endsemconv -->

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.
Expand Down

0 comments on commit f34abb0

Please sign in to comment.