http.* attributes: OpenTelemetry HTTP semantic conventions

From semantic-conventions v1.44.0 (e10a930)Synced View as MarkdownOpen in ClaudeOpen in ChatGPT

Short answer

The http.* attributes describe one HTTP request: http.request.method, http.response.status_code, http.route on servers, and request and response headers when you opt in. The core ones are Stable. Older names such as http.method, http.status_code and http.url are deprecated, and http.url became url.full.

What do the http.* attributes describe?

An HTTP client span is named {method} {target}, or just {method} when there is no low-cardinality target. The target is url.template on a client and http.route on a server. The URL path is never the default target.

A request with a method the instrumentation does not know gets http.request.method _OTHER, the real method in http.request.method_original, and the span name HTTP.

The address of the other side is not an http.* attribute: it is server.address and server.port, shared with RPC and GenAI spans.

Which spans set them?

Every span in the conventions that references at least one of these attributes, with the span name it should get and its kind.

  • {method} {target}CLIENThttp.client
  • {method} {target}SERVERhttp.server

Why does my backend show http.method and http.url?

If it does, the spans come from instrumentation that writes the old names. They are listed under the deprecated attributes below, each with its replacement: http.method is now http.request.method, http.status_code is http.response.status_code, http.url is url.full.

If a dashboard has to work across both, query both names until every service is upgraded.

All 12 http.* attributes

http.request.body.size

intDevelopment

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 header. For requests using transport encoding, this should be the compressed size.

Examples 3495

Set on
  • {method} {target} CLIENT: http.client (opt-in)
  • {method} {target} SERVER: http.server (opt-in)

Official definition

http.request.header.<key>

string[]Stable

HTTP request headers, <key> being the normalized HTTP Header name (lowercase), the value being the header values.

Examples ["application/json"], ["1.2.3.4","1.2.3.5"]

Set on
  • {method} {target} CLIENT: http.client (opt-in)
  • {method} {target} SERVER: http.server (opt-in)

Official definition

http.request.method

stringStable

HTTP request method.

Values CONNECT, DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT, TRACE, QUERY, _OTHER

Set on
  • {method} {target} CLIENT: http.client (required)
  • {method} {target} SERVER: http.server (required)

Official definition

http.request.method_original

stringStable

Original HTTP method sent by the client in the request line.

Examples GeT, ACL, foo

Set on
  • {method} {target} CLIENT: http.client (conditionally required)
  • {method} {target} SERVER: http.server (conditionally required)

Official definition

http.request.size

intDevelopment

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.

Examples 1437

Set on
  • {method} {target} CLIENT: http.client (opt-in)
  • {method} {target} SERVER: http.server (opt-in)

Official definition

http.response.body.size

intDevelopment

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 header. For requests using transport encoding, this should be the compressed size.

Examples 3495

Set on
  • {method} {target} CLIENT: http.client (opt-in)
  • {method} {target} SERVER: http.server (opt-in)

Official definition

http.response.header.<key>

string[]Stable

HTTP response headers, <key> being the normalized HTTP Header name (lowercase), the value being the header values.

Examples ["application/json"], ["abc","def"]

Set on
  • {method} {target} CLIENT: http.client (opt-in)
  • {method} {target} SERVER: http.server (opt-in)

Official definition

http.response.size

intDevelopment

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.

Examples 1437

Set on
  • {method} {target} CLIENT: http.client (opt-in)
  • {method} {target} SERVER: http.server (opt-in)

Official definition

http.response.status_code

intStable

HTTP response status code.

Examples 200

Set on
  • {method} {target} CLIENT: http.client (conditionally required)
  • {method} {target} SERVER: http.server (conditionally required)

Official definition

http.route

stringStable

The matched route template for the request. This MUST be low-cardinality and include all static path segments, with dynamic path segments represented with placeholders.

Examples /users/:userID?, my-controller/my-action/{id?}

Set on
  • {method} {target} SERVER: http.server (conditionally required)

Official definition

Which names were renamed or removed?

Deprecated names you may still see in older traces, each with what replaced it.

http.host

stringDeprecated

Replaced by one of server.address, client.address or http.request.header.host, depending on the usage.

Examples www.example.org

Official definition

http.user_agent

stringDeprecated

Renamed to user_agent.original.

Examples CERN-LineMode/2.15 libwww/2.17b3, Mozilla/5.0 (iPhone; CPU iPhone OS 14_7_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Mobile/15E148 Safari/604.1

Official definition

FAQ

Is a 404 response an error on the span?

On a client span, yes by default: a 4xx or 5xx status code SHOULD set the span status to Error. On a server span a 4xx MUST leave it unset, and only 5xx is an error. 1xx, 2xx and 3xx leave the status unset unless something else failed.

What replaced http.url and http.target?

http.url became url.full. http.target was split into url.path and url.query.

Attribute names, types, stability and descriptions are from the OpenTelemetry semantic conventions (open-telemetry/semantic-conventions), © OpenTelemetry Authors, Apache-2.0. Each attribute links to its official definition, which wins where the two differ.

Something wrong or out of date? Report a problem with this page.

Type to search the docs, Learn topics and the blog.