Skip to content

Commit 30402c4

Browse files
authored
Add experimental HTTP attributes to HTTP spans (open-telemetry#989)
1 parent 70baddd commit 30402c4

File tree

3 files changed

+72
-3
lines changed

3 files changed

+72
-3
lines changed

.chloggen/989.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
change_type: enhancement
2+
3+
component: http
4+
5+
note: List experimental HTTP attributes applicable to HTTP client and server spans.
6+
7+
issues: [989]

docs/http/http-spans.md

+35-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ linkTitle: Spans
44

55
# Semantic Conventions for HTTP Spans
66

7-
**Status**: [Stable][DocumentStatus]
7+
**Status**: [Stable][DocumentStatus], Unless otherwise specified.
88

99
This document defines semantic conventions for HTTP client and server Spans.
1010
They can be used for http and https schemes
@@ -17,14 +17,16 @@ and various HTTP versions like 1.1, 2 and SPDY.
1717
- [Name](#name)
1818
- [Status](#status)
1919
- [HTTP client](#http-client)
20+
- [HTTP client experimental attributes](#http-client-experimental-attributes)
2021
- [HTTP client span duration](#http-client-span-duration)
2122
- [HTTP request retries and redirects](#http-request-retries-and-redirects)
2223
- [HTTP server](#http-server)
2324
- [HTTP server definitions](#http-server-definitions)
2425
- [Setting `server.address` and `server.port` attributes](#setting-serveraddress-and-serverport-attributes)
2526
- [Simple client/server example](#simple-clientserver-example)
2627
- [Client/server example with reverse proxy](#clientserver-example-with-reverse-proxy)
27-
- [HTTP Server semantic conventions](#http-server-semantic-conventions)
28+
- [HTTP server semantic conventions](#http-server-semantic-conventions)
29+
- [HTTP server experimental attributes](#http-server-experimental-attributes)
2830
- [Examples](#examples)
2931
- [HTTP client-server example](#http-client-server-example)
3032
- [HTTP client retries examples](#http-client-retries-examples)
@@ -240,6 +242,21 @@ The following attributes can be important for making sampling decisions and SHOU
240242
| `unix` | Unix domain socket | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
241243
<!-- endsemconv -->
242244

245+
### HTTP client experimental attributes
246+
247+
**Status**: [Experimental][DocumentStatus]
248+
249+
Instrumentations MAY allow users to enable additional experimental attributes.
250+
251+
<!-- semconv trace.http.client.experimental(full) -->
252+
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
253+
|---|---|---|---|---|---|
254+
| [`http.request.body.size`](/docs/attributes-registry/http.md) | int | The size of the request 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://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) header. For requests using transport encoding, this should be the compressed size. | `3495` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
255+
| [`http.request.size`](/docs/attributes-registry/http.md) | int | The total size of the request in bytes. This should be the total number of bytes sent over the wire, including the request line (HTTP/1.1), framing (HTTP/2 and HTTP/3), headers, and request body if any. | `1437` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
256+
| [`http.response.body.size`](/docs/attributes-registry/http.md) | 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://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) header. For requests using transport encoding, this should be the compressed size. | `3495` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
257+
| [`http.response.size`](/docs/attributes-registry/http.md) | int | The total size of the response in bytes. This should be the total number of bytes sent over the wire, including the status line (HTTP/1.1), framing (HTTP/2 and HTTP/3), headers, and response body and trailers if any. | `1437` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
258+
<!-- endsemconv -->
259+
243260
### HTTP client span duration
244261

245262
There are some minimal constraints that SHOULD be honored:
@@ -314,7 +331,7 @@ Application developers MAY overwrite potentially inaccurate values of `server.*`
314331
[Forwarded#host]: https://developer.mozilla.org/docs/Web/HTTP/Headers/Forwarded#host
315332
[X-Forwarded-Host]: https://developer.mozilla.org/docs/Web/HTTP/Headers/X-Forwarded-Host
316333

317-
### HTTP Server semantic conventions
334+
### HTTP server semantic conventions
318335

319336
This span type represents an inbound HTTP request.
320337

@@ -458,6 +475,21 @@ The following attributes can be important for making sampling decisions and SHOU
458475

459476
`http.route` MUST be provided at span creation time if and only if it's already available. If it becomes available after span starts, instrumentation MUST populate it anytime before span ends.
460477

478+
### HTTP server experimental attributes
479+
480+
**Status**: [Experimental][DocumentStatus]
481+
482+
Instrumentations MAY allow users to enable additional experimental attributes.
483+
484+
<!-- semconv trace.http.server.experimental(full) -->
485+
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
486+
|---|---|---|---|---|---|
487+
| [`http.request.body.size`](/docs/attributes-registry/http.md) | int | The size of the request 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://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) header. For requests using transport encoding, this should be the compressed size. | `3495` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
488+
| [`http.request.size`](/docs/attributes-registry/http.md) | int | The total size of the request in bytes. This should be the total number of bytes sent over the wire, including the request line (HTTP/1.1), framing (HTTP/2 and HTTP/3), headers, and request body if any. | `1437` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
489+
| [`http.response.body.size`](/docs/attributes-registry/http.md) | 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://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) header. For requests using transport encoding, this should be the compressed size. | `3495` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
490+
| [`http.response.size`](/docs/attributes-registry/http.md) | int | The total size of the response in bytes. This should be the total number of bytes sent over the wire, including the status line (HTTP/1.1), framing (HTTP/2 and HTTP/3), headers, and response body and trailers if any. | `1437` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
491+
<!-- endsemconv -->
492+
461493
## Examples
462494

463495
### HTTP client-server example

model/trace/http.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ groups:
44
extends: attributes.http.client
55
span_kind: client
66
brief: 'Semantic Convention for HTTP Client'
7+
stability: stable
78
attributes:
89
- ref: http.request.method
910
sampling_relevant: true
@@ -37,11 +38,26 @@ groups:
3738
Generally `tcp` for `HTTP/1.0`, `HTTP/1.1`, and `HTTP/2`. Generally `udp` for `HTTP/3`.
3839
Other obscure implementations are possible.
3940
41+
- id: trace.http.client.experimental
42+
type: attribute_group
43+
brief: 'Experimental attributes for HTTP Client spans'
44+
stability: experimental
45+
attributes:
46+
- ref: http.request.size
47+
requirement_level: opt_in
48+
- ref: http.response.size
49+
requirement_level: opt_in
50+
- ref: http.request.body.size
51+
requirement_level: opt_in
52+
- ref: http.response.body.size
53+
requirement_level: opt_in
54+
4055
- id: trace.http.server
4156
type: span
4257
extends: attributes.http.server
4358
span_kind: server
4459
brief: 'Semantic Convention for HTTP Server'
60+
stability: stable
4561
attributes:
4662
- ref: http.request.method
4763
sampling_relevant: true
@@ -95,3 +111,17 @@ groups:
95111
note: >
96112
Generally `tcp` for `HTTP/1.0`, `HTTP/1.1`, and `HTTP/2`. Generally `udp` for `HTTP/3`.
97113
Other obscure implementations are possible.
114+
115+
- id: trace.http.server.experimental
116+
type: attribute_group
117+
brief: 'Experimental attributes for HTTP Server spans'
118+
stability: experimental
119+
attributes:
120+
- ref: http.request.size
121+
requirement_level: opt_in
122+
- ref: http.response.size
123+
requirement_level: opt_in
124+
- ref: http.request.body.size
125+
requirement_level: opt_in
126+
- ref: http.response.body.size
127+
requirement_level: opt_in

0 commit comments

Comments
 (0)