Skip to content

Commit

Permalink
Consider X-Forwarded-Host / Forwarded when capturing server.address a…
Browse files Browse the repository at this point in the history
…nd server.port
  • Loading branch information
trask committed Oct 16, 2023
1 parent cee22ec commit c26fbcf
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ release.

- BREAKING: Rename http.resend_count to http.request.resend_count.
([#374](https://github.com/open-telemetry/semantic-conventions/pull/374))
- BREAKING: Consider `X-Forwarded-Host` / `Forwarded` when capturing `server.address` and `server.port`.
([#411](https://github.com/open-telemetry/semantic-conventions/pull/411))

### Features

Expand Down
20 changes: 18 additions & 2 deletions docs/http/http-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ SHOULD include the [application root](/docs/http/http-spans.md#http-server-defin
include host identifier.
- Host identifier of the [request target](https://www.rfc-editor.org/rfc/rfc9110.html#target.resource)
if it's sent in absolute-form.
- Host identifier of [Forwarded#host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Forwarded#host),
[X-Forwarded-Host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host), or a similar header.
- Host identifier of the `Host` header

SHOULD NOT be set if only IP address is available and capturing name would require a reverse DNS lookup.
Expand All @@ -140,6 +142,8 @@ SHOULD NOT be set if only IP address is available and capturing name would requi
- Port identifier of the [primary server host](/docs/http/http-spans.md#http-server-definitions) of the matched virtual host.
- Port identifier of the [request target](https://www.rfc-editor.org/rfc/rfc9110.html#target.resource)
if it's sent in absolute-form.
- Host identifier of [Forwarded#host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Forwarded#host),
[X-Forwarded-Host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host), or a similar header.
- Port identifier of the `Host` header

`error.type` has the following list of well-known values. If one of them applies, then the respective value MUST be used, otherwise a custom value MAY be used.
Expand Down Expand Up @@ -205,21 +209,25 @@ Tracing instrumentations that do so, MUST also set `http.request.method_original
include host identifier.
- Host identifier of the [request target](https://www.rfc-editor.org/rfc/rfc9110.html#target.resource)
if it's sent in absolute-form.
- Host identifier of [Forwarded#host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Forwarded#host),
[X-Forwarded-Host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host), or a similar header.
- Host identifier of the `Host` header

SHOULD NOT be set if only IP address is available and capturing name would require a reverse DNS lookup.

Warning: since this attribute may be based on the `Host` header, opting in to it may allow an attacker
Warning: since this attribute may be based on HTTP headers, opting in to it may allow an attacker
to trigger cardinality limits, degrading the usefulness of the metric.

**[3]:** Determined by using the first of the following that applies

- Port identifier of the [primary server host](/docs/http/http-spans.md#http-server-definitions) of the matched virtual host.
- Port identifier of the [request target](https://www.rfc-editor.org/rfc/rfc9110.html#target.resource)
if it's sent in absolute-form.
- Host identifier of [Forwarded#host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Forwarded#host),
[X-Forwarded-Host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host), or a similar header.
- Port identifier of the `Host` header

Warning: since this attribute may be based on the `Host` header, opting in to it may allow an attacker
Warning: since this attribute may be based on HTTP headers, opting in to it may allow an attacker
to trigger cardinality limits, degrading the usefulness of the metric.

`http.request.method` has the following list of well-known values. If one of them applies, then the respective value MUST be used, otherwise a custom value MAY be used.
Expand Down Expand Up @@ -310,6 +318,8 @@ SHOULD include the [application root](/docs/http/http-spans.md#http-server-defin
include host identifier.
- Host identifier of the [request target](https://www.rfc-editor.org/rfc/rfc9110.html#target.resource)
if it's sent in absolute-form.
- Host identifier of [Forwarded#host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Forwarded#host),
[X-Forwarded-Host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host), or a similar header.
- Host identifier of the `Host` header

SHOULD NOT be set if only IP address is available and capturing name would require a reverse DNS lookup.
Expand All @@ -319,6 +329,8 @@ SHOULD NOT be set if only IP address is available and capturing name would requi
- Port identifier of the [primary server host](/docs/http/http-spans.md#http-server-definitions) of the matched virtual host.
- Port identifier of the [request target](https://www.rfc-editor.org/rfc/rfc9110.html#target.resource)
if it's sent in absolute-form.
- Host identifier of [Forwarded#host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Forwarded#host),
[X-Forwarded-Host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host), or a similar header.
- Port identifier of the `Host` header

`error.type` has the following list of well-known values. If one of them applies, then the respective value MUST be used, otherwise a custom value MAY be used.
Expand Down Expand Up @@ -415,6 +427,8 @@ SHOULD include the [application root](/docs/http/http-spans.md#http-server-defin
include host identifier.
- Host identifier of the [request target](https://www.rfc-editor.org/rfc/rfc9110.html#target.resource)
if it's sent in absolute-form.
- Host identifier of [Forwarded#host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Forwarded#host),
[X-Forwarded-Host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host), or a similar header.
- Host identifier of the `Host` header

SHOULD NOT be set if only IP address is available and capturing name would require a reverse DNS lookup.
Expand All @@ -424,6 +438,8 @@ SHOULD NOT be set if only IP address is available and capturing name would requi
- Port identifier of the [primary server host](/docs/http/http-spans.md#http-server-definitions) of the matched virtual host.
- Port identifier of the [request target](https://www.rfc-editor.org/rfc/rfc9110.html#target.resource)
if it's sent in absolute-form.
- Host identifier of [Forwarded#host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Forwarded#host),
[X-Forwarded-Host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host), or a similar header.
- Port identifier of the `Host` header

`error.type` has the following list of well-known values. If one of them applies, then the respective value MUST be used, otherwise a custom value MAY be used.
Expand Down
4 changes: 4 additions & 0 deletions docs/http/http-spans.md
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ SHOULD include the [application root](/docs/http/http-spans.md#http-server-defin
include host identifier.
- Host identifier of the [request target](https://www.rfc-editor.org/rfc/rfc9110.html#target.resource)
if it's sent in absolute-form.
- Host identifier of [Forwarded#host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Forwarded#host),
[X-Forwarded-Host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host), or a similar header.
- Host identifier of the `Host` header

SHOULD NOT be set if only IP address is available and capturing name would require a reverse DNS lookup.
Expand All @@ -402,6 +404,8 @@ SHOULD NOT be set if only IP address is available and capturing name would requi
- Port identifier of the [primary server host](/docs/http/http-spans.md#http-server-definitions) of the matched virtual host.
- Port identifier of the [request target](https://www.rfc-editor.org/rfc/rfc9110.html#target.resource)
if it's sent in absolute-form.
- Host identifier of [Forwarded#host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Forwarded#host),
[X-Forwarded-Host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host), or a similar header.
- Port identifier of the `Host` header

**[6]:** If not default (`80` for `http` scheme, `443` for `https`).
Expand Down
6 changes: 6 additions & 0 deletions model/http-common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,12 @@ groups:
include host identifier.
- Host identifier of the [request target](https://www.rfc-editor.org/rfc/rfc9110.html#target.resource)
if it's sent in absolute-form.
- Host identifier of [Forwarded#host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Forwarded#host),
[X-Forwarded-Host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host), or a similar header.
- Host identifier of the `Host` header
MUST NOT include the port identifier.
SHOULD NOT be set if only IP address is available and capturing name would require a reverse DNS lookup.
- ref: server.port
Expand All @@ -94,6 +98,8 @@ groups:
- Port identifier of the [primary server host](/docs/http/http-spans.md#http-server-definitions) of the matched virtual host.
- Port identifier of the [request target](https://www.rfc-editor.org/rfc/rfc9110.html#target.resource)
if it's sent in absolute-form.
- Port identifier of [Forwarded#host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Forwarded#host),
[X-Forwarded-Host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host), or a similar header.
- Port identifier of the `Host` header
requirement_level:
conditionally_required: If not default (`80` for `http` scheme, `443` for `https`).
Expand Down
13 changes: 9 additions & 4 deletions model/metrics/http.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,18 @@ groups:
note: |
Determined by using the first of the following that applies
- The [primary server name](/docs/http/http-spans.md#http-server-definitions) of the matched virtual host. MUST only
include host identifier.
- The [primary server name](/docs/http/http-spans.md#http-server-definitions) of the matched virtual host.
- Host identifier of the [request target](https://www.rfc-editor.org/rfc/rfc9110.html#target.resource)
if it's sent in absolute-form.
- Host identifier of [Forwarded#host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Forwarded#host),
[X-Forwarded-Host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host), or a similar header.
- Host identifier of the `Host` header
MUST NOT include the port identifier.
SHOULD NOT be set if only IP address is available and capturing name would require a reverse DNS lookup.
Warning: since this attribute may be based on the `Host` header, opting in to it may allow an attacker
Warning: since this attribute may be based on HTTP headers, opting in to it may allow an attacker
to trigger cardinality limits, degrading the usefulness of the metric.
- ref: server.port
Expand All @@ -65,9 +68,11 @@ groups:
- Port identifier of the [primary server host](/docs/http/http-spans.md#http-server-definitions) of the matched virtual host.
- Port identifier of the [request target](https://www.rfc-editor.org/rfc/rfc9110.html#target.resource)
if it's sent in absolute-form.
- Port identifier of [Forwarded#host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Forwarded#host),
[X-Forwarded-Host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host), or a similar header.
- Port identifier of the `Host` header
Warning: since this attribute may be based on the `Host` header, opting in to it may allow an attacker
Warning: since this attribute may be based on HTTP headers, opting in to it may allow an attacker
to trigger cardinality limits, degrading the usefulness of the metric.
- id: metric.http.server.request.body.size
Expand Down

0 comments on commit c26fbcf

Please sign in to comment.