http_attributes.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. * Copyright The OpenTelemetry Authors
  3. * SPDX-License-Identifier: Apache-2.0
  4. */
  5. /*
  6. * DO NOT EDIT, this is an Auto-generated file from:
  7. * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2
  8. */
  9. #pragma once
  10. #include "opentelemetry/common/macros.h"
  11. #include "opentelemetry/version.h"
  12. OPENTELEMETRY_BEGIN_NAMESPACE
  13. namespace semconv
  14. {
  15. namespace http
  16. {
  17. /**
  18. HTTP request headers, @code <key> @endcode being the normalized HTTP Header name (lowercase), the
  19. value being the header values. <p> Instrumentations SHOULD require an explicit configuration of
  20. which headers are to be captured. Including all request headers can be a security risk - explicit
  21. configuration helps avoid leaking sensitive information. <p> The @code User-Agent @endcode header
  22. is already captured in the @code user_agent.original @endcode attribute. Users MAY explicitly
  23. configure instrumentations to capture them even though it is not recommended. <p> The attribute
  24. value MUST consist of either multiple header values as an array of strings or a single-item array
  25. containing a possibly comma-concatenated string, depending on the way the HTTP library provides
  26. access to headers. <p> Examples: <ul> <li>A header @code Content-Type: application/json @endcode
  27. SHOULD be recorded as the @code http.request.header.content-type @endcode attribute with value
  28. @code ["application/json"] @endcode.</li> <li>A header @code X-Forwarded-For: 1.2.3.4, 1.2.3.5
  29. @endcode SHOULD be recorded as the @code http.request.header.x-forwarded-for @endcode attribute
  30. with value @code ["1.2.3.4", "1.2.3.5"] @endcode or @code ["1.2.3.4, 1.2.3.5"] @endcode depending
  31. on the HTTP library.</li>
  32. </ul>
  33. */
  34. static constexpr const char *kHttpRequestHeader = "http.request.header";
  35. /**
  36. HTTP request method.
  37. <p>
  38. HTTP request method value SHOULD be "known" to the instrumentation.
  39. By default, this convention defines "known" methods as the ones listed in <a
  40. href="https://www.rfc-editor.org/rfc/rfc9110.html#name-methods">RFC9110</a> and the PATCH method
  41. defined in <a href="https://www.rfc-editor.org/rfc/rfc5789.html">RFC5789</a>. <p> If the HTTP
  42. request method is not known to instrumentation, it MUST set the @code http.request.method @endcode
  43. attribute to @code _OTHER @endcode. <p> If the HTTP instrumentation could end up converting valid
  44. HTTP request methods to @code _OTHER @endcode, then it MUST provide a way to override the list of
  45. known HTTP methods. If this override is done via environment variable, then the environment
  46. variable MUST be named OTEL_INSTRUMENTATION_HTTP_KNOWN_METHODS and support a comma-separated list
  47. of case-sensitive known HTTP methods (this list MUST be a full override of the default known
  48. method, it is not a list of known methods in addition to the defaults). <p> HTTP method names are
  49. case-sensitive and @code http.request.method @endcode attribute value MUST match a known HTTP
  50. method name exactly. Instrumentations for specific web frameworks that consider HTTP methods to be
  51. case insensitive, SHOULD populate a canonical equivalent. Tracing instrumentations that do so,
  52. MUST also set @code http.request.method_original @endcode to the original value.
  53. */
  54. static constexpr const char *kHttpRequestMethod = "http.request.method";
  55. /**
  56. Original HTTP method sent by the client in the request line.
  57. */
  58. static constexpr const char *kHttpRequestMethodOriginal = "http.request.method_original";
  59. /**
  60. The ordinal number of request resending attempt (for any reason, including redirects).
  61. <p>
  62. The resend count SHOULD be updated each time an HTTP request gets resent by the client, regardless
  63. of what was the cause of the resending (e.g. redirection, authorization failure, 503 Server
  64. Unavailable, network issues, or any other).
  65. */
  66. static constexpr const char *kHttpRequestResendCount = "http.request.resend_count";
  67. /**
  68. HTTP response headers, @code <key> @endcode being the normalized HTTP Header name (lowercase), the
  69. value being the header values. <p> Instrumentations SHOULD require an explicit configuration of
  70. which headers are to be captured. Including all response headers can be a security risk - explicit
  71. configuration helps avoid leaking sensitive information. <p> Users MAY explicitly configure
  72. instrumentations to capture them even though it is not recommended. <p> The attribute value MUST
  73. consist of either multiple header values as an array of strings or a single-item array containing
  74. a possibly comma-concatenated string, depending on the way the HTTP library provides access to
  75. headers. <p> Examples: <ul> <li>A header @code Content-Type: application/json @endcode header
  76. SHOULD be recorded as the @code http.request.response.content-type @endcode attribute with value
  77. @code ["application/json"] @endcode.</li> <li>A header @code My-custom-header: abc, def @endcode
  78. header SHOULD be recorded as the @code http.response.header.my-custom-header @endcode attribute
  79. with value @code ["abc", "def"] @endcode or @code ["abc, def"] @endcode depending on the HTTP
  80. library.</li>
  81. </ul>
  82. */
  83. static constexpr const char *kHttpResponseHeader = "http.response.header";
  84. /**
  85. <a href="https://tools.ietf.org/html/rfc7231#section-6">HTTP response status code</a>.
  86. */
  87. static constexpr const char *kHttpResponseStatusCode = "http.response.status_code";
  88. /**
  89. The matched route, that is, the path template in the format used by the respective server
  90. framework. <p> MUST NOT be populated when this is not supported by the HTTP server framework as
  91. the route attribute should have low-cardinality and the URI path can NOT substitute it. SHOULD
  92. include the <a href="/docs/http/http-spans.md#http-server-definitions">application root</a> if
  93. there is one.
  94. */
  95. static constexpr const char *kHttpRoute = "http.route";
  96. namespace HttpRequestMethodValues
  97. {
  98. /**
  99. CONNECT method.
  100. */
  101. static constexpr const char *kConnect = "CONNECT";
  102. /**
  103. DELETE method.
  104. */
  105. static constexpr const char *kDelete = "DELETE";
  106. /**
  107. GET method.
  108. */
  109. static constexpr const char *kGet = "GET";
  110. /**
  111. HEAD method.
  112. */
  113. static constexpr const char *kHead = "HEAD";
  114. /**
  115. OPTIONS method.
  116. */
  117. static constexpr const char *kOptions = "OPTIONS";
  118. /**
  119. PATCH method.
  120. */
  121. static constexpr const char *kPatch = "PATCH";
  122. /**
  123. POST method.
  124. */
  125. static constexpr const char *kPost = "POST";
  126. /**
  127. PUT method.
  128. */
  129. static constexpr const char *kPut = "PUT";
  130. /**
  131. TRACE method.
  132. */
  133. static constexpr const char *kTrace = "TRACE";
  134. /**
  135. Any HTTP method that the instrumentation has no prior knowledge of.
  136. */
  137. static constexpr const char *kOther = "_OTHER";
  138. } // namespace HttpRequestMethodValues
  139. } // namespace http
  140. } // namespace semconv
  141. OPENTELEMETRY_END_NAMESPACE