1-
2-
31/*
42 * Copyright The OpenTelemetry Authors
53 * SPDX-License-Identifier: Apache-2.0
@@ -23,7 +21,7 @@ namespace http
2321
2422/* *
2523 * HTTP request headers, @code <key> @endcode being the normalized HTTP Header name (lowercase), the
26- * value being the header values. Note: Instrumentations SHOULD require an explicit configuration of
24+ * value being the header values. <p> Instrumentations SHOULD require an explicit configuration of
2725 * which headers are to be captured. Including all request headers can be a security risk - explicit
2826 * configuration helps avoid leaking sensitive information. The @code User-Agent @endcode header is
2927 * already captured in the @code user_agent.original @endcode attribute. Users MAY explicitly
@@ -32,11 +30,12 @@ namespace http
3230 * containing a possibly comma-concatenated string, depending on the way the HTTP library provides
3331 * access to headers.
3432 */
35- static const char *kHttpRequestHeader = " http.request.header" ;
33+ static constexpr const char *kHttpRequestHeader = " http.request.header" ;
3634
3735/* *
3836 * HTTP request method.
39- * Note: HTTP request method value SHOULD be "known" to the instrumentation.
37+ * <p>
38+ * HTTP request method value SHOULD be "known" to the instrumentation.
4039 * By default, this convention defines "known" methods as the ones listed in <a
4140 * href="https://www.rfc-editor.org/rfc/rfc9110.html#name-methods">RFC9110</a> and the PATCH method
4241 * defined in <a href="https://www.rfc-editor.org/rfc/rfc5789.html">RFC5789</a>. <p> If the HTTP
@@ -53,140 +52,100 @@ static const char *kHttpRequestHeader = "http.request.header";
5352 * instrumentations that do so, MUST also set @code http.request.method_original @endcode to the
5453 * original value.
5554 */
56- static const char *kHttpRequestMethod = " http.request.method" ;
55+ static constexpr const char *kHttpRequestMethod = " http.request.method" ;
5756
5857/* *
5958 * Original HTTP method sent by the client in the request line.
6059 */
61- static const char *kHttpRequestMethodOriginal = " http.request.method_original" ;
60+ static constexpr const char *kHttpRequestMethodOriginal = " http.request.method_original" ;
6261
6362/* *
6463 * The ordinal number of request resending attempt (for any reason, including redirects).
65- * Note: The resend count SHOULD be updated each time an HTTP request gets resent by the client,
64+ * <p>
65+ * The resend count SHOULD be updated each time an HTTP request gets resent by the client,
6666 * regardless of what was the cause of the resending (e.g. redirection, authorization failure, 503
6767 * Server Unavailable, network issues, or any other).
6868 */
69- static const char *kHttpRequestResendCount = " http.request.resend_count" ;
69+ static constexpr const char *kHttpRequestResendCount = " http.request.resend_count" ;
7070
7171/* *
7272 * HTTP response headers, @code <key> @endcode being the normalized HTTP Header name (lowercase),
73- * the value being the header values. Note: Instrumentations SHOULD require an explicit
74- * configuration of which headers are to be captured. Including all response headers can be a
75- * security risk - explicit configuration helps avoid leaking sensitive information. Users MAY
76- * explicitly configure instrumentations to capture them even though it is not recommended. The
77- * attribute value MUST consist of either multiple header values as an array of strings or a
78- * single-item array containing a possibly comma-concatenated string, depending on the way the HTTP
79- * library provides access to headers.
80- */
81- static const char *kHttpResponseHeader = " http.response.header" ;
73+ * the value being the header values. <p> Instrumentations SHOULD require an explicit configuration
74+ * of which headers are to be captured. Including all response headers can be a security risk -
75+ * explicit configuration helps avoid leaking sensitive information. Users MAY explicitly configure
76+ * instrumentations to capture them even though it is not recommended. The attribute value MUST
77+ * consist of either multiple header values as an array of strings or a single-item array containing
78+ * a possibly comma-concatenated string, depending on the way the HTTP library provides access to
79+ * headers.
80+ */
81+ static constexpr const char *kHttpResponseHeader = " http.response.header" ;
8282
8383/* *
8484 * <a href="https://tools.ietf.org/html/rfc7231#section-6">HTTP response status code</a>.
8585 */
86- static const char *kHttpResponseStatusCode = " http.response.status_code" ;
86+ static constexpr const char *kHttpResponseStatusCode = " http.response.status_code" ;
8787
8888/* *
8989 * The matched route, that is, the path template in the format used by the respective server
90- * framework. Note: MUST NOT be populated when this is not supported by the HTTP server framework as
90+ * framework. <p> MUST NOT be populated when this is not supported by the HTTP server framework as
9191 * the route attribute should have low-cardinality and the URI path can NOT substitute it. SHOULD
9292 * include the <a href="/docs/http/http-spans.md#http-server-definitions">application root</a> if
9393 * there is one.
9494 */
95- static const char *kHttpRoute = " http.route" ;
96-
97- // DEBUG: {"brief": "HTTP request method.", "examples": ["GET", "POST", "HEAD"], "name":
98- // "http.request.method", "note": "HTTP request method value SHOULD be \"known\" to the
99- // instrumentation.\nBy default, this convention defines \"known\" methods as the ones listed in
100- // [RFC9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-methods)\nand the PATCH method defined
101- // in [RFC5789](https://www.rfc-editor.org/rfc/rfc5789.html).\n\nIf the HTTP request method is not
102- // known to instrumentation, it MUST set the `http.request.method` attribute to `_OTHER`.\n\nIf the
103- // HTTP instrumentation could end up converting valid HTTP request methods to `_OTHER`, then it MUST
104- // provide a way to override\nthe list of known HTTP methods. If this override is done via
105- // environment variable, then the environment variable MUST be
106- // named\nOTEL_INSTRUMENTATION_HTTP_KNOWN_METHODS and support a comma-separated list of
107- // case-sensitive known HTTP methods\n(this list MUST be a full override of the default known
108- // method, it is not a list of known methods in addition to the defaults).\n\nHTTP method names are
109- // case-sensitive and `http.request.method` attribute value MUST match a known HTTP method name
110- // exactly.\nInstrumentations for specific web frameworks that consider HTTP methods to be case
111- // insensitive, SHOULD populate a canonical equivalent.\nTracing instrumentations that do so, MUST
112- // also set `http.request.method_original` to the original value.\n", "requirement_level":
113- // "recommended", "root_namespace": "http", "stability": "stable", "type": {"allow_custom_values":
114- // true, "members": [{"brief": "CONNECT method.", "deprecated": none, "id": "connect", "note": none,
115- // "stability": "stable", "value": "CONNECT"}, {"brief": "DELETE method.", "deprecated": none, "id":
116- // "delete", "note": none, "stability": "stable", "value": "DELETE"}, {"brief": "GET method.",
117- // "deprecated": none, "id": "get", "note": none, "stability": "stable", "value": "GET"}, {"brief":
118- // "HEAD method.", "deprecated": none, "id": "head", "note": none, "stability": "stable", "value":
119- // "HEAD"}, {"brief": "OPTIONS method.", "deprecated": none, "id": "options", "note": none,
120- // "stability": "stable", "value": "OPTIONS"}, {"brief": "PATCH method.", "deprecated": none, "id":
121- // "patch", "note": none, "stability": "stable", "value": "PATCH"}, {"brief": "POST method.",
122- // "deprecated": none, "id": "post", "note": none, "stability": "stable", "value": "POST"},
123- // {"brief": "PUT method.", "deprecated": none, "id": "put", "note": none, "stability": "stable",
124- // "value": "PUT"}, {"brief": "TRACE method.", "deprecated": none, "id": "trace", "note": none,
125- // "stability": "stable", "value": "TRACE"}, {"brief": "Any HTTP method that the instrumentation has
126- // no prior knowledge of.", "deprecated": none, "id": "other", "note": none, "stability": "stable",
127- // "value": "_OTHER"}]}}
95+ static constexpr const char *kHttpRoute = " http.route" ;
96+
12897namespace HttpRequestMethodValues
12998{
13099/* *
131100 * CONNECT method.
132101 */
133- // DEBUG: {"brief": "CONNECT method.", "deprecated": none, "id": "connect", "note": none,
134- // "stability": "stable", "value": "CONNECT"}
135102static constexpr const char *kConnect = " CONNECT" ;
103+
136104/* *
137105 * DELETE method.
138106 */
139- // DEBUG: {"brief": "DELETE method.", "deprecated": none, "id": "delete", "note": none, "stability":
140- // "stable", "value": "DELETE"}
141107static constexpr const char *kDelete = " DELETE" ;
108+
142109/* *
143110 * GET method.
144111 */
145- // DEBUG: {"brief": "GET method.", "deprecated": none, "id": "get", "note": none, "stability":
146- // "stable", "value": "GET"}
147112static constexpr const char *kGet = " GET" ;
113+
148114/* *
149115 * HEAD method.
150116 */
151- // DEBUG: {"brief": "HEAD method.", "deprecated": none, "id": "head", "note": none, "stability":
152- // "stable", "value": "HEAD"}
153117static constexpr const char *kHead = " HEAD" ;
118+
154119/* *
155120 * OPTIONS method.
156121 */
157- // DEBUG: {"brief": "OPTIONS method.", "deprecated": none, "id": "options", "note": none,
158- // "stability": "stable", "value": "OPTIONS"}
159122static constexpr const char *kOptions = " OPTIONS" ;
123+
160124/* *
161125 * PATCH method.
162126 */
163- // DEBUG: {"brief": "PATCH method.", "deprecated": none, "id": "patch", "note": none, "stability":
164- // "stable", "value": "PATCH"}
165127static constexpr const char *kPatch = " PATCH" ;
128+
166129/* *
167130 * POST method.
168131 */
169- // DEBUG: {"brief": "POST method.", "deprecated": none, "id": "post", "note": none, "stability":
170- // "stable", "value": "POST"}
171132static constexpr const char *kPost = " POST" ;
133+
172134/* *
173135 * PUT method.
174136 */
175- // DEBUG: {"brief": "PUT method.", "deprecated": none, "id": "put", "note": none, "stability":
176- // "stable", "value": "PUT"}
177137static constexpr const char *kPut = " PUT" ;
138+
178139/* *
179140 * TRACE method.
180141 */
181- // DEBUG: {"brief": "TRACE method.", "deprecated": none, "id": "trace", "note": none, "stability":
182- // "stable", "value": "TRACE"}
183142static constexpr const char *kTrace = " TRACE" ;
143+
184144/* *
185145 * Any HTTP method that the instrumentation has no prior knowledge of.
186146 */
187- // DEBUG: {"brief": "Any HTTP method that the instrumentation has no prior knowledge of.",
188- // "deprecated": none, "id": "other", "note": none, "stability": "stable", "value": "_OTHER"}
189147static constexpr const char *kOther = " _OTHER" ;
148+
190149} // namespace HttpRequestMethodValues
191150
192151} // namespace http
0 commit comments