@opentelemetry/api 1.2.0 → 1.4.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 (181) hide show
  1. package/README.md +12 -35
  2. package/build/esm/api/context.js +25 -5
  3. package/build/esm/api/context.js.map +1 -1
  4. package/build/esm/api/diag.d.ts +3 -11
  5. package/build/esm/api/diag.js +38 -7
  6. package/build/esm/api/diag.js.map +1 -1
  7. package/build/esm/api/metrics.d.ts +28 -0
  8. package/build/esm/api/metrics.js +60 -0
  9. package/build/esm/api/metrics.js.map +1 -0
  10. package/build/esm/api/propagation.d.ts +2 -1
  11. package/build/esm/api/propagation.js +2 -1
  12. package/build/esm/api/propagation.js.map +1 -1
  13. package/build/esm/baggage/context-helpers.d.ts +6 -0
  14. package/build/esm/baggage/context-helpers.js +9 -0
  15. package/build/esm/baggage/context-helpers.js.map +1 -1
  16. package/build/esm/baggage/internal/baggage-impl.js +41 -4
  17. package/build/esm/baggage/internal/baggage-impl.js.map +1 -1
  18. package/build/esm/common/Attributes.js.map +1 -1
  19. package/build/esm/context/NoopContextManager.js +25 -5
  20. package/build/esm/context/NoopContextManager.js.map +1 -1
  21. package/build/esm/context-api.d.ts +4 -0
  22. package/build/esm/context-api.js +21 -0
  23. package/build/esm/context-api.js.map +1 -0
  24. package/build/esm/diag/ComponentLogger.js +26 -1
  25. package/build/esm/diag/ComponentLogger.js.map +1 -1
  26. package/build/esm/diag/types.d.ts +30 -0
  27. package/build/esm/diag/types.js.map +1 -1
  28. package/build/esm/diag-api.d.ts +9 -0
  29. package/build/esm/diag-api.js +26 -0
  30. package/build/esm/diag-api.js.map +1 -0
  31. package/build/esm/index.d.ts +44 -48
  32. package/build/esm/index.js +29 -43
  33. package/build/esm/index.js.map +1 -1
  34. package/build/esm/internal/global-utils.d.ts +3 -1
  35. package/build/esm/internal/global-utils.js.map +1 -1
  36. package/build/esm/metrics/Meter.d.ts +104 -0
  37. package/build/esm/{diag/index.js → metrics/Meter.js} +2 -3
  38. package/build/esm/metrics/Meter.js.map +1 -0
  39. package/build/esm/metrics/MeterProvider.d.ts +17 -0
  40. package/build/esm/metrics/MeterProvider.js +17 -0
  41. package/build/esm/metrics/MeterProvider.js.map +1 -0
  42. package/build/esm/metrics/Metric.d.ts +93 -0
  43. package/build/esm/metrics/Metric.js +22 -0
  44. package/build/esm/metrics/Metric.js.map +1 -0
  45. package/build/esm/metrics/NoopMeter.d.ts +74 -0
  46. package/build/esm/metrics/NoopMeter.js +165 -0
  47. package/build/esm/metrics/NoopMeter.js.map +1 -0
  48. package/build/esm/metrics/NoopMeterProvider.d.ts +11 -0
  49. package/build/esm/metrics/NoopMeterProvider.js +31 -0
  50. package/build/esm/metrics/NoopMeterProvider.js.map +1 -0
  51. package/build/esm/metrics/ObservableResult.d.ts +31 -0
  52. package/build/esm/metrics/ObservableResult.js +17 -0
  53. package/build/esm/metrics/ObservableResult.js.map +1 -0
  54. package/build/esm/metrics-api.d.ts +4 -0
  55. package/build/esm/metrics-api.js +21 -0
  56. package/build/esm/metrics-api.js.map +1 -0
  57. package/build/esm/platform/browser/globalThis.js +10 -7
  58. package/build/esm/platform/browser/globalThis.js.map +1 -1
  59. package/build/esm/propagation-api.d.ts +4 -0
  60. package/build/esm/propagation-api.js +21 -0
  61. package/build/esm/propagation-api.js.map +1 -0
  62. package/build/esm/trace/NoopTracer.js +4 -3
  63. package/build/esm/trace/NoopTracer.js.map +1 -1
  64. package/build/esm/trace/ProxyTracer.js.map +1 -1
  65. package/build/esm/trace/internal/utils.js.map +1 -1
  66. package/build/esm/trace-api.d.ts +4 -0
  67. package/build/esm/trace-api.js +21 -0
  68. package/build/esm/trace-api.js.map +1 -0
  69. package/build/esm/version.d.ts +1 -1
  70. package/build/esm/version.js +1 -1
  71. package/build/esm/version.js.map +1 -1
  72. package/build/src/api/context.js +26 -38
  73. package/build/src/api/context.js.map +1 -1
  74. package/build/src/api/diag.d.ts +3 -11
  75. package/build/src/api/diag.js +33 -33
  76. package/build/src/api/diag.js.map +1 -1
  77. package/build/src/api/metrics.d.ts +28 -0
  78. package/build/src/api/metrics.js +61 -0
  79. package/build/src/api/metrics.js.map +1 -0
  80. package/build/src/api/propagation.d.ts +2 -1
  81. package/build/src/api/propagation.js +29 -31
  82. package/build/src/api/propagation.js.map +1 -1
  83. package/build/src/api/trace.js +22 -23
  84. package/build/src/api/trace.js.map +1 -1
  85. package/build/src/baggage/context-helpers.d.ts +6 -0
  86. package/build/src/baggage/context-helpers.js +13 -3
  87. package/build/src/baggage/context-helpers.js.map +1 -1
  88. package/build/src/baggage/internal/baggage-impl.js +21 -30
  89. package/build/src/baggage/internal/baggage-impl.js.map +1 -1
  90. package/build/src/baggage/utils.js +7 -8
  91. package/build/src/baggage/utils.js.map +1 -1
  92. package/build/src/common/Attributes.js.map +1 -1
  93. package/build/src/context/NoopContextManager.js +14 -26
  94. package/build/src/context/NoopContextManager.js.map +1 -1
  95. package/build/src/context/context.js +9 -10
  96. package/build/src/context/context.js.map +1 -1
  97. package/build/src/context-api.d.ts +4 -0
  98. package/build/src/{diag/index.js → context-api.js} +7 -13
  99. package/build/src/context-api.js.map +1 -0
  100. package/build/src/diag/ComponentLogger.js +16 -37
  101. package/build/src/diag/ComponentLogger.js.map +1 -1
  102. package/build/src/diag/consoleLogger.js +7 -12
  103. package/build/src/diag/consoleLogger.js.map +1 -1
  104. package/build/src/diag/internal/logLevelLogger.js +2 -2
  105. package/build/src/diag/internal/logLevelLogger.js.map +1 -1
  106. package/build/src/diag/types.d.ts +30 -0
  107. package/build/src/diag/types.js.map +1 -1
  108. package/build/src/diag-api.d.ts +9 -0
  109. package/build/src/diag-api.js +29 -0
  110. package/build/src/diag-api.js.map +1 -0
  111. package/build/src/index.d.ts +44 -48
  112. package/build/src/index.js +49 -56
  113. package/build/src/index.js.map +1 -1
  114. package/build/src/internal/global-utils.d.ts +3 -1
  115. package/build/src/internal/global-utils.js +15 -16
  116. package/build/src/internal/global-utils.js.map +1 -1
  117. package/build/src/internal/semver.js +9 -9
  118. package/build/src/internal/semver.js.map +1 -1
  119. package/build/src/metrics/Meter.d.ts +104 -0
  120. package/build/src/metrics/Meter.js +18 -0
  121. package/build/src/metrics/Meter.js.map +1 -0
  122. package/build/src/metrics/MeterProvider.d.ts +17 -0
  123. package/build/src/metrics/MeterProvider.js +18 -0
  124. package/build/src/metrics/MeterProvider.js.map +1 -0
  125. package/build/src/metrics/Metric.d.ts +93 -0
  126. package/build/src/metrics/Metric.js +25 -0
  127. package/build/src/metrics/Metric.js.map +1 -0
  128. package/build/src/metrics/NoopMeter.d.ts +74 -0
  129. package/build/src/metrics/NoopMeter.js +116 -0
  130. package/build/src/metrics/NoopMeter.js.map +1 -0
  131. package/build/src/metrics/NoopMeterProvider.d.ts +11 -0
  132. package/build/src/metrics/NoopMeterProvider.js +31 -0
  133. package/build/src/metrics/NoopMeterProvider.js.map +1 -0
  134. package/build/src/metrics/ObservableResult.d.ts +31 -0
  135. package/build/src/metrics/ObservableResult.js +18 -0
  136. package/build/src/metrics/ObservableResult.js.map +1 -0
  137. package/build/src/metrics-api.d.ts +4 -0
  138. package/build/src/metrics-api.js +24 -0
  139. package/build/src/metrics-api.js.map +1 -0
  140. package/build/src/platform/browser/globalThis.js +10 -7
  141. package/build/src/platform/browser/globalThis.js.map +1 -1
  142. package/build/src/propagation/NoopTextMapPropagator.js +7 -10
  143. package/build/src/propagation/NoopTextMapPropagator.js.map +1 -1
  144. package/build/src/propagation/TextMapPropagator.js +3 -3
  145. package/build/src/propagation/TextMapPropagator.js.map +1 -1
  146. package/build/src/propagation-api.d.ts +4 -0
  147. package/build/src/propagation-api.js +24 -0
  148. package/build/src/propagation-api.js.map +1 -0
  149. package/build/src/trace/NonRecordingSpan.js +20 -22
  150. package/build/src/trace/NonRecordingSpan.js.map +1 -1
  151. package/build/src/trace/NoopTracer.js +21 -24
  152. package/build/src/trace/NoopTracer.js.map +1 -1
  153. package/build/src/trace/NoopTracerProvider.js +5 -8
  154. package/build/src/trace/NoopTracerProvider.js.map +1 -1
  155. package/build/src/trace/ProxyTracer.js +13 -14
  156. package/build/src/trace/ProxyTracer.js.map +1 -1
  157. package/build/src/trace/ProxyTracerProvider.js +13 -16
  158. package/build/src/trace/ProxyTracerProvider.js.map +1 -1
  159. package/build/src/trace/context-utils.js +4 -4
  160. package/build/src/trace/context-utils.js.map +1 -1
  161. package/build/src/trace/internal/tracestate-impl.js +33 -35
  162. package/build/src/trace/internal/tracestate-impl.js.map +1 -1
  163. package/build/src/trace/internal/tracestate-validators.js +6 -6
  164. package/build/src/trace/internal/tracestate-validators.js.map +1 -1
  165. package/build/src/trace/internal/utils.js +1 -1
  166. package/build/src/trace/internal/utils.js.map +1 -1
  167. package/build/src/trace/invalid-span-constants.js +1 -1
  168. package/build/src/trace/invalid-span-constants.js.map +1 -1
  169. package/build/src/trace/spancontext-utils.js +4 -4
  170. package/build/src/trace/spancontext-utils.js.map +1 -1
  171. package/build/src/trace-api.d.ts +4 -0
  172. package/build/src/trace-api.js +24 -0
  173. package/build/src/{diag/index.js.map → trace-api.js.map} +1 -1
  174. package/build/src/version.d.ts +1 -1
  175. package/build/src/version.js +1 -1
  176. package/build/src/version.js.map +1 -1
  177. package/package.json +36 -35
  178. package/CHANGELOG.md +0 -212
  179. package/build/esm/diag/index.d.ts +0 -3
  180. package/build/esm/diag/index.js.map +0 -1
  181. package/build/src/diag/index.d.ts +0 -3
@@ -14,44 +14,42 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
- if (k2 === undefined) k2 = k;
19
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
20
- }) : (function(o, m, k, k2) {
21
- if (k2 === undefined) k2 = k;
22
- o[k2] = m[k];
23
- }));
24
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
25
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
26
- };
27
17
  Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.diag = exports.propagation = exports.trace = exports.context = exports.INVALID_SPAN_CONTEXT = exports.INVALID_TRACEID = exports.INVALID_SPANID = exports.isValidSpanId = exports.isValidTraceId = exports.isSpanContextValid = exports.createTraceState = exports.baggageEntryMetadataFromString = void 0;
29
- __exportStar(require("./baggage/types"), exports);
18
+ exports.trace = exports.propagation = exports.metrics = exports.diag = exports.context = exports.INVALID_SPAN_CONTEXT = exports.INVALID_TRACEID = exports.INVALID_SPANID = exports.isValidSpanId = exports.isValidTraceId = exports.isSpanContextValid = exports.createTraceState = exports.TraceFlags = exports.SpanStatusCode = exports.SpanKind = exports.SamplingDecision = exports.ProxyTracerProvider = exports.ProxyTracer = exports.defaultTextMapSetter = exports.defaultTextMapGetter = exports.ValueType = exports.createNoopMeter = exports.DiagLogLevel = exports.DiagConsoleLogger = exports.ROOT_CONTEXT = exports.createContextKey = exports.baggageEntryMetadataFromString = void 0;
30
19
  var utils_1 = require("./baggage/utils");
31
20
  Object.defineProperty(exports, "baggageEntryMetadataFromString", { enumerable: true, get: function () { return utils_1.baggageEntryMetadataFromString; } });
32
- __exportStar(require("./common/Exception"), exports);
33
- __exportStar(require("./common/Time"), exports);
34
- __exportStar(require("./common/Attributes"), exports);
35
- __exportStar(require("./diag"), exports);
36
- __exportStar(require("./propagation/TextMapPropagator"), exports);
37
- __exportStar(require("./trace/attributes"), exports);
38
- __exportStar(require("./trace/link"), exports);
39
- __exportStar(require("./trace/ProxyTracer"), exports);
40
- __exportStar(require("./trace/ProxyTracerProvider"), exports);
41
- __exportStar(require("./trace/Sampler"), exports);
42
- __exportStar(require("./trace/SamplingResult"), exports);
43
- __exportStar(require("./trace/span_context"), exports);
44
- __exportStar(require("./trace/span_kind"), exports);
45
- __exportStar(require("./trace/span"), exports);
46
- __exportStar(require("./trace/SpanOptions"), exports);
47
- __exportStar(require("./trace/status"), exports);
48
- __exportStar(require("./trace/trace_flags"), exports);
49
- __exportStar(require("./trace/trace_state"), exports);
21
+ // Context APIs
22
+ var context_1 = require("./context/context");
23
+ Object.defineProperty(exports, "createContextKey", { enumerable: true, get: function () { return context_1.createContextKey; } });
24
+ Object.defineProperty(exports, "ROOT_CONTEXT", { enumerable: true, get: function () { return context_1.ROOT_CONTEXT; } });
25
+ // Diag APIs
26
+ var consoleLogger_1 = require("./diag/consoleLogger");
27
+ Object.defineProperty(exports, "DiagConsoleLogger", { enumerable: true, get: function () { return consoleLogger_1.DiagConsoleLogger; } });
28
+ var types_1 = require("./diag/types");
29
+ Object.defineProperty(exports, "DiagLogLevel", { enumerable: true, get: function () { return types_1.DiagLogLevel; } });
30
+ // Metrics APIs
31
+ var NoopMeter_1 = require("./metrics/NoopMeter");
32
+ Object.defineProperty(exports, "createNoopMeter", { enumerable: true, get: function () { return NoopMeter_1.createNoopMeter; } });
33
+ var Metric_1 = require("./metrics/Metric");
34
+ Object.defineProperty(exports, "ValueType", { enumerable: true, get: function () { return Metric_1.ValueType; } });
35
+ // Propagation APIs
36
+ var TextMapPropagator_1 = require("./propagation/TextMapPropagator");
37
+ Object.defineProperty(exports, "defaultTextMapGetter", { enumerable: true, get: function () { return TextMapPropagator_1.defaultTextMapGetter; } });
38
+ Object.defineProperty(exports, "defaultTextMapSetter", { enumerable: true, get: function () { return TextMapPropagator_1.defaultTextMapSetter; } });
39
+ var ProxyTracer_1 = require("./trace/ProxyTracer");
40
+ Object.defineProperty(exports, "ProxyTracer", { enumerable: true, get: function () { return ProxyTracer_1.ProxyTracer; } });
41
+ var ProxyTracerProvider_1 = require("./trace/ProxyTracerProvider");
42
+ Object.defineProperty(exports, "ProxyTracerProvider", { enumerable: true, get: function () { return ProxyTracerProvider_1.ProxyTracerProvider; } });
43
+ var SamplingResult_1 = require("./trace/SamplingResult");
44
+ Object.defineProperty(exports, "SamplingDecision", { enumerable: true, get: function () { return SamplingResult_1.SamplingDecision; } });
45
+ var span_kind_1 = require("./trace/span_kind");
46
+ Object.defineProperty(exports, "SpanKind", { enumerable: true, get: function () { return span_kind_1.SpanKind; } });
47
+ var status_1 = require("./trace/status");
48
+ Object.defineProperty(exports, "SpanStatusCode", { enumerable: true, get: function () { return status_1.SpanStatusCode; } });
49
+ var trace_flags_1 = require("./trace/trace_flags");
50
+ Object.defineProperty(exports, "TraceFlags", { enumerable: true, get: function () { return trace_flags_1.TraceFlags; } });
50
51
  var utils_2 = require("./trace/internal/utils");
51
52
  Object.defineProperty(exports, "createTraceState", { enumerable: true, get: function () { return utils_2.createTraceState; } });
52
- __exportStar(require("./trace/tracer_provider"), exports);
53
- __exportStar(require("./trace/tracer"), exports);
54
- __exportStar(require("./trace/tracer_options"), exports);
55
53
  var spancontext_utils_1 = require("./trace/spancontext-utils");
56
54
  Object.defineProperty(exports, "isSpanContextValid", { enumerable: true, get: function () { return spancontext_utils_1.isSpanContextValid; } });
57
55
  Object.defineProperty(exports, "isValidTraceId", { enumerable: true, get: function () { return spancontext_utils_1.isValidTraceId; } });
@@ -60,29 +58,24 @@ var invalid_span_constants_1 = require("./trace/invalid-span-constants");
60
58
  Object.defineProperty(exports, "INVALID_SPANID", { enumerable: true, get: function () { return invalid_span_constants_1.INVALID_SPANID; } });
61
59
  Object.defineProperty(exports, "INVALID_TRACEID", { enumerable: true, get: function () { return invalid_span_constants_1.INVALID_TRACEID; } });
62
60
  Object.defineProperty(exports, "INVALID_SPAN_CONTEXT", { enumerable: true, get: function () { return invalid_span_constants_1.INVALID_SPAN_CONTEXT; } });
63
- __exportStar(require("./context/context"), exports);
64
- __exportStar(require("./context/types"), exports);
65
- var context_1 = require("./api/context");
66
- /** Entrypoint for context API */
67
- exports.context = context_1.ContextAPI.getInstance();
68
- var trace_1 = require("./api/trace");
69
- /** Entrypoint for trace API */
70
- exports.trace = trace_1.TraceAPI.getInstance();
71
- var propagation_1 = require("./api/propagation");
72
- /** Entrypoint for propagation API */
73
- exports.propagation = propagation_1.PropagationAPI.getInstance();
74
- var diag_1 = require("./api/diag");
75
- /**
76
- * Entrypoint for Diag API.
77
- * Defines Diagnostic handler used for internal diagnostic logging operations.
78
- * The default provides a Noop DiagLogger implementation which may be changed via the
79
- * diag.setLogger(logger: DiagLogger) function.
80
- */
81
- exports.diag = diag_1.DiagAPI.instance();
61
+ // Split module-level variable definition into separate files to allow
62
+ // tree-shaking on each api instance.
63
+ const context_api_1 = require("./context-api");
64
+ Object.defineProperty(exports, "context", { enumerable: true, get: function () { return context_api_1.context; } });
65
+ const diag_api_1 = require("./diag-api");
66
+ Object.defineProperty(exports, "diag", { enumerable: true, get: function () { return diag_api_1.diag; } });
67
+ const metrics_api_1 = require("./metrics-api");
68
+ Object.defineProperty(exports, "metrics", { enumerable: true, get: function () { return metrics_api_1.metrics; } });
69
+ const propagation_api_1 = require("./propagation-api");
70
+ Object.defineProperty(exports, "propagation", { enumerable: true, get: function () { return propagation_api_1.propagation; } });
71
+ const trace_api_1 = require("./trace-api");
72
+ Object.defineProperty(exports, "trace", { enumerable: true, get: function () { return trace_api_1.trace; } });
73
+ // Default export.
82
74
  exports.default = {
83
- trace: exports.trace,
84
- context: exports.context,
85
- propagation: exports.propagation,
86
- diag: exports.diag,
75
+ context: context_api_1.context,
76
+ diag: diag_api_1.diag,
77
+ metrics: metrics_api_1.metrics,
78
+ propagation: propagation_api_1.propagation,
79
+ trace: trace_api_1.trace,
87
80
  };
88
81
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;AAEH,kDAAgC;AAChC,yCAAiE;AAAxD,uHAAA,8BAA8B,OAAA;AACvC,qDAAmC;AACnC,gDAA8B;AAC9B,sDAAoC;AACpC,yCAAuB;AACvB,kEAAgD;AAChD,qDAAmC;AACnC,+CAA6B;AAC7B,sDAAoC;AACpC,8DAA4C;AAC5C,kDAAgC;AAChC,yDAAuC;AACvC,uDAAqC;AACrC,oDAAkC;AAClC,+CAA6B;AAC7B,sDAAoC;AACpC,iDAA+B;AAC/B,sDAAoC;AACpC,sDAAoC;AACpC,gDAA0D;AAAjD,yGAAA,gBAAgB,OAAA;AACzB,0DAAwC;AACxC,iDAA+B;AAC/B,yDAAuC;AAEvC,+DAImC;AAHjC,uHAAA,kBAAkB,OAAA;AAClB,mHAAA,cAAc,OAAA;AACd,kHAAA,aAAa,OAAA;AAGf,yEAIwC;AAHtC,wHAAA,cAAc,OAAA;AACd,yHAAA,eAAe,OAAA;AACf,8HAAA,oBAAoB,OAAA;AAGtB,oDAAkC;AAClC,kDAAgC;AAEhC,yCAA2C;AAE3C,iCAAiC;AACpB,QAAA,OAAO,GAAG,oBAAU,CAAC,WAAW,EAAE,CAAC;AAEhD,qCAAuC;AAEvC,+BAA+B;AAClB,QAAA,KAAK,GAAG,gBAAQ,CAAC,WAAW,EAAE,CAAC;AAE5C,iDAAmD;AAEnD,qCAAqC;AACxB,QAAA,WAAW,GAAG,4BAAc,CAAC,WAAW,EAAE,CAAC;AAExD,mCAAqC;AAGrC;;;;;GAKG;AACU,QAAA,IAAI,GAAG,cAAO,CAAC,QAAQ,EAAE,CAAC;AAEvC,kBAAe;IACb,KAAK,eAAA;IACL,OAAO,iBAAA;IACP,WAAW,qBAAA;IACX,IAAI,cAAA;CACL,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 * from './baggage/types';\nexport { baggageEntryMetadataFromString } from './baggage/utils';\nexport * from './common/Exception';\nexport * from './common/Time';\nexport * from './common/Attributes';\nexport * from './diag';\nexport * from './propagation/TextMapPropagator';\nexport * from './trace/attributes';\nexport * from './trace/link';\nexport * from './trace/ProxyTracer';\nexport * from './trace/ProxyTracerProvider';\nexport * from './trace/Sampler';\nexport * from './trace/SamplingResult';\nexport * from './trace/span_context';\nexport * from './trace/span_kind';\nexport * from './trace/span';\nexport * from './trace/SpanOptions';\nexport * from './trace/status';\nexport * from './trace/trace_flags';\nexport * from './trace/trace_state';\nexport { createTraceState } from './trace/internal/utils';\nexport * from './trace/tracer_provider';\nexport * from './trace/tracer';\nexport * from './trace/tracer_options';\n\nexport {\n isSpanContextValid,\n isValidTraceId,\n isValidSpanId,\n} from './trace/spancontext-utils';\n\nexport {\n INVALID_SPANID,\n INVALID_TRACEID,\n INVALID_SPAN_CONTEXT,\n} from './trace/invalid-span-constants';\n\nexport * from './context/context';\nexport * from './context/types';\n\nimport { ContextAPI } from './api/context';\nexport type { ContextAPI } from './api/context';\n/** Entrypoint for context API */\nexport const context = ContextAPI.getInstance();\n\nimport { TraceAPI } from './api/trace';\nexport type { TraceAPI } from './api/trace';\n/** Entrypoint for trace API */\nexport const trace = TraceAPI.getInstance();\n\nimport { PropagationAPI } from './api/propagation';\nexport type { PropagationAPI } from './api/propagation';\n/** Entrypoint for propagation API */\nexport const propagation = PropagationAPI.getInstance();\n\nimport { DiagAPI } from './api/diag';\nexport type { DiagAPI } from './api/diag';\n\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\nexport default {\n trace,\n context,\n propagation,\n diag,\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAGH,yCAAiE;AAAxD,uHAAA,8BAA8B,OAAA;AAKvC,eAAe;AACf,6CAAmE;AAA1D,2GAAA,gBAAgB,OAAA;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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} 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 MetricAttributes,\n MetricAttributeValue,\n ObservableCallback,\n} from './metrics/Metric';\nexport {\n BatchObservableResult,\n ObservableResult,\n} from './metrics/ObservableResult';\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"]}
@@ -1,5 +1,6 @@
1
+ import { MeterProvider } from '../metrics/MeterProvider';
1
2
  import { ContextManager } from '../context/types';
2
- import { DiagLogger } from '../diag';
3
+ import { DiagLogger } from '../diag/types';
3
4
  import { TextMapPropagator } from '../propagation/TextMapPropagator';
4
5
  import type { TracerProvider } from '../trace/tracer_provider';
5
6
  export declare function registerGlobal<Type extends keyof OTelGlobalAPI>(type: Type, instance: OTelGlobalAPI[Type], diag: DiagLogger, allowOverride?: boolean): boolean;
@@ -10,6 +11,7 @@ declare type OTelGlobalAPI = {
10
11
  diag?: DiagLogger;
11
12
  trace?: TracerProvider;
12
13
  context?: ContextManager;
14
+ metrics?: MeterProvider;
13
15
  propagation?: TextMapPropagator;
14
16
  };
15
17
  export {};
@@ -16,47 +16,46 @@
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.unregisterGlobal = exports.getGlobal = exports.registerGlobal = void 0;
19
- var platform_1 = require("../platform");
20
- var version_1 = require("../version");
21
- var semver_1 = require("./semver");
22
- var major = version_1.VERSION.split('.')[0];
23
- var GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for("opentelemetry.js.api." + major);
24
- var _global = platform_1._globalThis;
25
- function registerGlobal(type, instance, diag, allowOverride) {
19
+ const platform_1 = require("../platform");
20
+ const version_1 = require("../version");
21
+ const semver_1 = require("./semver");
22
+ const major = version_1.VERSION.split('.')[0];
23
+ const GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for(`opentelemetry.js.api.${major}`);
24
+ const _global = platform_1._globalThis;
25
+ function registerGlobal(type, instance, diag, allowOverride = false) {
26
26
  var _a;
27
- if (allowOverride === void 0) { allowOverride = false; }
28
- var api = (_global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a !== void 0 ? _a : {
27
+ const api = (_global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a !== void 0 ? _a : {
29
28
  version: version_1.VERSION,
30
29
  });
31
30
  if (!allowOverride && api[type]) {
32
31
  // already registered an API of this type
33
- var err = new Error("@opentelemetry/api: Attempted duplicate registration of API: " + type);
32
+ const err = new Error(`@opentelemetry/api: Attempted duplicate registration of API: ${type}`);
34
33
  diag.error(err.stack || err.message);
35
34
  return false;
36
35
  }
37
36
  if (api.version !== version_1.VERSION) {
38
37
  // All registered APIs must be of the same version exactly
39
- var err = new Error('@opentelemetry/api: All API registration versions must match');
38
+ const err = new Error('@opentelemetry/api: All API registration versions must match');
40
39
  diag.error(err.stack || err.message);
41
40
  return false;
42
41
  }
43
42
  api[type] = instance;
44
- diag.debug("@opentelemetry/api: Registered a global for " + type + " v" + version_1.VERSION + ".");
43
+ diag.debug(`@opentelemetry/api: Registered a global for ${type} v${version_1.VERSION}.`);
45
44
  return true;
46
45
  }
47
46
  exports.registerGlobal = registerGlobal;
48
47
  function getGlobal(type) {
49
48
  var _a, _b;
50
- var globalVersion = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a === void 0 ? void 0 : _a.version;
51
- if (!globalVersion || !semver_1.isCompatible(globalVersion)) {
49
+ const globalVersion = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a === void 0 ? void 0 : _a.version;
50
+ if (!globalVersion || !(0, semver_1.isCompatible)(globalVersion)) {
52
51
  return;
53
52
  }
54
53
  return (_b = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b === void 0 ? void 0 : _b[type];
55
54
  }
56
55
  exports.getGlobal = getGlobal;
57
56
  function unregisterGlobal(type, diag) {
58
- diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + version_1.VERSION + ".");
59
- var api = _global[GLOBAL_OPENTELEMETRY_API_KEY];
57
+ diag.debug(`@opentelemetry/api: Unregistering a global for ${type} v${version_1.VERSION}.`);
58
+ const api = _global[GLOBAL_OPENTELEMETRY_API_KEY];
60
59
  if (api) {
61
60
  delete api[type];
62
61
  }
@@ -1 +1 @@
1
- {"version":3,"file":"global-utils.js","sourceRoot":"","sources":["../../../src/internal/global-utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAIH,wCAA0C;AAG1C,sCAAqC;AACrC,mCAAwC;AAExC,IAAM,KAAK,GAAG,iBAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACpC,IAAM,4BAA4B,GAAG,MAAM,CAAC,GAAG,CAC7C,0BAAwB,KAAO,CAChC,CAAC;AAEF,IAAM,OAAO,GAAG,sBAAyB,CAAC;AAE1C,SAAgB,cAAc,CAC5B,IAAU,EACV,QAA6B,EAC7B,IAAgB,EAChB,aAAqB;;IAArB,8BAAA,EAA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;IACF,IAAM,GAAG,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;IAElD,IAAI,GAAG,EAAE;QACP,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC;KAClB;AACH,CAAC;AATD,4CASC","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 { ContextManager } from '../context/types';\nimport { DiagLogger } from '../diag';\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: All API registration versions must match'\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 propagation?: TextMapPropagator;\n};\n"]}
1
+ {"version":3,"file":"global-utils.js","sourceRoot":"","sources":["../../../src/internal/global-utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAKH,0CAA0C;AAG1C,wCAAqC;AACrC,qCAAwC;AAExC,MAAM,KAAK,GAAG,iBAAO,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,sBAAyB,CAAC;AAE1C,SAAgB,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,iBAAO;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,iBAAO,EAAE;QAC3B,0DAA0D;QAC1D,MAAM,GAAG,GAAG,IAAI,KAAK,CACnB,8DAA8D,CAC/D,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,iBAAO,GAAG,CACnE,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC;AApCD,wCAoCC;AAED,SAAgB,SAAS,CACvB,IAAU;;IAEV,MAAM,aAAa,GAAG,MAAA,OAAO,CAAC,4BAA4B,CAAC,0CAAE,OAAO,CAAC;IACrE,IAAI,CAAC,aAAa,IAAI,CAAC,IAAA,qBAAY,EAAC,aAAa,CAAC,EAAE;QAClD,OAAO;KACR;IACD,OAAO,MAAA,OAAO,CAAC,4BAA4B,CAAC,0CAAG,IAAI,CAAC,CAAC;AACvD,CAAC;AARD,8BAQC;AAED,SAAgB,gBAAgB,CAAC,IAAyB,EAAE,IAAgB;IAC1E,IAAI,CAAC,KAAK,CACR,kDAAkD,IAAI,KAAK,iBAAO,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;AATD,4CASC","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: All API registration versions must match'\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"]}
@@ -16,8 +16,8 @@
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.isCompatible = exports._makeCompatibilityCheck = void 0;
19
- var version_1 = require("../version");
20
- var re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
19
+ const version_1 = require("../version");
20
+ const re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
21
21
  /**
22
22
  * Create a function to test an API version to see if it is compatible with the provided ownVersion.
23
23
  *
@@ -35,14 +35,14 @@ var re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
35
35
  * @param ownVersion version which should be checked against
36
36
  */
37
37
  function _makeCompatibilityCheck(ownVersion) {
38
- var acceptedVersions = new Set([ownVersion]);
39
- var rejectedVersions = new Set();
40
- var myVersionMatch = ownVersion.match(re);
38
+ const acceptedVersions = new Set([ownVersion]);
39
+ const rejectedVersions = new Set();
40
+ const myVersionMatch = ownVersion.match(re);
41
41
  if (!myVersionMatch) {
42
42
  // we cannot guarantee compatibility so we always return noop
43
- return function () { return false; };
43
+ return () => false;
44
44
  }
45
- var ownVersionParsed = {
45
+ const ownVersionParsed = {
46
46
  major: +myVersionMatch[1],
47
47
  minor: +myVersionMatch[2],
48
48
  patch: +myVersionMatch[3],
@@ -69,13 +69,13 @@ function _makeCompatibilityCheck(ownVersion) {
69
69
  if (rejectedVersions.has(globalVersion)) {
70
70
  return false;
71
71
  }
72
- var globalVersionMatch = globalVersion.match(re);
72
+ const globalVersionMatch = globalVersion.match(re);
73
73
  if (!globalVersionMatch) {
74
74
  // cannot parse other version
75
75
  // we cannot guarantee compatibility so we always noop
76
76
  return _reject(globalVersion);
77
77
  }
78
- var globalVersionParsed = {
78
+ const globalVersionParsed = {
79
79
  major: +globalVersionMatch[1],
80
80
  minor: +globalVersionMatch[2],
81
81
  patch: +globalVersionMatch[3],
@@ -1 +1 @@
1
- {"version":3,"file":"semver.js","sourceRoot":"","sources":["../../../src/internal/semver.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,sCAAqC;AAErC,IAAM,EAAE,GAAG,+BAA+B,CAAC;AAE3C;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,uBAAuB,CACrC,UAAkB;IAElB,IAAM,gBAAgB,GAAG,IAAI,GAAG,CAAS,CAAC,UAAU,CAAC,CAAC,CAAC;IACvD,IAAM,gBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;IAE3C,IAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC5C,IAAI,CAAC,cAAc,EAAE;QACnB,6DAA6D;QAC7D,OAAO,cAAM,OAAA,KAAK,EAAL,CAAK,CAAC;KACpB;IAED,IAAM,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,CAA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ACnD;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;AAtFD,0DAsFC;AAED;;;;;;;;;;;;;;GAcG;AACU,QAAA,YAAY,GAAG,uBAAuB,CAAC,iBAAO,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"]}
1
+ {"version":3,"file":"semver.js","sourceRoot":"","sources":["../../../src/internal/semver.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,wCAAqC;AAErC,MAAM,EAAE,GAAG,+BAA+B,CAAC;AAE3C;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,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,gBAAg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AAK,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;AAtFD,0DAsFC;AAED;;;;;;;;;;;;;;GAcG;AACU,QAAA,YAAY,GAAG,uBAAuB,CAAC,iBAAO,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,18 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright The OpenTelemetry Authors
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * https://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ //# 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"]}
@@ -0,0 +1,17 @@
1
+ import { Meter, MeterOptions } from './Meter';
2
+ /**
3
+ * A registry for creating named {@link Meter}s.
4
+ */
5
+ export interface MeterProvider {
6
+ /**
7
+ * Returns a Meter, creating one if one with the given name, version, and
8
+ * schemaUrl pair is not already created.
9
+ *
10
+ * @param name The name of the meter or instrumentation library.
11
+ * @param version The version of the meter or instrumentation library.
12
+ * @param options The options of the meter or instrumentation library.
13
+ * @returns Meter A Meter with the given name and version
14
+ */
15
+ getMeter(name: string, version?: string, options?: MeterOptions): Meter;
16
+ }
17
+ //# sourceMappingURL=MeterProvider.d.ts.map
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright The OpenTelemetry Authors
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * https://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ //# sourceMappingURL=MeterProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MeterProvider.js","sourceRoot":"","sources":["../../../src/metrics/MeterProvider.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 { Meter, MeterOptions } from './Meter';\n\n/**\n * A registry for creating named {@link Meter}s.\n */\nexport interface MeterProvider {\n /**\n * Returns a Meter, creating one if one with the given name, version, and\n * schemaUrl pair is not already created.\n *\n * @param name The name of the meter or instrumentation library.\n * @param version The version of the meter or instrumentation library.\n * @param options The options of the meter or instrumentation library.\n * @returns Meter A Meter with the given name and version\n */\n getMeter(name: string, version?: string, options?: MeterOptions): Meter;\n}\n"]}