@opentelemetry/api 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/build/esm/index.d.ts +1 -1
  2. package/build/esm/index.js.map +1 -1
  3. package/build/esm/metrics/Metric.d.ts +16 -0
  4. package/build/esm/metrics/Metric.js.map +1 -1
  5. package/build/esm/version.d.ts +1 -1
  6. package/build/esm/version.js +1 -1
  7. package/build/esm/version.js.map +1 -1
  8. package/build/esnext/api/context.d.ts +41 -0
  9. package/build/esnext/api/context.js +77 -0
  10. package/build/esnext/api/context.js.map +1 -0
  11. package/build/esnext/api/diag.d.ts +30 -0
  12. package/build/esnext/api/diag.js +89 -0
  13. package/build/esnext/api/diag.js.map +1 -0
  14. package/build/esnext/api/metrics.d.ts +28 -0
  15. package/build/esnext/api/metrics.js +57 -0
  16. package/build/esnext/api/metrics.js.map +1 -0
  17. package/build/esnext/api/propagation.d.ts +49 -0
  18. package/build/esnext/api/propagation.js +85 -0
  19. package/build/esnext/api/propagation.js.map +1 -0
  20. package/build/esnext/api/trace.d.ts +40 -0
  21. package/build/esnext/api/trace.js +75 -0
  22. package/build/esnext/api/trace.js.map +1 -0
  23. package/build/esnext/baggage/context-helpers.d.ts +29 -0
  24. package/build/esnext/baggage/context-helpers.js +56 -0
  25. package/build/esnext/baggage/context-helpers.js.map +1 -0
  26. package/build/esnext/baggage/internal/baggage-impl.d.ts +12 -0
  27. package/build/esnext/baggage/internal/baggage-impl.js +51 -0
  28. package/build/esnext/baggage/internal/baggage-impl.js.map +1 -0
  29. package/build/esnext/baggage/internal/symbol.d.ts +5 -0
  30. package/build/esnext/baggage/internal/symbol.js +20 -0
  31. package/build/esnext/baggage/internal/symbol.js.map +1 -0
  32. package/build/esnext/baggage/types.d.ts +60 -0
  33. package/build/esnext/baggage/types.js +17 -0
  34. package/build/esnext/baggage/types.js.map +1 -0
  35. package/build/esnext/baggage/utils.d.ts +15 -0
  36. package/build/esnext/baggage/utils.js +46 -0
  37. package/build/esnext/baggage/utils.js.map +1 -0
  38. package/build/esnext/common/Attributes.d.ts +15 -0
  39. package/build/esnext/common/Attributes.js +17 -0
  40. package/build/esnext/common/Attributes.js.map +1 -0
  41. package/build/esnext/common/Exception.d.ts +26 -0
  42. package/build/esnext/common/Exception.js +17 -0
  43. package/build/esnext/common/Exception.js.map +1 -0
  44. package/build/esnext/common/Time.d.ts +20 -0
  45. package/build/esnext/common/Time.js +2 -0
  46. package/build/esnext/common/Time.js.map +1 -0
  47. package/build/esnext/context/NoopContextManager.d.ts +9 -0
  48. package/build/esnext/context/NoopContextManager.js +34 -0
  49. package/build/esnext/context/NoopContextManager.js.map +1 -0
  50. package/build/esnext/context/context.d.ts +6 -0
  51. package/build/esnext/context/context.js +51 -0
  52. package/build/esnext/context/context.js.map +1 -0
  53. package/build/esnext/context/types.d.ts +52 -0
  54. package/build/esnext/context/types.js +17 -0
  55. package/build/esnext/context/types.js.map +1 -0
  56. package/build/esnext/context-api.d.ts +4 -0
  57. package/build/esnext/context-api.js +21 -0
  58. package/build/esnext/context-api.js.map +1 -0
  59. package/build/esnext/diag/ComponentLogger.d.ts +20 -0
  60. package/build/esnext/diag/ComponentLogger.js +55 -0
  61. package/build/esnext/diag/ComponentLogger.js.map +1 -0
  62. package/build/esnext/diag/consoleLogger.d.ts +38 -0
  63. package/build/esnext/diag/consoleLogger.js +53 -0
  64. package/build/esnext/diag/consoleLogger.js.map +1 -0
  65. package/build/esnext/diag/internal/logLevelLogger.d.ts +3 -0
  66. package/build/esnext/diag/internal/logLevelLogger.js +41 -0
  67. package/build/esnext/diag/internal/logLevelLogger.js.map +1 -0
  68. package/build/esnext/diag/internal/noopLogger.d.ts +8 -0
  69. package/build/esnext/diag/internal/noopLogger.js +31 -0
  70. package/build/esnext/diag/internal/noopLogger.js.map +1 -0
  71. package/build/esnext/diag/types.d.ts +100 -0
  72. package/build/esnext/diag/types.js +41 -0
  73. package/build/esnext/diag/types.js.map +1 -0
  74. package/build/esnext/diag-api.d.ts +9 -0
  75. package/build/esnext/diag-api.js +26 -0
  76. package/build/esnext/diag-api.js.map +1 -0
  77. package/build/esnext/index.d.ts +54 -0
  78. package/build/esnext/index.js +53 -0
  79. package/build/esnext/index.js.map +1 -0
  80. package/build/esnext/internal/global-utils.d.ts +18 -0
  81. package/build/esnext/internal/global-utils.js +58 -0
  82. package/build/esnext/internal/global-utils.js.map +1 -0
  83. package/build/esnext/internal/semver.d.ts +34 -0
  84. package/build/esnext/internal/semver.js +118 -0
  85. package/build/esnext/internal/semver.js.map +1 -0
  86. package/build/esnext/metrics/Meter.d.ts +104 -0
  87. package/build/esnext/metrics/Meter.js +17 -0
  88. package/build/esnext/metrics/Meter.js.map +1 -0
  89. package/build/esnext/metrics/MeterProvider.d.ts +17 -0
  90. package/build/esnext/metrics/MeterProvider.js +17 -0
  91. package/build/esnext/metrics/MeterProvider.js.map +1 -0
  92. package/build/esnext/metrics/Metric.d.ts +109 -0
  93. package/build/esnext/metrics/Metric.js +22 -0
  94. package/build/esnext/metrics/Metric.js.map +1 -0
  95. package/build/esnext/metrics/NoopMeter.d.ts +74 -0
  96. package/build/esnext/metrics/NoopMeter.js +103 -0
  97. package/build/esnext/metrics/NoopMeter.js.map +1 -0
  98. package/build/esnext/metrics/NoopMeterProvider.d.ts +11 -0
  99. package/build/esnext/metrics/NoopMeterProvider.js +27 -0
  100. package/build/esnext/metrics/NoopMeterProvider.js.map +1 -0
  101. package/build/esnext/metrics/ObservableResult.d.ts +31 -0
  102. package/build/esnext/metrics/ObservableResult.js +17 -0
  103. package/build/esnext/metrics/ObservableResult.js.map +1 -0
  104. package/build/esnext/metrics-api.d.ts +4 -0
  105. package/build/esnext/metrics-api.js +21 -0
  106. package/build/esnext/metrics-api.js.map +1 -0
  107. package/build/esnext/platform/browser/globalThis.d.ts +10 -0
  108. package/build/esnext/platform/browser/globalThis.js +35 -0
  109. package/build/esnext/platform/browser/globalThis.js.map +1 -0
  110. package/build/esnext/platform/browser/index.d.ts +2 -0
  111. package/build/esnext/platform/browser/index.js +17 -0
  112. package/build/esnext/platform/browser/index.js.map +1 -0
  113. package/build/esnext/platform/index.d.ts +2 -0
  114. package/build/esnext/platform/index.js +17 -0
  115. package/build/esnext/platform/index.js.map +1 -0
  116. package/build/esnext/platform/node/globalThis.d.ts +3 -0
  117. package/build/esnext/platform/node/globalThis.js +19 -0
  118. package/build/esnext/platform/node/globalThis.js.map +1 -0
  119. package/build/esnext/platform/node/index.d.ts +2 -0
  120. package/build/esnext/platform/node/index.js +17 -0
  121. package/build/esnext/platform/node/index.js.map +1 -0
  122. package/build/esnext/propagation/NoopTextMapPropagator.d.ts +13 -0
  123. package/build/esnext/propagation/NoopTextMapPropagator.js +30 -0
  124. package/build/esnext/propagation/NoopTextMapPropagator.js.map +1 -0
  125. package/build/esnext/propagation/TextMapPropagator.d.ts +84 -0
  126. package/build/esnext/propagation/TextMapPropagator.js +38 -0
  127. package/build/esnext/propagation/TextMapPropagator.js.map +1 -0
  128. package/build/esnext/propagation-api.d.ts +4 -0
  129. package/build/esnext/propagation-api.js +21 -0
  130. package/build/esnext/propagation-api.js.map +1 -0
  131. package/build/esnext/trace/NonRecordingSpan.d.ts +25 -0
  132. package/build/esnext/trace/NonRecordingSpan.js +59 -0
  133. package/build/esnext/trace/NonRecordingSpan.js.map +1 -0
  134. package/build/esnext/trace/NoopTracer.d.ts +14 -0
  135. package/build/esnext/trace/NoopTracer.js +71 -0
  136. package/build/esnext/trace/NoopTracer.js.map +1 -0
  137. package/build/esnext/trace/NoopTracerProvider.d.ts +13 -0
  138. package/build/esnext/trace/NoopTracerProvider.js +28 -0
  139. package/build/esnext/trace/NoopTracerProvider.js.map +1 -0
  140. package/build/esnext/trace/ProxyTracer.d.ts +27 -0
  141. package/build/esnext/trace/ProxyTracer.js +51 -0
  142. package/build/esnext/trace/ProxyTracer.js.map +1 -0
  143. package/build/esnext/trace/ProxyTracerProvider.d.ts +25 -0
  144. package/build/esnext/trace/ProxyTracerProvider.js +50 -0
  145. package/build/esnext/trace/ProxyTracerProvider.js.map +1 -0
  146. package/build/esnext/trace/Sampler.d.ts +31 -0
  147. package/build/esnext/trace/Sampler.js +17 -0
  148. package/build/esnext/trace/Sampler.js.map +1 -0
  149. package/build/esnext/trace/SamplingResult.d.ts +49 -0
  150. package/build/esnext/trace/SamplingResult.js +39 -0
  151. package/build/esnext/trace/SamplingResult.js.map +1 -0
  152. package/build/esnext/trace/SpanOptions.d.ts +23 -0
  153. package/build/esnext/trace/SpanOptions.js +17 -0
  154. package/build/esnext/trace/SpanOptions.js.map +1 -0
  155. package/build/esnext/trace/attributes.d.ts +10 -0
  156. package/build/esnext/trace/attributes.js +17 -0
  157. package/build/esnext/trace/attributes.js.map +1 -0
  158. package/build/esnext/trace/context-utils.d.ts +41 -0
  159. package/build/esnext/trace/context-utils.js +73 -0
  160. package/build/esnext/trace/context-utils.js.map +1 -0
  161. package/build/esnext/trace/internal/tracestate-impl.d.ts +22 -0
  162. package/build/esnext/trace/internal/tracestate-impl.js +99 -0
  163. package/build/esnext/trace/internal/tracestate-impl.js.map +1 -0
  164. package/build/esnext/trace/internal/tracestate-validators.d.ts +15 -0
  165. package/build/esnext/trace/internal/tracestate-validators.js +41 -0
  166. package/build/esnext/trace/internal/tracestate-validators.js.map +1 -0
  167. package/build/esnext/trace/internal/utils.d.ts +3 -0
  168. package/build/esnext/trace/internal/utils.js +20 -0
  169. package/build/esnext/trace/internal/utils.js.map +1 -0
  170. package/build/esnext/trace/invalid-span-constants.d.ts +5 -0
  171. package/build/esnext/trace/invalid-span-constants.js +24 -0
  172. package/build/esnext/trace/invalid-span-constants.js.map +1 -0
  173. package/build/esnext/trace/link.d.ts +26 -0
  174. package/build/esnext/trace/link.js +17 -0
  175. package/build/esnext/trace/link.js.map +1 -0
  176. package/build/esnext/trace/span.d.ts +101 -0
  177. package/build/esnext/trace/span.js +17 -0
  178. package/build/esnext/trace/span.js.map +1 -0
  179. package/build/esnext/trace/span_context.d.ts +53 -0
  180. package/build/esnext/trace/span_context.js +17 -0
  181. package/build/esnext/trace/span_context.js.map +1 -0
  182. package/build/esnext/trace/span_kind.d.ts +27 -0
  183. package/build/esnext/trace/span_kind.js +43 -0
  184. package/build/esnext/trace/span_kind.js.map +1 -0
  185. package/build/esnext/trace/spancontext-utils.d.ts +17 -0
  186. package/build/esnext/trace/spancontext-utils.js +42 -0
  187. package/build/esnext/trace/spancontext-utils.js.map +1 -0
  188. package/build/esnext/trace/status.d.ts +25 -0
  189. package/build/esnext/trace/status.js +20 -0
  190. package/build/esnext/trace/status.js.map +1 -0
  191. package/build/esnext/trace/trace_flags.d.ts +7 -0
  192. package/build/esnext/trace/trace_flags.js +23 -0
  193. package/build/esnext/trace/trace_flags.js.map +1 -0
  194. package/build/esnext/trace/trace_state.d.ts +38 -0
  195. package/build/esnext/trace/trace_state.js +17 -0
  196. package/build/esnext/trace/trace_state.js.map +1 -0
  197. package/build/esnext/trace/tracer.d.ts +71 -0
  198. package/build/esnext/trace/tracer.js +17 -0
  199. package/build/esnext/trace/tracer.js.map +1 -0
  200. package/build/esnext/trace/tracer_options.d.ts +10 -0
  201. package/build/esnext/trace/tracer_options.js +17 -0
  202. package/build/esnext/trace/tracer_options.js.map +1 -0
  203. package/build/esnext/trace/tracer_provider.d.ts +21 -0
  204. package/build/esnext/trace/tracer_provider.js +17 -0
  205. package/build/esnext/trace/tracer_provider.js.map +1 -0
  206. package/build/esnext/trace-api.d.ts +4 -0
  207. package/build/esnext/trace-api.js +21 -0
  208. package/build/esnext/trace-api.js.map +1 -0
  209. package/build/esnext/version.d.ts +2 -0
  210. package/build/esnext/version.js +18 -0
  211. package/build/esnext/version.js.map +1 -0
  212. package/build/src/index.d.ts +1 -1
  213. package/build/src/index.js.map +1 -1
  214. package/build/src/metrics/Metric.d.ts +16 -0
  215. package/build/src/metrics/Metric.js.map +1 -1
  216. package/build/src/version.d.ts +1 -1
  217. package/build/src/version.js +1 -1
  218. package/build/src/version.js.map +1 -1
  219. package/package.json +11 -6
@@ -0,0 +1,41 @@
1
+ /*
2
+ * Copyright The OpenTelemetry Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Defines the available internal logging levels for the diagnostic logger, the numeric values
18
+ * of the levels are defined to match the original values from the initial LogLevel to avoid
19
+ * compatibility/migration issues for any implementation that assume the numeric ordering.
20
+ */
21
+ export var DiagLogLevel;
22
+ (function (DiagLogLevel) {
23
+ /** Diagnostic Logging level setting to disable all logging (except and forced logs) */
24
+ DiagLogLevel[DiagLogLevel["NONE"] = 0] = "NONE";
25
+ /** Identifies an error scenario */
26
+ DiagLogLevel[DiagLogLevel["ERROR"] = 30] = "ERROR";
27
+ /** Identifies a warning scenario */
28
+ DiagLogLevel[DiagLogLevel["WARN"] = 50] = "WARN";
29
+ /** General informational log message */
30
+ DiagLogLevel[DiagLogLevel["INFO"] = 60] = "INFO";
31
+ /** General debug log message */
32
+ DiagLogLevel[DiagLogLevel["DEBUG"] = 70] = "DEBUG";
33
+ /**
34
+ * Detailed trace level logging should only be used for development, should only be set
35
+ * in a development environment.
36
+ */
37
+ DiagLogLevel[DiagLogLevel["VERBOSE"] = 80] = "VERBOSE";
38
+ /** Used to set the logging level to include all logging */
39
+ DiagLogLevel[DiagLogLevel["ALL"] = 9999] = "ALL";
40
+ })(DiagLogLevel || (DiagLogLevel = {}));
41
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/diag/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA+CH;;;;GAIG;AACH,MAAM,CAAN,IAAY,YAwBX;AAxBD,WAAY,YAAY;IACtB,uFAAuF;IACvF,+CAAQ,CAAA;IAER,mCAAmC;IACnC,kDAAU,CAAA;IAEV,oCAAoC;IACpC,gDAAS,CAAA;IAET,wCAAwC;IACxC,gDAAS,CAAA;IAET,gCAAgC;IAChC,kDAAU,CAAA;IAEV;;;OAGG;IACH,sDAAY,CAAA;IAEZ,2DAA2D;IAC3D,gDAAU,CAAA;AACZ,CAAC,EAxBW,YAAY,KAAZ,YAAY,QAwBvB","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport type DiagLogFunction = (message: string, ...args: unknown[]) => void;\n\n/**\n * Defines an internal diagnostic logger interface which is used to log internal diagnostic\n * messages, you can set the default diagnostic logger via the {@link DiagAPI} setLogger function.\n * API provided implementations include :-\n * - a No-Op {@link createNoopDiagLogger}\n * - a {@link DiagLogLevel} filtering wrapper {@link createLogLevelDiagLogger}\n * - a general Console {@link DiagConsoleLogger} version.\n */\nexport interface DiagLogger {\n /** Log an error scenario that was not expected and caused the requested operation to fail. */\n error: DiagLogFunction;\n\n /**\n * Log a warning scenario to inform the developer of an issues that should be investigated.\n * The requested operation may or may not have succeeded or completed.\n */\n warn: DiagLogFunction;\n\n /**\n * Log a general informational message, this should not affect functionality.\n * This is also the default logging level so this should NOT be used for logging\n * debugging level information.\n */\n info: DiagLogFunction;\n\n /**\n * Log a general debug message that can be useful for identifying a failure.\n * Information logged at this level may include diagnostic details that would\n * help identify a failure scenario.\n * For example: Logging the order of execution of async operations.\n */\n debug: DiagLogFunction;\n\n /**\n * Log a detailed (verbose) trace level logging that can be used to identify failures\n * where debug level logging would be insufficient, this level of tracing can include\n * input and output parameters and as such may include PII information passing through\n * the API. As such it is recommended that this level of tracing should not be enabled\n * in a production environment.\n */\n verbose: DiagLogFunction;\n}\n\n/**\n * Defines the available internal logging levels for the diagnostic logger, the numeric values\n * of the levels are defined to match the original values from the initial LogLevel to avoid\n * compatibility/migration issues for any implementation that assume the numeric ordering.\n */\nexport enum DiagLogLevel {\n /** Diagnostic Logging level setting to disable all logging (except and forced logs) */\n NONE = 0,\n\n /** Identifies an error scenario */\n ERROR = 30,\n\n /** Identifies a warning scenario */\n WARN = 50,\n\n /** General informational log message */\n INFO = 60,\n\n /** General debug log message */\n DEBUG = 70,\n\n /**\n * Detailed trace level logging should only be used for development, should only be set\n * in a development environment.\n */\n VERBOSE = 80,\n\n /** Used to set the logging level to include all logging */\n ALL = 9999,\n}\n\n/**\n * Defines options for ComponentLogger\n */\nexport interface ComponentLoggerOptions {\n namespace: string;\n}\n\nexport interface DiagLoggerOptions {\n /**\n * The {@link DiagLogLevel} used to filter logs sent to the logger.\n *\n * @defaultValue DiagLogLevel.INFO\n */\n logLevel?: DiagLogLevel;\n\n /**\n * Setting this value to `true` will suppress the warning message normally emitted when registering a logger when another logger is already registered.\n */\n suppressOverrideMessage?: boolean;\n}\n\nexport interface DiagLoggerApi {\n /**\n * Set the global DiagLogger and DiagLogLevel.\n * If a global diag logger is already set, this will override it.\n *\n * @param logger - The {@link DiagLogger} instance to set as the default logger.\n * @param options - A {@link DiagLoggerOptions} object. If not provided, default values will be set.\n * @returns `true` if the logger was successfully registered, else `false`\n */\n setLogger(logger: DiagLogger, options?: DiagLoggerOptions): boolean;\n\n /**\n *\n * @param logger - The {@link DiagLogger} instance to set as the default logger.\n * @param logLevel - The {@link DiagLogLevel} used to filter logs sent to the logger. If not provided it will default to {@link DiagLogLevel.INFO}.\n * @returns `true` if the logger was successfully registered, else `false`\n */\n setLogger(logger: DiagLogger, logLevel?: DiagLogLevel): boolean;\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import { DiagAPI } from './api/diag';
2
+ /**
3
+ * Entrypoint for Diag API.
4
+ * Defines Diagnostic handler used for internal diagnostic logging operations.
5
+ * The default provides a Noop DiagLogger implementation which may be changed via the
6
+ * diag.setLogger(logger: DiagLogger) function.
7
+ */
8
+ export declare const diag: DiagAPI;
9
+ //# sourceMappingURL=diag-api.d.ts.map
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Copyright The OpenTelemetry Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ // Split module-level variable definition into separate files to allow
17
+ // tree-shaking on each api instance.
18
+ import { DiagAPI } from './api/diag';
19
+ /**
20
+ * Entrypoint for Diag API.
21
+ * Defines Diagnostic handler used for internal diagnostic logging operations.
22
+ * The default provides a Noop DiagLogger implementation which may be changed via the
23
+ * diag.setLogger(logger: DiagLogger) function.
24
+ */
25
+ export const diag = DiagAPI.instance();
26
+ //# sourceMappingURL=diag-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diag-api.js","sourceRoot":"","sources":["../../src/diag-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,sEAAsE;AACtE,qCAAqC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Split module-level variable definition into separate files to allow\n// tree-shaking on each api instance.\nimport { DiagAPI } from './api/diag';\n/**\n * Entrypoint for Diag API.\n * Defines Diagnostic handler used for internal diagnostic logging operations.\n * The default provides a Noop DiagLogger implementation which may be changed via the\n * diag.setLogger(logger: DiagLogger) function.\n */\nexport const diag = DiagAPI.instance();\n"]}
@@ -0,0 +1,54 @@
1
+ export { BaggageEntry, BaggageEntryMetadata, Baggage } from './baggage/types';
2
+ export { baggageEntryMetadataFromString } from './baggage/utils';
3
+ export { Exception } from './common/Exception';
4
+ export { HrTime, TimeInput } from './common/Time';
5
+ export { Attributes, AttributeValue } from './common/Attributes';
6
+ export { createContextKey, ROOT_CONTEXT } from './context/context';
7
+ export { Context, ContextManager } from './context/types';
8
+ export type { ContextAPI } from './api/context';
9
+ export { DiagConsoleLogger } from './diag/consoleLogger';
10
+ export { DiagLogFunction, DiagLogger, DiagLogLevel, ComponentLoggerOptions, DiagLoggerOptions, } from './diag/types';
11
+ export type { DiagAPI } from './api/diag';
12
+ export { createNoopMeter } from './metrics/NoopMeter';
13
+ export { MeterOptions, Meter } from './metrics/Meter';
14
+ export { MeterProvider } from './metrics/MeterProvider';
15
+ export { ValueType, Counter, Histogram, MetricOptions, Observable, ObservableCounter, ObservableGauge, ObservableUpDownCounter, UpDownCounter, BatchObservableCallback, MetricAdvice, MetricAttributes, MetricAttributeValue, ObservableCallback, } from './metrics/Metric';
16
+ export { BatchObservableResult, ObservableResult, } from './metrics/ObservableResult';
17
+ export type { MetricsAPI } from './api/metrics';
18
+ export { TextMapPropagator, TextMapSetter, TextMapGetter, defaultTextMapGetter, defaultTextMapSetter, } from './propagation/TextMapPropagator';
19
+ export type { PropagationAPI } from './api/propagation';
20
+ export { SpanAttributes, SpanAttributeValue } from './trace/attributes';
21
+ export { Link } from './trace/link';
22
+ export { ProxyTracer, TracerDelegator } from './trace/ProxyTracer';
23
+ export { ProxyTracerProvider } from './trace/ProxyTracerProvider';
24
+ export { Sampler } from './trace/Sampler';
25
+ export { SamplingDecision, SamplingResult } from './trace/SamplingResult';
26
+ export { SpanContext } from './trace/span_context';
27
+ export { SpanKind } from './trace/span_kind';
28
+ export { Span } from './trace/span';
29
+ export { SpanOptions } from './trace/SpanOptions';
30
+ export { SpanStatus, SpanStatusCode } from './trace/status';
31
+ export { TraceFlags } from './trace/trace_flags';
32
+ export { TraceState } from './trace/trace_state';
33
+ export { createTraceState } from './trace/internal/utils';
34
+ export { TracerProvider } from './trace/tracer_provider';
35
+ export { Tracer } from './trace/tracer';
36
+ export { TracerOptions } from './trace/tracer_options';
37
+ export { isSpanContextValid, isValidTraceId, isValidSpanId, } from './trace/spancontext-utils';
38
+ export { INVALID_SPANID, INVALID_TRACEID, INVALID_SPAN_CONTEXT, } from './trace/invalid-span-constants';
39
+ export type { TraceAPI } from './api/trace';
40
+ import { context } from './context-api';
41
+ import { diag } from './diag-api';
42
+ import { metrics } from './metrics-api';
43
+ import { propagation } from './propagation-api';
44
+ import { trace } from './trace-api';
45
+ export { context, diag, metrics, propagation, trace };
46
+ declare const _default: {
47
+ context: import("./api/context").ContextAPI;
48
+ diag: import("./api/diag").DiagAPI;
49
+ metrics: import("./api/metrics").MetricsAPI;
50
+ propagation: import("./api/propagation").PropagationAPI;
51
+ trace: import("./api/trace").TraceAPI;
52
+ };
53
+ export default _default;
54
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,53 @@
1
+ /*
2
+ * Copyright The OpenTelemetry Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export { baggageEntryMetadataFromString } from './baggage/utils';
17
+ // Context APIs
18
+ export { createContextKey, ROOT_CONTEXT } from './context/context';
19
+ // Diag APIs
20
+ export { DiagConsoleLogger } from './diag/consoleLogger';
21
+ export { DiagLogLevel, } from './diag/types';
22
+ // Metrics APIs
23
+ export { createNoopMeter } from './metrics/NoopMeter';
24
+ export { ValueType, } from './metrics/Metric';
25
+ // Propagation APIs
26
+ export { defaultTextMapGetter, defaultTextMapSetter, } from './propagation/TextMapPropagator';
27
+ export { ProxyTracer } from './trace/ProxyTracer';
28
+ export { ProxyTracerProvider } from './trace/ProxyTracerProvider';
29
+ export { SamplingDecision } from './trace/SamplingResult';
30
+ export { SpanKind } from './trace/span_kind';
31
+ export { SpanStatusCode } from './trace/status';
32
+ export { TraceFlags } from './trace/trace_flags';
33
+ export { createTraceState } from './trace/internal/utils';
34
+ export { isSpanContextValid, isValidTraceId, isValidSpanId, } from './trace/spancontext-utils';
35
+ export { INVALID_SPANID, INVALID_TRACEID, INVALID_SPAN_CONTEXT, } from './trace/invalid-span-constants';
36
+ // Split module-level variable definition into separate files to allow
37
+ // tree-shaking on each api instance.
38
+ import { context } from './context-api';
39
+ import { diag } from './diag-api';
40
+ import { metrics } from './metrics-api';
41
+ import { propagation } from './propagation-api';
42
+ import { trace } from './trace-api';
43
+ // Named export.
44
+ export { context, diag, metrics, propagation, trace };
45
+ // Default export.
46
+ export default {
47
+ context,
48
+ diag,
49
+ metrics,
50
+ propagation,
51
+ trace,
52
+ };
53
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,8BAA8B,EAAE,MAAM,iBAAiB,CAAC;AAKjE,eAAe;AACf,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAInE,YAAY;AACZ,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAGL,YAAY,GAGb,MAAM,cAAc,CAAC;AAGtB,eAAe;AACf,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,EACL,SAAS,GAcV,MAAM,kBAAkB,CAAC;AAO1B,mBAAmB;AACnB,OAAO,EAIL,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,iCAAiC,CAAC;AAMzC,OAAO,EAAE,WAAW,EAAmB,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE,OAAO,EAAE,gBAAgB,EAAkB,MAAM,wBAAwB,CAAC;AAE1E,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,OAAO,EAAc,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAI1D,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,aAAa,GACd,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,cAAc,EACd,eAAe,EACf,oBAAoB,GACrB,MAAM,gCAAgC,CAAC;AAGxC,sEAAsE;AACtE,qCAAqC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,gBAAgB;AAChB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;AACtD,kBAAkB;AAClB,eAAe;IACb,OAAO;IACP,IAAI;IACJ,OAAO;IACP,WAAW;IACX,KAAK;CACN,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { BaggageEntry, BaggageEntryMetadata, Baggage } from './baggage/types';\nexport { baggageEntryMetadataFromString } from './baggage/utils';\nexport { Exception } from './common/Exception';\nexport { HrTime, TimeInput } from './common/Time';\nexport { Attributes, AttributeValue } from './common/Attributes';\n\n// Context APIs\nexport { createContextKey, ROOT_CONTEXT } from './context/context';\nexport { Context, ContextManager } from './context/types';\nexport type { ContextAPI } from './api/context';\n\n// Diag APIs\nexport { DiagConsoleLogger } from './diag/consoleLogger';\nexport {\n DiagLogFunction,\n DiagLogger,\n DiagLogLevel,\n ComponentLoggerOptions,\n DiagLoggerOptions,\n} from './diag/types';\nexport type { DiagAPI } from './api/diag';\n\n// Metrics APIs\nexport { createNoopMeter } from './metrics/NoopMeter';\nexport { MeterOptions, Meter } from './metrics/Meter';\nexport { MeterProvider } from './metrics/MeterProvider';\nexport {\n ValueType,\n Counter,\n Histogram,\n MetricOptions,\n Observable,\n ObservableCounter,\n ObservableGauge,\n ObservableUpDownCounter,\n UpDownCounter,\n BatchObservableCallback,\n MetricAdvice,\n MetricAttributes,\n MetricAttributeValue,\n ObservableCallback,\n} from './metrics/Metric';\nexport {\n BatchObservableResult,\n ObservableResult,\n} from './metrics/ObservableResult';\nexport type { MetricsAPI } from './api/metrics';\n\n// Propagation APIs\nexport {\n TextMapPropagator,\n TextMapSetter,\n TextMapGetter,\n defaultTextMapGetter,\n defaultTextMapSetter,\n} from './propagation/TextMapPropagator';\nexport type { PropagationAPI } from './api/propagation';\n\n// Trace APIs\nexport { SpanAttributes, SpanAttributeValue } from './trace/attributes';\nexport { Link } from './trace/link';\nexport { ProxyTracer, TracerDelegator } from './trace/ProxyTracer';\nexport { ProxyTracerProvider } from './trace/ProxyTracerProvider';\nexport { Sampler } from './trace/Sampler';\nexport { SamplingDecision, SamplingResult } from './trace/SamplingResult';\nexport { SpanContext } from './trace/span_context';\nexport { SpanKind } from './trace/span_kind';\nexport { Span } from './trace/span';\nexport { SpanOptions } from './trace/SpanOptions';\nexport { SpanStatus, SpanStatusCode } from './trace/status';\nexport { TraceFlags } from './trace/trace_flags';\nexport { TraceState } from './trace/trace_state';\nexport { createTraceState } from './trace/internal/utils';\nexport { TracerProvider } from './trace/tracer_provider';\nexport { Tracer } from './trace/tracer';\nexport { TracerOptions } from './trace/tracer_options';\nexport {\n isSpanContextValid,\n isValidTraceId,\n isValidSpanId,\n} from './trace/spancontext-utils';\nexport {\n INVALID_SPANID,\n INVALID_TRACEID,\n INVALID_SPAN_CONTEXT,\n} from './trace/invalid-span-constants';\nexport type { TraceAPI } from './api/trace';\n\n// Split module-level variable definition into separate files to allow\n// tree-shaking on each api instance.\nimport { context } from './context-api';\nimport { diag } from './diag-api';\nimport { metrics } from './metrics-api';\nimport { propagation } from './propagation-api';\nimport { trace } from './trace-api';\n\n// Named export.\nexport { context, diag, metrics, propagation, trace };\n// Default export.\nexport default {\n context,\n diag,\n metrics,\n propagation,\n trace,\n};\n"]}
@@ -0,0 +1,18 @@
1
+ import { MeterProvider } from '../metrics/MeterProvider';
2
+ import { ContextManager } from '../context/types';
3
+ import { DiagLogger } from '../diag/types';
4
+ import { TextMapPropagator } from '../propagation/TextMapPropagator';
5
+ import type { TracerProvider } from '../trace/tracer_provider';
6
+ export declare function registerGlobal<Type extends keyof OTelGlobalAPI>(type: Type, instance: OTelGlobalAPI[Type], diag: DiagLogger, allowOverride?: boolean): boolean;
7
+ export declare function getGlobal<Type extends keyof OTelGlobalAPI>(type: Type): OTelGlobalAPI[Type] | undefined;
8
+ export declare function unregisterGlobal(type: keyof OTelGlobalAPI, diag: DiagLogger): void;
9
+ declare type OTelGlobalAPI = {
10
+ version: string;
11
+ diag?: DiagLogger;
12
+ trace?: TracerProvider;
13
+ context?: ContextManager;
14
+ metrics?: MeterProvider;
15
+ propagation?: TextMapPropagator;
16
+ };
17
+ export {};
18
+ //# sourceMappingURL=global-utils.d.ts.map
@@ -0,0 +1,58 @@
1
+ /*
2
+ * Copyright The OpenTelemetry Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { _globalThis } from '../platform';
17
+ import { VERSION } from '../version';
18
+ import { isCompatible } from './semver';
19
+ const major = VERSION.split('.')[0];
20
+ const GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for(`opentelemetry.js.api.${major}`);
21
+ const _global = _globalThis;
22
+ export function registerGlobal(type, instance, diag, allowOverride = false) {
23
+ var _a;
24
+ const api = (_global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a !== void 0 ? _a : {
25
+ version: VERSION,
26
+ });
27
+ if (!allowOverride && api[type]) {
28
+ // already registered an API of this type
29
+ const err = new Error(`@opentelemetry/api: Attempted duplicate registration of API: ${type}`);
30
+ diag.error(err.stack || err.message);
31
+ return false;
32
+ }
33
+ if (api.version !== VERSION) {
34
+ // All registered APIs must be of the same version exactly
35
+ const err = new Error(`@opentelemetry/api: Registration of version v${api.version} for ${type} does not match previously registered API v${VERSION}`);
36
+ diag.error(err.stack || err.message);
37
+ return false;
38
+ }
39
+ api[type] = instance;
40
+ diag.debug(`@opentelemetry/api: Registered a global for ${type} v${VERSION}.`);
41
+ return true;
42
+ }
43
+ export function getGlobal(type) {
44
+ var _a, _b;
45
+ const globalVersion = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a === void 0 ? void 0 : _a.version;
46
+ if (!globalVersion || !isCompatible(globalVersion)) {
47
+ return;
48
+ }
49
+ return (_b = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b === void 0 ? void 0 : _b[type];
50
+ }
51
+ export function unregisterGlobal(type, diag) {
52
+ diag.debug(`@opentelemetry/api: Unregistering a global for ${type} v${VERSION}.`);
53
+ const api = _global[GLOBAL_OPENTELEMETRY_API_KEY];
54
+ if (api) {
55
+ delete api[type];
56
+ }
57
+ }
58
+ //# sourceMappingURL=global-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global-utils.js","sourceRoot":"","sources":["../../../src/internal/global-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACpC,MAAM,4BAA4B,GAAG,MAAM,CAAC,GAAG,CAC7C,wBAAwB,KAAK,EAAE,CAChC,CAAC;AAEF,MAAM,OAAO,GAAG,WAAyB,CAAC;AAE1C,MAAM,UAAU,cAAc,CAC5B,IAAU,EACV,QAA6B,EAC7B,IAAgB,EAChB,aAAa,GAAG,KAAK;;IAErB,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,4BAA4B,CAAC,GAAG,MAAA,OAAO,CAC1D,4BAA4B,CAC7B,mCAAI;QACH,OAAO,EAAE,OAAO;KACjB,CAAC,CAAC;IAEH,IAAI,CAAC,aAAa,IAAI,GAAG,CAAC,IAAI,CAAC,EAAE;QAC/B,yCAAyC;QACzC,MAAM,GAAG,GAAG,IAAI,KAAK,CACnB,gEAAgE,IAAI,EAAE,CACvE,CAAC;QACF,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;QACrC,OAAO,KAAK,CAAC;KACd;IAED,IAAI,GAAG,CAAC,OAAO,KAAK,OAAO,EAAE;QAC3B,0DAA0D;QAC1D,MAAM,GAAG,GAAG,IAAI,KAAK,CACnB,gDAAgD,GAAG,CAAC,OAAO,QAAQ,IAAI,8CAA8C,OAAO,EAAE,CAC/H,CAAC;QACF,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;QACrC,OAAO,KAAK,CAAC;KACd;IAED,GAAG,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC;IACrB,IAAI,CAAC,KAAK,CACR,+CAA+C,IAAI,KAAK,OAAO,GAAG,CACnE,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,SAAS,CACvB,IAAU;;IAEV,MAAM,aAAa,GAAG,MAAA,OAAO,CAAC,4BAA4B,CAAC,0CAAE,OAAO,CAAC;IACrE,IAAI,CAAC,aAAa,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,EAAE;QAClD,OAAO;KACR;IACD,OAAO,MAAA,OAAO,CAAC,4BAA4B,CAAC,0CAAG,IAAI,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,IAAyB,EAAE,IAAgB;IAC1E,IAAI,CAAC,KAAK,CACR,kDAAkD,IAAI,KAAK,OAAO,GAAG,CACtE,CAAC;IACF,MAAM,GAAG,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;IAElD,IAAI,GAAG,EAAE;QACP,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC;KAClB;AACH,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { MeterProvider } from '../metrics/MeterProvider';\nimport { ContextManager } from '../context/types';\nimport { DiagLogger } from '../diag/types';\nimport { _globalThis } from '../platform';\nimport { TextMapPropagator } from '../propagation/TextMapPropagator';\nimport type { TracerProvider } from '../trace/tracer_provider';\nimport { VERSION } from '../version';\nimport { isCompatible } from './semver';\n\nconst major = VERSION.split('.')[0];\nconst GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for(\n `opentelemetry.js.api.${major}`\n);\n\nconst _global = _globalThis as OTelGlobal;\n\nexport function registerGlobal<Type extends keyof OTelGlobalAPI>(\n type: Type,\n instance: OTelGlobalAPI[Type],\n diag: DiagLogger,\n allowOverride = false\n): boolean {\n const api = (_global[GLOBAL_OPENTELEMETRY_API_KEY] = _global[\n GLOBAL_OPENTELEMETRY_API_KEY\n ] ?? {\n version: VERSION,\n });\n\n if (!allowOverride && api[type]) {\n // already registered an API of this type\n const err = new Error(\n `@opentelemetry/api: Attempted duplicate registration of API: ${type}`\n );\n diag.error(err.stack || err.message);\n return false;\n }\n\n if (api.version !== VERSION) {\n // All registered APIs must be of the same version exactly\n const err = new Error(\n `@opentelemetry/api: Registration of version v${api.version} for ${type} does not match previously registered API v${VERSION}`\n );\n diag.error(err.stack || err.message);\n return false;\n }\n\n api[type] = instance;\n diag.debug(\n `@opentelemetry/api: Registered a global for ${type} v${VERSION}.`\n );\n\n return true;\n}\n\nexport function getGlobal<Type extends keyof OTelGlobalAPI>(\n type: Type\n): OTelGlobalAPI[Type] | undefined {\n const globalVersion = _global[GLOBAL_OPENTELEMETRY_API_KEY]?.version;\n if (!globalVersion || !isCompatible(globalVersion)) {\n return;\n }\n return _global[GLOBAL_OPENTELEMETRY_API_KEY]?.[type];\n}\n\nexport function unregisterGlobal(type: keyof OTelGlobalAPI, diag: DiagLogger) {\n diag.debug(\n `@opentelemetry/api: Unregistering a global for ${type} v${VERSION}.`\n );\n const api = _global[GLOBAL_OPENTELEMETRY_API_KEY];\n\n if (api) {\n delete api[type];\n }\n}\n\ntype OTelGlobal = {\n [GLOBAL_OPENTELEMETRY_API_KEY]?: OTelGlobalAPI;\n};\n\ntype OTelGlobalAPI = {\n version: string;\n\n diag?: DiagLogger;\n trace?: TracerProvider;\n context?: ContextManager;\n metrics?: MeterProvider;\n propagation?: TextMapPropagator;\n};\n"]}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Create a function to test an API version to see if it is compatible with the provided ownVersion.
3
+ *
4
+ * The returned function has the following semantics:
5
+ * - Exact match is always compatible
6
+ * - Major versions must match exactly
7
+ * - 1.x package cannot use global 2.x package
8
+ * - 2.x package cannot use global 1.x package
9
+ * - The minor version of the API module requesting access to the global API must be less than or equal to the minor version of this API
10
+ * - 1.3 package may use 1.4 global because the later global contains all functions 1.3 expects
11
+ * - 1.4 package may NOT use 1.3 global because it may try to call functions which don't exist on 1.3
12
+ * - If the major version is 0, the minor version is treated as the major and the patch is treated as the minor
13
+ * - Patch and build tag differences are not considered at this time
14
+ *
15
+ * @param ownVersion version which should be checked against
16
+ */
17
+ export declare function _makeCompatibilityCheck(ownVersion: string): (globalVersion: string) => boolean;
18
+ /**
19
+ * Test an API version to see if it is compatible with this API.
20
+ *
21
+ * - Exact match is always compatible
22
+ * - Major versions must match exactly
23
+ * - 1.x package cannot use global 2.x package
24
+ * - 2.x package cannot use global 1.x package
25
+ * - The minor version of the API module requesting access to the global API must be less than or equal to the minor version of this API
26
+ * - 1.3 package may use 1.4 global because the later global contains all functions 1.3 expects
27
+ * - 1.4 package may NOT use 1.3 global because it may try to call functions which don't exist on 1.3
28
+ * - If the major version is 0, the minor version is treated as the major and the patch is treated as the minor
29
+ * - Patch and build tag differences are not considered at this time
30
+ *
31
+ * @param version version of the API requesting an instance of the global API
32
+ */
33
+ export declare const isCompatible: (globalVersion: string) => boolean;
34
+ //# sourceMappingURL=semver.d.ts.map
@@ -0,0 +1,118 @@
1
+ /*
2
+ * Copyright The OpenTelemetry Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { VERSION } from '../version';
17
+ const re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
18
+ /**
19
+ * Create a function to test an API version to see if it is compatible with the provided ownVersion.
20
+ *
21
+ * The returned function has the following semantics:
22
+ * - Exact match is always compatible
23
+ * - Major versions must match exactly
24
+ * - 1.x package cannot use global 2.x package
25
+ * - 2.x package cannot use global 1.x package
26
+ * - The minor version of the API module requesting access to the global API must be less than or equal to the minor version of this API
27
+ * - 1.3 package may use 1.4 global because the later global contains all functions 1.3 expects
28
+ * - 1.4 package may NOT use 1.3 global because it may try to call functions which don't exist on 1.3
29
+ * - If the major version is 0, the minor version is treated as the major and the patch is treated as the minor
30
+ * - Patch and build tag differences are not considered at this time
31
+ *
32
+ * @param ownVersion version which should be checked against
33
+ */
34
+ export function _makeCompatibilityCheck(ownVersion) {
35
+ const acceptedVersions = new Set([ownVersion]);
36
+ const rejectedVersions = new Set();
37
+ const myVersionMatch = ownVersion.match(re);
38
+ if (!myVersionMatch) {
39
+ // we cannot guarantee compatibility so we always return noop
40
+ return () => false;
41
+ }
42
+ const ownVersionParsed = {
43
+ major: +myVersionMatch[1],
44
+ minor: +myVersionMatch[2],
45
+ patch: +myVersionMatch[3],
46
+ prerelease: myVersionMatch[4],
47
+ };
48
+ // if ownVersion has a prerelease tag, versions must match exactly
49
+ if (ownVersionParsed.prerelease != null) {
50
+ return function isExactmatch(globalVersion) {
51
+ return globalVersion === ownVersion;
52
+ };
53
+ }
54
+ function _reject(v) {
55
+ rejectedVersions.add(v);
56
+ return false;
57
+ }
58
+ function _accept(v) {
59
+ acceptedVersions.add(v);
60
+ return true;
61
+ }
62
+ return function isCompatible(globalVersion) {
63
+ if (acceptedVersions.has(globalVersion)) {
64
+ return true;
65
+ }
66
+ if (rejectedVersions.has(globalVersion)) {
67
+ return false;
68
+ }
69
+ const globalVersionMatch = globalVersion.match(re);
70
+ if (!globalVersionMatch) {
71
+ // cannot parse other version
72
+ // we cannot guarantee compatibility so we always noop
73
+ return _reject(globalVersion);
74
+ }
75
+ const globalVersionParsed = {
76
+ major: +globalVersionMatch[1],
77
+ minor: +globalVersionMatch[2],
78
+ patch: +globalVersionMatch[3],
79
+ prerelease: globalVersionMatch[4],
80
+ };
81
+ // if globalVersion has a prerelease tag, versions must match exactly
82
+ if (globalVersionParsed.prerelease != null) {
83
+ return _reject(globalVersion);
84
+ }
85
+ // major versions must match
86
+ if (ownVersionParsed.major !== globalVersionParsed.major) {
87
+ return _reject(globalVersion);
88
+ }
89
+ if (ownVersionParsed.major === 0) {
90
+ if (ownVersionParsed.minor === globalVersionParsed.minor &&
91
+ ownVersionParsed.patch <= globalVersionParsed.patch) {
92
+ return _accept(globalVersion);
93
+ }
94
+ return _reject(globalVersion);
95
+ }
96
+ if (ownVersionParsed.minor <= globalVersionParsed.minor) {
97
+ return _accept(globalVersion);
98
+ }
99
+ return _reject(globalVersion);
100
+ };
101
+ }
102
+ /**
103
+ * Test an API version to see if it is compatible with this API.
104
+ *
105
+ * - Exact match is always compatible
106
+ * - Major versions must match exactly
107
+ * - 1.x package cannot use global 2.x package
108
+ * - 2.x package cannot use global 1.x package
109
+ * - The minor version of the API module requesting access to the global API must be less than or equal to the minor version of this API
110
+ * - 1.3 package may use 1.4 global because the later global contains all functions 1.3 expects
111
+ * - 1.4 package may NOT use 1.3 global because it may try to call functions which don't exist on 1.3
112
+ * - If the major version is 0, the minor version is treated as the major and the patch is treated as the minor
113
+ * - Patch and build tag differences are not considered at this time
114
+ *
115
+ * @param version version of the API requesting an instance of the global API
116
+ */
117
+ export const isCompatible = _makeCompatibilityCheck(VERSION);
118
+ //# sourceMappingURL=semver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semver.js","sourceRoot":"","sources":["../../../src/internal/semver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,EAAE,GAAG,+BAA+B,CAAC;AAE3C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,uBAAuB,CACrC,UAAkB;IAElB,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAS,CAAC,UAAU,CAAC,CAAC,CAAC;IACvD,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;IAE3C,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC5C,IAAI,CAAC,cAAc,EAAE;QACnB,6DAA6D;QAC7D,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC;KACpB;IAED,MAAM,gBAAgB,GAAG;QACvB,KAAK,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;QACzB,KAAK,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;QACzB,KAAK,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;QACzB,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC;KAC9B,CAAC;IAEF,kEAAkE;IAClE,IAAI,gBAAgB,CAAC,UAAU,IAAI,IAAI,EAAE;QACvC,OAAO,SAAS,YAAY,CAAC,aAAqB;YAChD,OAAO,aAAa,KAAK,UAAU,CAAC;QACtC,CAAC,CAAC;KACH;IAED,SAAS,OAAO,CAAC,CAAS;QACxB,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,SAAS,OAAO,CAAC,CAAS;QACxB,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,SAAS,YAAY,CAAC,aAAqB;QAChD,IAAI,gBAAgB,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;YACvC,OAAO,IAAI,CAAC;SACb;QAED,IAAI,gBAAgB,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;YACvC,OAAO,KAAK,CAAC;SACd;QAED,MAAM,kBAAkB,GAAG,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACnD,IAAI,CAAC,kBAAkB,EAAE;YACvB,6BAA6B;YAC7B,sDAAsD;YACtD,OAAO,OAAO,CAAC,aAAa,CAAC,CAAC;SAC/B;QAED,MAAM,mBAAmB,GAAG;YAC1B,KAAK,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC;YAC7B,KAAK,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC;YAC7B,KAAK,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC;YAC7B,UAAU,EAAE,kBAAkB,CAAC,CAAC,CAAC;SAClC,CAAC;QAEF,qEAAqE;QACrE,IAAI,mBAAmB,CAAC,UAAU,IAAI,IAAI,EAAE;YAC1C,OAAO,OAAO,CAAC,aAAa,CAAC,CAAC;SAC/B;QAED,4BAA4B;QAC5B,IAAI,gBAAgB,CAAC,KAAK,KAAK,mBAAmB,CAAC,KAAK,EAAE;YACxD,OAAO,OAAO,CAAC,aAAa,CAAC,CAAC;SAC/B;QAED,IAAI,gBAAgB,CAAC,KAAK,KAAK,CAAC,EAAE;YAChC,IACE,gBAAgB,CAAC,KAAK,KAAK,mBAAmB,CAAC,KAAK;gBACpD,gBAAgB,CAAC,KAAK,IAAI,mBAAmB,CAAC,KAAK,EACnD;gBACA,OAAO,OAAO,CAAC,aAAa,CAAC,CAAC;aAC/B;YAED,OAAO,OAAO,CAAC,aAAa,CAAC,CAAC;SAC/B;QAED,IAAI,gBAAgB,CAAC,KAAK,IAAI,mBAAmB,CAAC,KAAK,EAAE;YACvD,OAAO,OAAO,CAAC,aAAa,CAAC,CAAC;SAC/B;QAED,OAAO,OAAO,CAAC,aAAa,CAAC,CAAC;IAChC,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { VERSION } from '../version';\n\nconst re = /^(\\d+)\\.(\\d+)\\.(\\d+)(-(.+))?$/;\n\n/**\n * Create a function to test an API version to see if it is compatible with the provided ownVersion.\n *\n * The returned function has the following semantics:\n * - Exact match is always compatible\n * - Major versions must match exactly\n * - 1.x package cannot use global 2.x package\n * - 2.x package cannot use global 1.x package\n * - The minor version of the API module requesting access to the global API must be less than or equal to the minor version of this API\n * - 1.3 package may use 1.4 global because the later global contains all functions 1.3 expects\n * - 1.4 package may NOT use 1.3 global because it may try to call functions which don't exist on 1.3\n * - If the major version is 0, the minor version is treated as the major and the patch is treated as the minor\n * - Patch and build tag differences are not considered at this time\n *\n * @param ownVersion version which should be checked against\n */\nexport function _makeCompatibilityCheck(\n ownVersion: string\n): (globalVersion: string) => boolean {\n const acceptedVersions = new Set<string>([ownVersion]);\n const rejectedVersions = new Set<string>();\n\n const myVersionMatch = ownVersion.match(re);\n if (!myVersionMatch) {\n // we cannot guarantee compatibility so we always return noop\n return () => false;\n }\n\n const ownVersionParsed = {\n major: +myVersionMatch[1],\n minor: +myVersionMatch[2],\n patch: +myVersionMatch[3],\n prerelease: myVersionMatch[4],\n };\n\n // if ownVersion has a prerelease tag, versions must match exactly\n if (ownVersionParsed.prerelease != null) {\n return function isExactmatch(globalVersion: string): boolean {\n return globalVersion === ownVersion;\n };\n }\n\n function _reject(v: string) {\n rejectedVersions.add(v);\n return false;\n }\n\n function _accept(v: string) {\n acceptedVersions.add(v);\n return true;\n }\n\n return function isCompatible(globalVersion: string): boolean {\n if (acceptedVersions.has(globalVersion)) {\n return true;\n }\n\n if (rejectedVersions.has(globalVersion)) {\n return false;\n }\n\n const globalVersionMatch = globalVersion.match(re);\n if (!globalVersionMatch) {\n // cannot parse other version\n // we cannot guarantee compatibility so we always noop\n return _reject(globalVersion);\n }\n\n const globalVersionParsed = {\n major: +globalVersionMatch[1],\n minor: +globalVersionMatch[2],\n patch: +globalVersionMatch[3],\n prerelease: globalVersionMatch[4],\n };\n\n // if globalVersion has a prerelease tag, versions must match exactly\n if (globalVersionParsed.prerelease != null) {\n return _reject(globalVersion);\n }\n\n // major versions must match\n if (ownVersionParsed.major !== globalVersionParsed.major) {\n return _reject(globalVersion);\n }\n\n if (ownVersionParsed.major === 0) {\n if (\n ownVersionParsed.minor === globalVersionParsed.minor &&\n ownVersionParsed.patch <= globalVersionParsed.patch\n ) {\n return _accept(globalVersion);\n }\n\n return _reject(globalVersion);\n }\n\n if (ownVersionParsed.minor <= globalVersionParsed.minor) {\n return _accept(globalVersion);\n }\n\n return _reject(globalVersion);\n };\n}\n\n/**\n * Test an API version to see if it is compatible with this API.\n *\n * - Exact match is always compatible\n * - Major versions must match exactly\n * - 1.x package cannot use global 2.x package\n * - 2.x package cannot use global 1.x package\n * - The minor version of the API module requesting access to the global API must be less than or equal to the minor version of this API\n * - 1.3 package may use 1.4 global because the later global contains all functions 1.3 expects\n * - 1.4 package may NOT use 1.3 global because it may try to call functions which don't exist on 1.3\n * - If the major version is 0, the minor version is treated as the major and the patch is treated as the minor\n * - Patch and build tag differences are not considered at this time\n *\n * @param version version of the API requesting an instance of the global API\n */\nexport const isCompatible = _makeCompatibilityCheck(VERSION);\n"]}
@@ -0,0 +1,104 @@
1
+ import { BatchObservableCallback, Counter, Histogram, MetricAttributes, MetricOptions, Observable, ObservableCounter, ObservableGauge, ObservableUpDownCounter, UpDownCounter } from './Metric';
2
+ /**
3
+ * An interface describes additional metadata of a meter.
4
+ */
5
+ export interface MeterOptions {
6
+ /**
7
+ * The schemaUrl of the meter or instrumentation library
8
+ */
9
+ schemaUrl?: string;
10
+ }
11
+ /**
12
+ * An interface to allow the recording metrics.
13
+ *
14
+ * {@link Metric}s are used for recording pre-defined aggregation (`Counter`),
15
+ * or raw values (`Histogram`) in which the aggregation and attributes
16
+ * for the exported metric are deferred.
17
+ */
18
+ export interface Meter {
19
+ /**
20
+ * Creates and returns a new `Histogram`.
21
+ * @param name the name of the metric.
22
+ * @param [options] the metric options.
23
+ */
24
+ createHistogram<AttributesTypes extends MetricAttributes = MetricAttributes>(name: string, options?: MetricOptions): Histogram<AttributesTypes>;
25
+ /**
26
+ * Creates a new `Counter` metric. Generally, this kind of metric when the
27
+ * value is a quantity, the sum is of primary interest, and the event count
28
+ * and value distribution are not of primary interest.
29
+ * @param name the name of the metric.
30
+ * @param [options] the metric options.
31
+ */
32
+ createCounter<AttributesTypes extends MetricAttributes = MetricAttributes>(name: string, options?: MetricOptions): Counter<AttributesTypes>;
33
+ /**
34
+ * Creates a new `UpDownCounter` metric. UpDownCounter is a synchronous
35
+ * instrument and very similar to Counter except that Add(increment)
36
+ * supports negative increments. It is generally useful for capturing changes
37
+ * in an amount of resources used, or any quantity that rises and falls
38
+ * during a request.
39
+ * Example uses for UpDownCounter:
40
+ * <ol>
41
+ * <li> count the number of active requests. </li>
42
+ * <li> count memory in use by instrumenting new and delete. </li>
43
+ * <li> count queue size by instrumenting enqueue and dequeue. </li>
44
+ * <li> count semaphore up and down operations. </li>
45
+ * </ol>
46
+ *
47
+ * @param name the name of the metric.
48
+ * @param [options] the metric options.
49
+ */
50
+ createUpDownCounter<AttributesTypes extends MetricAttributes = MetricAttributes>(name: string, options?: MetricOptions): UpDownCounter<AttributesTypes>;
51
+ /**
52
+ * Creates a new `ObservableGauge` metric.
53
+ *
54
+ * The callback SHOULD be safe to be invoked concurrently.
55
+ *
56
+ * @param name the name of the metric.
57
+ * @param [options] the metric options.
58
+ */
59
+ createObservableGauge<AttributesTypes extends MetricAttributes = MetricAttributes>(name: string, options?: MetricOptions): ObservableGauge<AttributesTypes>;
60
+ /**
61
+ * Creates a new `ObservableCounter` metric.
62
+ *
63
+ * The callback SHOULD be safe to be invoked concurrently.
64
+ *
65
+ * @param name the name of the metric.
66
+ * @param [options] the metric options.
67
+ */
68
+ createObservableCounter<AttributesTypes extends MetricAttributes = MetricAttributes>(name: string, options?: MetricOptions): ObservableCounter<AttributesTypes>;
69
+ /**
70
+ * Creates a new `ObservableUpDownCounter` metric.
71
+ *
72
+ * The callback SHOULD be safe to be invoked concurrently.
73
+ *
74
+ * @param name the name of the metric.
75
+ * @param [options] the metric options.
76
+ */
77
+ createObservableUpDownCounter<AttributesTypes extends MetricAttributes = MetricAttributes>(name: string, options?: MetricOptions): ObservableUpDownCounter<AttributesTypes>;
78
+ /**
79
+ * Sets up a function that will be called whenever a metric collection is
80
+ * initiated.
81
+ *
82
+ * If the function is already in the list of callbacks for this Observable,
83
+ * the function is not added a second time.
84
+ *
85
+ * Only the associated observables can be observed in the callback.
86
+ * Measurements of observables that are not associated observed in the
87
+ * callback are dropped.
88
+ *
89
+ * @param callback the batch observable callback
90
+ * @param observables the observables associated with this batch observable callback
91
+ */
92
+ addBatchObservableCallback<AttributesTypes extends MetricAttributes = MetricAttributes>(callback: BatchObservableCallback<AttributesTypes>, observables: Observable<AttributesTypes>[]): void;
93
+ /**
94
+ * Removes a callback previously registered with {@link Meter.addBatchObservableCallback}.
95
+ *
96
+ * The callback to be removed is identified using a combination of the callback itself,
97
+ * and the set of the observables associated with it.
98
+ *
99
+ * @param callback the batch observable callback
100
+ * @param observables the observables associated with this batch observable callback
101
+ */
102
+ removeBatchObservableCallback<AttributesTypes extends MetricAttributes = MetricAttributes>(callback: BatchObservableCallback<AttributesTypes>, observables: Observable<AttributesTypes>[]): void;
103
+ }
104
+ //# sourceMappingURL=Meter.d.ts.map
@@ -0,0 +1,17 @@
1
+ /*
2
+ * Copyright The OpenTelemetry Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export {};
17
+ //# sourceMappingURL=Meter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Meter.js","sourceRoot":"","sources":["../../../src/metrics/Meter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n BatchObservableCallback,\n Counter,\n Histogram,\n MetricAttributes,\n MetricOptions,\n Observable,\n ObservableCounter,\n ObservableGauge,\n ObservableUpDownCounter,\n UpDownCounter,\n} from './Metric';\n\n/**\n * An interface describes additional metadata of a meter.\n */\nexport interface MeterOptions {\n /**\n * The schemaUrl of the meter or instrumentation library\n */\n schemaUrl?: string;\n}\n\n/**\n * An interface to allow the recording metrics.\n *\n * {@link Metric}s are used for recording pre-defined aggregation (`Counter`),\n * or raw values (`Histogram`) in which the aggregation and attributes\n * for the exported metric are deferred.\n */\nexport interface Meter {\n /**\n * Creates and returns a new `Histogram`.\n * @param name the name of the metric.\n * @param [options] the metric options.\n */\n createHistogram<AttributesTypes extends MetricAttributes = MetricAttributes>(\n name: string,\n options?: MetricOptions\n ): Histogram<AttributesTypes>;\n\n /**\n * Creates a new `Counter` metric. Generally, this kind of metric when the\n * value is a quantity, the sum is of primary interest, and the event count\n * and value distribution are not of primary interest.\n * @param name the name of the metric.\n * @param [options] the metric options.\n */\n createCounter<AttributesTypes extends MetricAttributes = MetricAttributes>(\n name: string,\n options?: MetricOptions\n ): Counter<AttributesTypes>;\n\n /**\n * Creates a new `UpDownCounter` metric. UpDownCounter is a synchronous\n * instrument and very similar to Counter except that Add(increment)\n * supports negative increments. It is generally useful for capturing changes\n * in an amount of resources used, or any quantity that rises and falls\n * during a request.\n * Example uses for UpDownCounter:\n * <ol>\n * <li> count the number of active requests. </li>\n * <li> count memory in use by instrumenting new and delete. </li>\n * <li> count queue size by instrumenting enqueue and dequeue. </li>\n * <li> count semaphore up and down operations. </li>\n * </ol>\n *\n * @param name the name of the metric.\n * @param [options] the metric options.\n */\n createUpDownCounter<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n >(\n name: string,\n options?: MetricOptions\n ): UpDownCounter<AttributesTypes>;\n\n /**\n * Creates a new `ObservableGauge` metric.\n *\n * The callback SHOULD be safe to be invoked concurrently.\n *\n * @param name the name of the metric.\n * @param [options] the metric options.\n */\n createObservableGauge<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n >(\n name: string,\n options?: MetricOptions\n ): ObservableGauge<AttributesTypes>;\n\n /**\n * Creates a new `ObservableCounter` metric.\n *\n * The callback SHOULD be safe to be invoked concurrently.\n *\n * @param name the name of the metric.\n * @param [options] the metric options.\n */\n createObservableCounter<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n >(\n name: string,\n options?: MetricOptions\n ): ObservableCounter<AttributesTypes>;\n\n /**\n * Creates a new `ObservableUpDownCounter` metric.\n *\n * The callback SHOULD be safe to be invoked concurrently.\n *\n * @param name the name of the metric.\n * @param [options] the metric options.\n */\n createObservableUpDownCounter<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n >(\n name: string,\n options?: MetricOptions\n ): ObservableUpDownCounter<AttributesTypes>;\n\n /**\n * Sets up a function that will be called whenever a metric collection is\n * initiated.\n *\n * If the function is already in the list of callbacks for this Observable,\n * the function is not added a second time.\n *\n * Only the associated observables can be observed in the callback.\n * Measurements of observables that are not associated observed in the\n * callback are dropped.\n *\n * @param callback the batch observable callback\n * @param observables the observables associated with this batch observable callback\n */\n addBatchObservableCallback<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n >(\n callback: BatchObservableCallback<AttributesTypes>,\n observables: Observable<AttributesTypes>[]\n ): void;\n\n /**\n * Removes a callback previously registered with {@link Meter.addBatchObservableCallback}.\n *\n * The callback to be removed is identified using a combination of the callback itself,\n * and the set of the observables associated with it.\n *\n * @param callback the batch observable callback\n * @param observables the observables associated with this batch observable callback\n */\n removeBatchObservableCallback<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n >(\n callback: BatchObservableCallback<AttributesTypes>,\n observables: Observable<AttributesTypes>[]\n ): void;\n}\n"]}