Semantic Conventions for HTTP Metrics

Status: Experimental

The conventions described in this section are HTTP specific. When HTTP operations occur, metric events about those operations will be generated and reported to provide insight into the operations. By adding HTTP attributes to metric events it allows for finely tuned filtering.

Disclaimer: These are initial HTTP metric instruments and attributes but more may be added in the future.

HTTP Server

Metric: http.server.duration

This metric is required.

NameInstrument TypeUnit (UCUM)Description
http.server.durationHistogrammsMeasures the duration of inbound HTTP requests.
AttributeTypeDescriptionExamplesRequirement Level
http.flavorstringKind of HTTP protocol used. [1]1.0Recommended
http.methodstringHTTP request method.GET; POST; HEADRequired
http.routestringThe matched route (path template in the format used by the respective server framework). See note below [2]/users/:userID?; {controller}/{action}/{id?}Conditionally Required: If and only if it’s available
http.schemestringThe URI scheme identifying the used protocol.http; httpsRequired
http.status_codeintHTTP response status code.200Conditionally Required: If and only if one was received/sent.
net.host.namestringName of the local HTTP server that received the request. [3]localhostRequired
net.host.portintPort of the local HTTP server that received the request. [4]8080Conditionally Required: [5]

[1]: 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.

[2]: MUST NOT be populated when this is not supported by the HTTP server framework as the route attribute should have low-cardinality and the URI path can NOT substitute it. SHOULD include the application root if there is one.

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

  • The primary server name of the matched virtual host. MUST only include host identifier.
  • Host identifier of the request target if it’s sent in absolute-form.
  • 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.

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

  • Port identifier of the primary server host of the matched virtual host.
  • Port identifier of the request target if it’s sent in absolute-form.
  • Port identifier of the Host header

[5]: If not default (80 for http scheme, 443 for https).

Metric: http.server.active_requests

This metric is optional.

NameInstrument TypeUnit (UCUM)Description
http.server.active_requestsUpDownCounter{requests}Measures the number of concurrent HTTP requests that are currently in-flight.
AttributeTypeDescriptionExamplesRequirement Level
http.flavorstringKind of HTTP protocol used. [1]1.0Recommended
http.methodstringHTTP request method.GET; POST; HEADRequired
http.schemestringThe URI scheme identifying the used protocol.http; httpsRequired
net.host.namestringName of the local HTTP server that received the request. [2]localhostRequired
net.host.portintPort of the local HTTP server that received the request. [3]8080Conditionally Required: [4]

[1]: 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.

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

  • The primary server name of the matched virtual host. MUST only include host identifier.
  • Host identifier of the request target if it’s sent in absolute-form.
  • 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.

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

  • Port identifier of the primary server host of the matched virtual host.
  • Port identifier of the request target if it’s sent in absolute-form.
  • Port identifier of the Host header

[4]: If not default (80 for http scheme, 443 for https).

Metric: http.server.request.size

This metric is optional.

NameInstrument TypeUnit (UCUM)Description
http.server.request.sizeHistogramByMeasures the size of HTTP request messages (compressed).
AttributeTypeDescriptionExamplesRequirement Level
http.flavorstringKind of HTTP protocol used. [1]1.0Recommended
http.methodstringHTTP request method.GET; POST; HEADRequired
http.routestringThe matched route (path template in the format used by the respective server framework). See note below [2]/users/:userID?; {controller}/{action}/{id?}Conditionally Required: If and only if it’s available
http.schemestringThe URI scheme identifying the used protocol.http; httpsRequired
http.status_codeintHTTP response status code.200Conditionally Required: If and only if one was received/sent.
net.host.namestringName of the local HTTP server that received the request. [3]localhostRequired
net.host.portintPort of the local HTTP server that received the request. [4]8080Conditionally Required: [5]

[1]: 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.

[2]: MUST NOT be populated when this is not supported by the HTTP server framework as the route attribute should have low-cardinality and the URI path can NOT substitute it. SHOULD include the application root if there is one.

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

  • The primary server name of the matched virtual host. MUST only include host identifier.
  • Host identifier of the request target if it’s sent in absolute-form.
  • 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.

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

  • Port identifier of the primary server host of the matched virtual host.
  • Port identifier of the request target if it’s sent in absolute-form.
  • Port identifier of the Host header

[5]: If not default (80 for http scheme, 443 for https).

Metric: http.server.response.size

This metric is optional.

NameInstrument TypeUnit (UCUM)Description
http.server.response.sizeHistogramByMeasures the size of HTTP response messages (compressed).
AttributeTypeDescriptionExamplesRequirement Level
http.flavorstringKind of HTTP protocol used. [1]1.0Recommended
http.methodstringHTTP request method.GET; POST; HEADRequired
http.routestringThe matched route (path template in the format used by the respective server framework). See note below [2]/users/:userID?; {controller}/{action}/{id?}Conditionally Required: If and only if it’s available
http.schemestringThe URI scheme identifying the used protocol.http; httpsRequired
http.status_codeintHTTP response status code.200Conditionally Required: If and only if one was received/sent.
net.host.namestringName of the local HTTP server that received the request. [3]localhostRequired
net.host.portintPort of the local HTTP server that received the request. [4]8080Conditionally Required: [5]

[1]: 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.

[2]: MUST NOT be populated when this is not supported by the HTTP server framework as the route attribute should have low-cardinality and the URI path can NOT substitute it. SHOULD include the application root if there is one.

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

  • The primary server name of the matched virtual host. MUST only include host identifier.
  • Host identifier of the request target if it’s sent in absolute-form.
  • 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.

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

  • Port identifier of the primary server host of the matched virtual host.
  • Port identifier of the request target if it’s sent in absolute-form.
  • Port identifier of the Host header

[5]: If not default (80 for http scheme, 443 for https).

HTTP Client

Metric: http.client.duration

This metric is required.

NameInstrument TypeUnit (UCUM)Description
http.client.durationHistogrammsMeasures the duration of outbound HTTP requests.
AttributeTypeDescriptionExamplesRequirement Level
http.flavorstringKind of HTTP protocol used. [1]1.0Recommended
http.methodstringHTTP request method.GET; POST; HEADRequired
http.status_codeintHTTP response status code.200Conditionally Required: If and only if one was received/sent.
net.peer.namestringHost identifier of the “URI origin” HTTP request is sent to. [2]example.comRequired
net.peer.portintPort identifier of the “URI origin” HTTP request is sent to. [3]80; 8080; 443Conditionally Required: [4]
net.sock.peer.addrstringRemote socket peer address: IPv4 or IPv6 for internet protocols, path for local communication, etc.127.0.0.1; /tmp/mysql.sockRecommended

[1]: 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.

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

  • Host identifier of the request target if it’s sent in absolute-form
  • Host identifier of the Host header

SHOULD NOT be set if capturing it would require an extra DNS lookup.

[3]: When request target is absolute URI, net.peer.name MUST match URI port identifier, otherwise it MUST match Host header port identifier.

[4]: If not default (80 for http scheme, 443 for https).

Metric: http.client.request.size

This metric is optional.

NameInstrument TypeUnit (UCUM)Description
http.client.request.sizeHistogramByMeasures the size of HTTP request messages (compressed).
AttributeTypeDescriptionExamplesRequirement Level
http.flavorstringKind of HTTP protocol used. [1]1.0Recommended
http.methodstringHTTP request method.GET; POST; HEADRequired
http.status_codeintHTTP response status code.200Conditionally Required: If and only if one was received/sent.
net.peer.namestringHost identifier of the “URI origin” HTTP request is sent to. [2]example.comRequired
net.peer.portintPort identifier of the “URI origin” HTTP request is sent to. [3]80; 8080; 443Conditionally Required: [4]
net.sock.peer.addrstringRemote socket peer address: IPv4 or IPv6 for internet protocols, path for local communication, etc.127.0.0.1; /tmp/mysql.sockRecommended

[1]: 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.

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

  • Host identifier of the request target if it’s sent in absolute-form
  • Host identifier of the Host header

SHOULD NOT be set if capturing it would require an extra DNS lookup.

[3]: When request target is absolute URI, net.peer.name MUST match URI port identifier, otherwise it MUST match Host header port identifier.

[4]: If not default (80 for http scheme, 443 for https).

Metric: http.client.response.size

This metric is optional.

NameInstrument TypeUnit (UCUM)Description
http.client.response.sizeHistogramByMeasures the size of HTTP response messages (compressed).
AttributeTypeDescriptionExamplesRequirement Level
http.flavorstringKind of HTTP protocol used. [1]1.0Recommended
http.methodstringHTTP request method.GET; POST; HEADRequired
http.status_codeintHTTP response status code.200Conditionally Required: If and only if one was received/sent.
net.peer.namestringHost identifier of the “URI origin” HTTP request is sent to. [2]example.comRequired
net.peer.portintPort identifier of the “URI origin” HTTP request is sent to. [3]80; 8080; 443Conditionally Required: [4]
net.sock.peer.addrstringRemote socket peer address: IPv4 or IPv6 for internet protocols, path for local communication, etc.127.0.0.1; /tmp/mysql.sockRecommended

[1]: 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.

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

  • Host identifier of the request target if it’s sent in absolute-form
  • Host identifier of the Host header

SHOULD NOT be set if capturing it would require an extra DNS lookup.

[3]: When request target is absolute URI, net.peer.name MUST match URI port identifier, otherwise it MUST match Host header port identifier.

[4]: If not default (80 for http scheme, 443 for https).