Skip to content

Commit

Permalink
trace/http: Add http.{request,response}.size attributes
Browse files Browse the repository at this point in the history
These attributes are the number of bytes in the request or response,
including control data, headers, body, and trailers. The names were
chosen by taking the [ECS HTTP fields] and replacing `bytes` with
`size`, as for `http.request.content.size`.

closes #38

[ECS HTTP fields]: https://www.elastic.co/guide/en/ecs/current/ecs-http.html
  • Loading branch information
kamalmarhubi committed Feb 9, 2024
1 parent 44c830d commit 043d590
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .chloggen/http-request-response-size.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Use this changelog template to create an entry for release notes.
#
# If your change doesn't affect end users you should instead start
# your pull request title with [chore] or use the "Skip Changelog" label.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the area of concern in the attributes-registry, (e.g. http, cloud, db)
component: http

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add `http.request.size` and `http.response.size` attributes for the total number of bytes in http messages

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
# The values here must be integers.
issues: [38, 84]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
2 changes: 2 additions & 0 deletions docs/attributes-registry/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
| `http.request.method` | string | ![Stable](https://img.shields.io/badge/-stable-lightgreen)<br>HTTP request method. [2] | `GET`; `POST`; `HEAD` |
| `http.request.method_original` | string | ![Stable](https://img.shields.io/badge/-stable-lightgreen)<br>Original HTTP method sent by the client in the request line. | `GeT`; `ACL`; `foo` |
| `http.request.resend_count` | int | ![Stable](https://img.shields.io/badge/-stable-lightgreen)<br>The ordinal number of request resending attempt (for any reason, including redirects). [3] | `3` |
| `http.request.size` | int | The total size of the request in bytes. This should be the total number of bytes sent over the wire, and includes all framing and control data, headers, and request body if any. For requests using transport encoding, this should include the compressed body size as sent over the wire. | `1437` |
| `http.response.body.size` | 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` |
| `http.response.header.<key>` | string[] | ![Stable](https://img.shields.io/badge/-stable-lightgreen)<br>HTTP response headers, `<key>` being the normalized HTTP Header name (lowercase), the value being the header values. [4] | `http.response.header.content-type=["application/json"]`; `http.response.header.my-custom-header=["abc", "def"]` |
| `http.response.size` | int | The total size of the response in bytes. This should be the total number of bytes sent over the wire, and includes all framing and control data, headers, and response body and trailers if any. For responses using transport encoding, this should include the compressed body size as sent over the wire. | `1437` |
| `http.response.status_code` | int | ![Stable](https://img.shields.io/badge/-stable-lightgreen)<br>[HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). | `200` |
| `http.route` | string | ![Stable](https://img.shields.io/badge/-stable-lightgreen)<br>The matched route, that is, the path template in the format used by the respective server framework. [5] | `/users/:userID?`; `{controller}/{action}/{id?}` |

Expand Down
13 changes: 13 additions & 0 deletions model/registry/http.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ groups:
was the cause of the resending (e.g. redirection, authorization failure, 503 Server Unavailable, network issues,
or any other).
examples: 3
- id: request.size
type: int
brief: >
The total size of the request in bytes. This should be the total number of bytes sent over the wire, and includes all framing and control
data, headers, and request body if any.
examples: 1437
- id: response.body.size
type: int
brief: >
Expand All @@ -118,6 +124,13 @@ groups:
or a single-item array containing a possibly comma-concatenated string, depending on the way
the HTTP library provides access to headers.
examples: ['http.response.header.content-type=["application/json"]', 'http.response.header.my-custom-header=["abc", "def"]']
- id: response.size
type: int
brief: >
The total size of the response in bytes. This should be the total number of bytes sent over the wire, and includes all framing and control
data, headers, and response body and trailers if any.
as sent over the wire.
examples: 1437
- id: response.status_code
stability: stable
type: int
Expand Down

0 comments on commit 043d590

Please sign in to comment.