Semantic Conventions for HTTP Metrics

NOTICE Semantic Conventions are moving to a new location.

No changes to this document are allowed.

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.

Warning Existing HTTP instrumentations that are using v1.20.0 of this document (or prior):

  • SHOULD NOT change the version of the HTTP or networking attributes that they emit until the HTTP semantic conventions are marked stable (HTTP stabilization will include stabilization of a core set of networking attributes which are also used in HTTP instrumentations).
  • SHOULD introduce an environment variable OTEL_SEMCONV_STABILITY_OPT_IN in the existing major version which supports the following values:
    • none - continue emitting whatever version of the old experimental HTTP and networking attributes the instrumentation was emitting previously. This is the default value.
    • http - emit the new, stable HTTP and networking attributes, and stop emitting the old experimental HTTP and networking attributes that the instrumentation emitted previously.
    • http/dup - emit both the old and the stable HTTP and networking attributes, allowing for a seamless transition.
  • SHOULD maintain (security patching at a minimum) the existing major version for at least six months after it starts emitting both sets of attributes.
  • SHOULD drop the environment variable in the next major version (stable next major version SHOULD NOT be released prior to October 1, 2023).

HTTP Server

Metric: http.server.duration

This metric is required.

This metric SHOULD be specified with ExplicitBucketBoundaries of [ 0, 0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10 ].

NameInstrument TypeUnit (UCUM)Description
http.server.durationHistogramsMeasures the duration of inbound HTTP requests.
AttributeTypeDescriptionExamplesRequirement Level
http.routestringThe matched route (path template in the format used by the respective server framework). See note below [1]/users/:userID?; {controller}/{action}/{id?}Conditionally Required: If and only if it’s available
http.request.methodstringHTTP request method.GET; POST; HEADRequired
http.response.status_codeintHTTP response status code.200Conditionally Required: If and only if one was received/sent.
network.protocol.namestringOSI Application Layer or non-OSI equivalent. The value SHOULD be normalized to lowercase.amqp; http; mqttRecommended
network.protocol.versionstringVersion of the application layer protocol used. See note below. [2]3.1.1Recommended
server.addressstringName of the local HTTP server that received the request. [3]example.comRequired
server.portintPort of the local HTTP server that received the request. [4]80; 8080; 443Conditionally Required: [5]
url.schemestringThe URI scheme component identifying the used protocol.http; httpsRequired

[1]: 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 roottrace/semantic_conventions/http.md#http-server-definitions) if there is one.

[2]: network.protocol.version refers to the version of the protocol used and might be different from the protocol client’s version. If the HTTP client used has a version of 0.27.2, but sends HTTP version 1.1, this attribute should be set to 1.1.

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

  • The primary server nametrace/semantic_conventions/http.md#http-server-definitions) 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 hosttrace/semantic_conventions/http.md#http-server-definitions) 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{request}Measures the number of concurrent HTTP requests that are currently in-flight.
AttributeTypeDescriptionExamplesRequirement Level
http.request.methodstringHTTP request method.GET; POST; HEADRequired
server.addressstringName of the local HTTP server that received the request. [1]example.comRequired
server.portintPort of the local HTTP server that received the request. [2]80; 8080; 443Conditionally Required: [3]
url.schemestringThe URI scheme component identifying the used protocol.http; httpsRequired

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

  • The primary server nametrace/semantic_conventions/http.md#http-server-definitions) 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.

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

  • Port identifier of the primary server hosttrace/semantic_conventions/http.md#http-server-definitions) of the matched virtual host.
  • Port identifier of the request target if it’s sent in absolute-form.
  • Port identifier of the Host header

[3]: 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.routestringThe matched route (path template in the format used by the respective server framework). See note below [1]/users/:userID?; {controller}/{action}/{id?}Conditionally Required: If and only if it’s available
http.request.methodstringHTTP request method.GET; POST; HEADRequired
http.response.status_codeintHTTP response status code.200Conditionally Required: If and only if one was received/sent.
network.protocol.namestringOSI Application Layer or non-OSI equivalent. The value SHOULD be normalized to lowercase.amqp; http; mqttRecommended
network.protocol.versionstringVersion of the application layer protocol used. See note below. [2]3.1.1Recommended
server.addressstringName of the local HTTP server that received the request. [3]example.comRequired
server.portintPort of the local HTTP server that received the request. [4]80; 8080; 443Conditionally Required: [5]
url.schemestringThe URI scheme component identifying the used protocol.http; httpsRequired

[1]: 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 roottrace/semantic_conventions/http.md#http-server-definitions) if there is one.

[2]: network.protocol.version refers to the version of the protocol used and might be different from the protocol client’s version. If the HTTP client used has a version of 0.27.2, but sends HTTP version 1.1, this attribute should be set to 1.1.

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

  • The primary server nametrace/semantic_conventions/http.md#http-server-definitions) 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 hosttrace/semantic_conventions/http.md#http-server-definitions) 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.routestringThe matched route (path template in the format used by the respective server framework). See note below [1]/users/:userID?; {controller}/{action}/{id?}Conditionally Required: If and only if it’s available
http.request.methodstringHTTP request method.GET; POST; HEADRequired
http.response.status_codeintHTTP response status code.200Conditionally Required: If and only if one was received/sent.
network.protocol.namestringOSI Application Layer or non-OSI equivalent. The value SHOULD be normalized to lowercase.amqp; http; mqttRecommended
network.protocol.versionstringVersion of the application layer protocol used. See note below. [2]3.1.1Recommended
server.addressstringName of the local HTTP server that received the request. [3]example.comRequired
server.portintPort of the local HTTP server that received the request. [4]80; 8080; 443Conditionally Required: [5]
url.schemestringThe URI scheme component identifying the used protocol.http; httpsRequired

[1]: 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 roottrace/semantic_conventions/http.md#http-server-definitions) if there is one.

[2]: network.protocol.version refers to the version of the protocol used and might be different from the protocol client’s version. If the HTTP client used has a version of 0.27.2, but sends HTTP version 1.1, this attribute should be set to 1.1.

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

  • The primary server nametrace/semantic_conventions/http.md#http-server-definitions) 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 hosttrace/semantic_conventions/http.md#http-server-definitions) 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.

This metric SHOULD be specified with ExplicitBucketBoundaries of [ 0, 0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10 ].

NameInstrument TypeUnit (UCUM)Description
http.client.durationHistogramsMeasures the duration of outbound HTTP requests.
AttributeTypeDescriptionExamplesRequirement Level
http.request.methodstringHTTP request method.GET; POST; HEADRequired
http.response.status_codeintHTTP response status code.200Conditionally Required: If and only if one was received/sent.
network.protocol.namestringOSI Application Layer or non-OSI equivalent. The value SHOULD be normalized to lowercase.amqp; http; mqttRecommended
network.protocol.versionstringVersion of the application layer protocol used. See note below. [1]3.1.1Recommended
server.addressstringHost identifier of the “URI origin” HTTP request is sent to. [2]example.comRequired
server.portintPort identifier of the “URI origin” HTTP request is sent to. [3]80; 8080; 443Conditionally Required: [4]
server.socket.addressstringPhysical server IP address or Unix socket address.10.5.3.2Recommended: If different than server.address.

[1]: network.protocol.version refers to the version of the protocol used and might be different from the protocol client’s version. If the HTTP client used has a version of 0.27.2, but sends HTTP version 1.1, this attribute should be set to 1.1.

[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, server.port 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.request.methodstringHTTP request method.GET; POST; HEADRequired
http.response.status_codeintHTTP response status code.200Conditionally Required: If and only if one was received/sent.
network.protocol.namestringOSI Application Layer or non-OSI equivalent. The value SHOULD be normalized to lowercase.amqp; http; mqttRecommended
network.protocol.versionstringVersion of the application layer protocol used. See note below. [1]3.1.1Recommended
server.addressstringHost identifier of the “URI origin” HTTP request is sent to. [2]example.comRequired
server.portintPort identifier of the “URI origin” HTTP request is sent to. [3]80; 8080; 443Conditionally Required: [4]
server.socket.addressstringPhysical server IP address or Unix socket address.10.5.3.2Recommended: If different than server.address.

[1]: network.protocol.version refers to the version of the protocol used and might be different from the protocol client’s version. If the HTTP client used has a version of 0.27.2, but sends HTTP version 1.1, this attribute should be set to 1.1.

[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, server.port 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.request.methodstringHTTP request method.GET; POST; HEADRequired
http.response.status_codeintHTTP response status code.200Conditionally Required: If and only if one was received/sent.
network.protocol.namestringOSI Application Layer or non-OSI equivalent. The value SHOULD be normalized to lowercase.amqp; http; mqttRecommended
network.protocol.versionstringVersion of the application layer protocol used. See note below. [1]3.1.1Recommended
server.addressstringHost identifier of the “URI origin” HTTP request is sent to. [2]example.comRequired
server.portintPort identifier of the “URI origin” HTTP request is sent to. [3]80; 8080; 443Conditionally Required: [4]
server.socket.addressstringPhysical server IP address or Unix socket address.10.5.3.2Recommended: If different than server.address.

[1]: network.protocol.version refers to the version of the protocol used and might be different from the protocol client’s version. If the HTTP client used has a version of 0.27.2, but sends HTTP version 1.1, this attribute should be set to 1.1.

[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, server.port MUST match URI port identifier, otherwise it MUST match Host header port identifier.

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