otel_metrics.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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_metrics-h.j2
  8. */
  9. #pragma once
  10. #include "opentelemetry/common/macros.h"
  11. #include "opentelemetry/metrics/meter.h"
  12. #include "opentelemetry/version.h"
  13. OPENTELEMETRY_BEGIN_NAMESPACE
  14. namespace semconv
  15. {
  16. namespace otel
  17. {
  18. /**
  19. * The number of spans for which the export has finished, either successful or failed
  20. * <p>
  21. * For successful exports, @code error.type @endcode MUST NOT be set. For failed exports, @code
  22. * error.type @endcode must contain the failure cause. For exporters with partial success semantics
  23. * (e.g. OTLP with @code rejected_spans @endcode), rejected spans must count as failed and only
  24. * non-rejected spans count as success. If no rejection reason is available, @code rejected @endcode
  25. * SHOULD be used as value for @code error.type @endcode. <p> counter
  26. */
  27. static constexpr const char *kMetricOtelSdkExporterSpanExportedCount =
  28. "otel.sdk.exporter.span.exported.count";
  29. static constexpr const char *descrMetricOtelSdkExporterSpanExportedCount =
  30. "The number of spans for which the export has finished, either successful or failed";
  31. static constexpr const char *unitMetricOtelSdkExporterSpanExportedCount = "{span}";
  32. static inline nostd::unique_ptr<metrics::Counter<uint64_t>>
  33. CreateSyncInt64MetricOtelSdkExporterSpanExportedCount(metrics::Meter *meter)
  34. {
  35. return meter->CreateUInt64Counter(kMetricOtelSdkExporterSpanExportedCount,
  36. descrMetricOtelSdkExporterSpanExportedCount,
  37. unitMetricOtelSdkExporterSpanExportedCount);
  38. }
  39. static inline nostd::unique_ptr<metrics::Counter<double>>
  40. CreateSyncDoubleMetricOtelSdkExporterSpanExportedCount(metrics::Meter *meter)
  41. {
  42. return meter->CreateDoubleCounter(kMetricOtelSdkExporterSpanExportedCount,
  43. descrMetricOtelSdkExporterSpanExportedCount,
  44. unitMetricOtelSdkExporterSpanExportedCount);
  45. }
  46. static inline nostd::shared_ptr<metrics::ObservableInstrument>
  47. CreateAsyncInt64MetricOtelSdkExporterSpanExportedCount(metrics::Meter *meter)
  48. {
  49. return meter->CreateInt64ObservableCounter(kMetricOtelSdkExporterSpanExportedCount,
  50. descrMetricOtelSdkExporterSpanExportedCount,
  51. unitMetricOtelSdkExporterSpanExportedCount);
  52. }
  53. static inline nostd::shared_ptr<metrics::ObservableInstrument>
  54. CreateAsyncDoubleMetricOtelSdkExporterSpanExportedCount(metrics::Meter *meter)
  55. {
  56. return meter->CreateDoubleObservableCounter(kMetricOtelSdkExporterSpanExportedCount,
  57. descrMetricOtelSdkExporterSpanExportedCount,
  58. unitMetricOtelSdkExporterSpanExportedCount);
  59. }
  60. /**
  61. * The number of spans which were passed to the exporter, but that have not been exported yet
  62. * (neither successful, nor failed) <p> For successful exports, @code error.type @endcode MUST NOT
  63. * be set. For failed exports, @code error.type @endcode must contain the failure cause. <p>
  64. * updowncounter
  65. */
  66. static constexpr const char *kMetricOtelSdkExporterSpanInflightCount =
  67. "otel.sdk.exporter.span.inflight.count";
  68. static constexpr const char *descrMetricOtelSdkExporterSpanInflightCount =
  69. "The number of spans which were passed to the exporter, but that have not been exported yet "
  70. "(neither successful, nor failed)";
  71. static constexpr const char *unitMetricOtelSdkExporterSpanInflightCount = "{span}";
  72. static inline nostd::unique_ptr<metrics::UpDownCounter<int64_t>>
  73. CreateSyncInt64MetricOtelSdkExporterSpanInflightCount(metrics::Meter *meter)
  74. {
  75. return meter->CreateInt64UpDownCounter(kMetricOtelSdkExporterSpanInflightCount,
  76. descrMetricOtelSdkExporterSpanInflightCount,
  77. unitMetricOtelSdkExporterSpanInflightCount);
  78. }
  79. static inline nostd::unique_ptr<metrics::UpDownCounter<double>>
  80. CreateSyncDoubleMetricOtelSdkExporterSpanInflightCount(metrics::Meter *meter)
  81. {
  82. return meter->CreateDoubleUpDownCounter(kMetricOtelSdkExporterSpanInflightCount,
  83. descrMetricOtelSdkExporterSpanInflightCount,
  84. unitMetricOtelSdkExporterSpanInflightCount);
  85. }
  86. static inline nostd::shared_ptr<metrics::ObservableInstrument>
  87. CreateAsyncInt64MetricOtelSdkExporterSpanInflightCount(metrics::Meter *meter)
  88. {
  89. return meter->CreateInt64ObservableUpDownCounter(kMetricOtelSdkExporterSpanInflightCount,
  90. descrMetricOtelSdkExporterSpanInflightCount,
  91. unitMetricOtelSdkExporterSpanInflightCount);
  92. }
  93. static inline nostd::shared_ptr<metrics::ObservableInstrument>
  94. CreateAsyncDoubleMetricOtelSdkExporterSpanInflightCount(metrics::Meter *meter)
  95. {
  96. return meter->CreateDoubleObservableUpDownCounter(kMetricOtelSdkExporterSpanInflightCount,
  97. descrMetricOtelSdkExporterSpanInflightCount,
  98. unitMetricOtelSdkExporterSpanInflightCount);
  99. }
  100. /**
  101. * The number of spans for which the processing has finished, either successful or failed
  102. * <p>
  103. * For successful processing, @code error.type @endcode MUST NOT be set. For failed processing,
  104. * @code error.type @endcode must contain the failure cause. For the SDK Simple and Batching Span
  105. * Processor a span is considered to be processed already when it has been submitted to the
  106. * exporter, not when the corresponding export call has finished. <p> counter
  107. */
  108. static constexpr const char *kMetricOtelSdkProcessorSpanProcessedCount =
  109. "otel.sdk.processor.span.processed.count";
  110. static constexpr const char *descrMetricOtelSdkProcessorSpanProcessedCount =
  111. "The number of spans for which the processing has finished, either successful or failed";
  112. static constexpr const char *unitMetricOtelSdkProcessorSpanProcessedCount = "{span}";
  113. static inline nostd::unique_ptr<metrics::Counter<uint64_t>>
  114. CreateSyncInt64MetricOtelSdkProcessorSpanProcessedCount(metrics::Meter *meter)
  115. {
  116. return meter->CreateUInt64Counter(kMetricOtelSdkProcessorSpanProcessedCount,
  117. descrMetricOtelSdkProcessorSpanProcessedCount,
  118. unitMetricOtelSdkProcessorSpanProcessedCount);
  119. }
  120. static inline nostd::unique_ptr<metrics::Counter<double>>
  121. CreateSyncDoubleMetricOtelSdkProcessorSpanProcessedCount(metrics::Meter *meter)
  122. {
  123. return meter->CreateDoubleCounter(kMetricOtelSdkProcessorSpanProcessedCount,
  124. descrMetricOtelSdkProcessorSpanProcessedCount,
  125. unitMetricOtelSdkProcessorSpanProcessedCount);
  126. }
  127. static inline nostd::shared_ptr<metrics::ObservableInstrument>
  128. CreateAsyncInt64MetricOtelSdkProcessorSpanProcessedCount(metrics::Meter *meter)
  129. {
  130. return meter->CreateInt64ObservableCounter(kMetricOtelSdkProcessorSpanProcessedCount,
  131. descrMetricOtelSdkProcessorSpanProcessedCount,
  132. unitMetricOtelSdkProcessorSpanProcessedCount);
  133. }
  134. static inline nostd::shared_ptr<metrics::ObservableInstrument>
  135. CreateAsyncDoubleMetricOtelSdkProcessorSpanProcessedCount(metrics::Meter *meter)
  136. {
  137. return meter->CreateDoubleObservableCounter(kMetricOtelSdkProcessorSpanProcessedCount,
  138. descrMetricOtelSdkProcessorSpanProcessedCount,
  139. unitMetricOtelSdkProcessorSpanProcessedCount);
  140. }
  141. /**
  142. * The maximum number of spans the queue of a given instance of an SDK span processor can hold
  143. * <p>
  144. * Only applies to span processors which use a queue, e.g. the SDK Batching Span Processor.
  145. * <p>
  146. * updowncounter
  147. */
  148. static constexpr const char *kMetricOtelSdkProcessorSpanQueueCapacity =
  149. "otel.sdk.processor.span.queue.capacity";
  150. static constexpr const char *descrMetricOtelSdkProcessorSpanQueueCapacity =
  151. "The maximum number of spans the queue of a given instance of an SDK span processor can hold";
  152. static constexpr const char *unitMetricOtelSdkProcessorSpanQueueCapacity = "{span}";
  153. static inline nostd::unique_ptr<metrics::UpDownCounter<int64_t>>
  154. CreateSyncInt64MetricOtelSdkProcessorSpanQueueCapacity(metrics::Meter *meter)
  155. {
  156. return meter->CreateInt64UpDownCounter(kMetricOtelSdkProcessorSpanQueueCapacity,
  157. descrMetricOtelSdkProcessorSpanQueueCapacity,
  158. unitMetricOtelSdkProcessorSpanQueueCapacity);
  159. }
  160. static inline nostd::unique_ptr<metrics::UpDownCounter<double>>
  161. CreateSyncDoubleMetricOtelSdkProcessorSpanQueueCapacity(metrics::Meter *meter)
  162. {
  163. return meter->CreateDoubleUpDownCounter(kMetricOtelSdkProcessorSpanQueueCapacity,
  164. descrMetricOtelSdkProcessorSpanQueueCapacity,
  165. unitMetricOtelSdkProcessorSpanQueueCapacity);
  166. }
  167. static inline nostd::shared_ptr<metrics::ObservableInstrument>
  168. CreateAsyncInt64MetricOtelSdkProcessorSpanQueueCapacity(metrics::Meter *meter)
  169. {
  170. return meter->CreateInt64ObservableUpDownCounter(kMetricOtelSdkProcessorSpanQueueCapacity,
  171. descrMetricOtelSdkProcessorSpanQueueCapacity,
  172. unitMetricOtelSdkProcessorSpanQueueCapacity);
  173. }
  174. static inline nostd::shared_ptr<metrics::ObservableInstrument>
  175. CreateAsyncDoubleMetricOtelSdkProcessorSpanQueueCapacity(metrics::Meter *meter)
  176. {
  177. return meter->CreateDoubleObservableUpDownCounter(kMetricOtelSdkProcessorSpanQueueCapacity,
  178. descrMetricOtelSdkProcessorSpanQueueCapacity,
  179. unitMetricOtelSdkProcessorSpanQueueCapacity);
  180. }
  181. /**
  182. * The number of spans in the queue of a given instance of an SDK span processor
  183. * <p>
  184. * Only applies to span processors which use a queue, e.g. the SDK Batching Span Processor.
  185. * <p>
  186. * updowncounter
  187. */
  188. static constexpr const char *kMetricOtelSdkProcessorSpanQueueSize =
  189. "otel.sdk.processor.span.queue.size";
  190. static constexpr const char *descrMetricOtelSdkProcessorSpanQueueSize =
  191. "The number of spans in the queue of a given instance of an SDK span processor";
  192. static constexpr const char *unitMetricOtelSdkProcessorSpanQueueSize = "{span}";
  193. static inline nostd::unique_ptr<metrics::UpDownCounter<int64_t>>
  194. CreateSyncInt64MetricOtelSdkProcessorSpanQueueSize(metrics::Meter *meter)
  195. {
  196. return meter->CreateInt64UpDownCounter(kMetricOtelSdkProcessorSpanQueueSize,
  197. descrMetricOtelSdkProcessorSpanQueueSize,
  198. unitMetricOtelSdkProcessorSpanQueueSize);
  199. }
  200. static inline nostd::unique_ptr<metrics::UpDownCounter<double>>
  201. CreateSyncDoubleMetricOtelSdkProcessorSpanQueueSize(metrics::Meter *meter)
  202. {
  203. return meter->CreateDoubleUpDownCounter(kMetricOtelSdkProcessorSpanQueueSize,
  204. descrMetricOtelSdkProcessorSpanQueueSize,
  205. unitMetricOtelSdkProcessorSpanQueueSize);
  206. }
  207. static inline nostd::shared_ptr<metrics::ObservableInstrument>
  208. CreateAsyncInt64MetricOtelSdkProcessorSpanQueueSize(metrics::Meter *meter)
  209. {
  210. return meter->CreateInt64ObservableUpDownCounter(kMetricOtelSdkProcessorSpanQueueSize,
  211. descrMetricOtelSdkProcessorSpanQueueSize,
  212. unitMetricOtelSdkProcessorSpanQueueSize);
  213. }
  214. static inline nostd::shared_ptr<metrics::ObservableInstrument>
  215. CreateAsyncDoubleMetricOtelSdkProcessorSpanQueueSize(metrics::Meter *meter)
  216. {
  217. return meter->CreateDoubleObservableUpDownCounter(kMetricOtelSdkProcessorSpanQueueSize,
  218. descrMetricOtelSdkProcessorSpanQueueSize,
  219. unitMetricOtelSdkProcessorSpanQueueSize);
  220. }
  221. /**
  222. * The number of created spans for which the end operation was called
  223. * <p>
  224. * For spans with @code recording=true @endcode: Implementations MUST record both @code
  225. * otel.sdk.span.live.count @endcode and @code otel.sdk.span.ended.count @endcode. For spans with
  226. * @code recording=false @endcode: If implementations decide to record this metric, they MUST also
  227. * record @code otel.sdk.span.live.count @endcode. <p> counter
  228. */
  229. static constexpr const char *kMetricOtelSdkSpanEndedCount = "otel.sdk.span.ended.count";
  230. static constexpr const char *descrMetricOtelSdkSpanEndedCount =
  231. "The number of created spans for which the end operation was called";
  232. static constexpr const char *unitMetricOtelSdkSpanEndedCount = "{span}";
  233. static inline nostd::unique_ptr<metrics::Counter<uint64_t>>
  234. CreateSyncInt64MetricOtelSdkSpanEndedCount(metrics::Meter *meter)
  235. {
  236. return meter->CreateUInt64Counter(kMetricOtelSdkSpanEndedCount, descrMetricOtelSdkSpanEndedCount,
  237. unitMetricOtelSdkSpanEndedCount);
  238. }
  239. static inline nostd::unique_ptr<metrics::Counter<double>>
  240. CreateSyncDoubleMetricOtelSdkSpanEndedCount(metrics::Meter *meter)
  241. {
  242. return meter->CreateDoubleCounter(kMetricOtelSdkSpanEndedCount, descrMetricOtelSdkSpanEndedCount,
  243. unitMetricOtelSdkSpanEndedCount);
  244. }
  245. static inline nostd::shared_ptr<metrics::ObservableInstrument>
  246. CreateAsyncInt64MetricOtelSdkSpanEndedCount(metrics::Meter *meter)
  247. {
  248. return meter->CreateInt64ObservableCounter(kMetricOtelSdkSpanEndedCount,
  249. descrMetricOtelSdkSpanEndedCount,
  250. unitMetricOtelSdkSpanEndedCount);
  251. }
  252. static inline nostd::shared_ptr<metrics::ObservableInstrument>
  253. CreateAsyncDoubleMetricOtelSdkSpanEndedCount(metrics::Meter *meter)
  254. {
  255. return meter->CreateDoubleObservableCounter(kMetricOtelSdkSpanEndedCount,
  256. descrMetricOtelSdkSpanEndedCount,
  257. unitMetricOtelSdkSpanEndedCount);
  258. }
  259. /**
  260. * The number of created spans for which the end operation has not been called yet
  261. * <p>
  262. * For spans with @code recording=true @endcode: Implementations MUST record both @code
  263. * otel.sdk.span.live.count @endcode and @code otel.sdk.span.ended.count @endcode. For spans with
  264. * @code recording=false @endcode: If implementations decide to record this metric, they MUST also
  265. * record @code otel.sdk.span.ended.count @endcode. <p> updowncounter
  266. */
  267. static constexpr const char *kMetricOtelSdkSpanLiveCount = "otel.sdk.span.live.count";
  268. static constexpr const char *descrMetricOtelSdkSpanLiveCount =
  269. "The number of created spans for which the end operation has not been called yet";
  270. static constexpr const char *unitMetricOtelSdkSpanLiveCount = "{span}";
  271. static inline nostd::unique_ptr<metrics::UpDownCounter<int64_t>>
  272. CreateSyncInt64MetricOtelSdkSpanLiveCount(metrics::Meter *meter)
  273. {
  274. return meter->CreateInt64UpDownCounter(
  275. kMetricOtelSdkSpanLiveCount, descrMetricOtelSdkSpanLiveCount, unitMetricOtelSdkSpanLiveCount);
  276. }
  277. static inline nostd::unique_ptr<metrics::UpDownCounter<double>>
  278. CreateSyncDoubleMetricOtelSdkSpanLiveCount(metrics::Meter *meter)
  279. {
  280. return meter->CreateDoubleUpDownCounter(
  281. kMetricOtelSdkSpanLiveCount, descrMetricOtelSdkSpanLiveCount, unitMetricOtelSdkSpanLiveCount);
  282. }
  283. static inline nostd::shared_ptr<metrics::ObservableInstrument>
  284. CreateAsyncInt64MetricOtelSdkSpanLiveCount(metrics::Meter *meter)
  285. {
  286. return meter->CreateInt64ObservableUpDownCounter(
  287. kMetricOtelSdkSpanLiveCount, descrMetricOtelSdkSpanLiveCount, unitMetricOtelSdkSpanLiveCount);
  288. }
  289. static inline nostd::shared_ptr<metrics::ObservableInstrument>
  290. CreateAsyncDoubleMetricOtelSdkSpanLiveCount(metrics::Meter *meter)
  291. {
  292. return meter->CreateDoubleObservableUpDownCounter(
  293. kMetricOtelSdkSpanLiveCount, descrMetricOtelSdkSpanLiveCount, unitMetricOtelSdkSpanLiveCount);
  294. }
  295. } // namespace otel
  296. } // namespace semconv
  297. OPENTELEMETRY_END_NAMESPACE