NoopMeter.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. var __extends = (this && this.__extends) || (function () {
  17. var extendStatics = function (d, b) {
  18. extendStatics = Object.setPrototypeOf ||
  19. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  20. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  21. return extendStatics(d, b);
  22. };
  23. return function (d, b) {
  24. if (typeof b !== "function" && b !== null)
  25. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  26. extendStatics(d, b);
  27. function __() { this.constructor = d; }
  28. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  29. };
  30. })();
  31. /**
  32. * NoopMeter is a noop implementation of the {@link Meter} interface. It reuses
  33. * constant NoopMetrics for all of its methods.
  34. */
  35. var NoopMeter = /** @class */ (function () {
  36. function NoopMeter() {
  37. }
  38. /**
  39. * @see {@link Meter.createGauge}
  40. */
  41. NoopMeter.prototype.createGauge = function (_name, _options) {
  42. return NOOP_GAUGE_METRIC;
  43. };
  44. /**
  45. * @see {@link Meter.createHistogram}
  46. */
  47. NoopMeter.prototype.createHistogram = function (_name, _options) {
  48. return NOOP_HISTOGRAM_METRIC;
  49. };
  50. /**
  51. * @see {@link Meter.createCounter}
  52. */
  53. NoopMeter.prototype.createCounter = function (_name, _options) {
  54. return NOOP_COUNTER_METRIC;
  55. };
  56. /**
  57. * @see {@link Meter.createUpDownCounter}
  58. */
  59. NoopMeter.prototype.createUpDownCounter = function (_name, _options) {
  60. return NOOP_UP_DOWN_COUNTER_METRIC;
  61. };
  62. /**
  63. * @see {@link Meter.createObservableGauge}
  64. */
  65. NoopMeter.prototype.createObservableGauge = function (_name, _options) {
  66. return NOOP_OBSERVABLE_GAUGE_METRIC;
  67. };
  68. /**
  69. * @see {@link Meter.createObservableCounter}
  70. */
  71. NoopMeter.prototype.createObservableCounter = function (_name, _options) {
  72. return NOOP_OBSERVABLE_COUNTER_METRIC;
  73. };
  74. /**
  75. * @see {@link Meter.createObservableUpDownCounter}
  76. */
  77. NoopMeter.prototype.createObservableUpDownCounter = function (_name, _options) {
  78. return NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC;
  79. };
  80. /**
  81. * @see {@link Meter.addBatchObservableCallback}
  82. */
  83. NoopMeter.prototype.addBatchObservableCallback = function (_callback, _observables) { };
  84. /**
  85. * @see {@link Meter.removeBatchObservableCallback}
  86. */
  87. NoopMeter.prototype.removeBatchObservableCallback = function (_callback) { };
  88. return NoopMeter;
  89. }());
  90. export { NoopMeter };
  91. var NoopMetric = /** @class */ (function () {
  92. function NoopMetric() {
  93. }
  94. return NoopMetric;
  95. }());
  96. export { NoopMetric };
  97. var NoopCounterMetric = /** @class */ (function (_super) {
  98. __extends(NoopCounterMetric, _super);
  99. function NoopCounterMetric() {
  100. return _super !== null && _super.apply(this, arguments) || this;
  101. }
  102. NoopCounterMetric.prototype.add = function (_value, _attributes) { };
  103. return NoopCounterMetric;
  104. }(NoopMetric));
  105. export { NoopCounterMetric };
  106. var NoopUpDownCounterMetric = /** @class */ (function (_super) {
  107. __extends(NoopUpDownCounterMetric, _super);
  108. function NoopUpDownCounterMetric() {
  109. return _super !== null && _super.apply(this, arguments) || this;
  110. }
  111. NoopUpDownCounterMetric.prototype.add = function (_value, _attributes) { };
  112. return NoopUpDownCounterMetric;
  113. }(NoopMetric));
  114. export { NoopUpDownCounterMetric };
  115. var NoopGaugeMetric = /** @class */ (function (_super) {
  116. __extends(NoopGaugeMetric, _super);
  117. function NoopGaugeMetric() {
  118. return _super !== null && _super.apply(this, arguments) || this;
  119. }
  120. NoopGaugeMetric.prototype.record = function (_value, _attributes) { };
  121. return NoopGaugeMetric;
  122. }(NoopMetric));
  123. export { NoopGaugeMetric };
  124. var NoopHistogramMetric = /** @class */ (function (_super) {
  125. __extends(NoopHistogramMetric, _super);
  126. function NoopHistogramMetric() {
  127. return _super !== null && _super.apply(this, arguments) || this;
  128. }
  129. NoopHistogramMetric.prototype.record = function (_value, _attributes) { };
  130. return NoopHistogramMetric;
  131. }(NoopMetric));
  132. export { NoopHistogramMetric };
  133. var NoopObservableMetric = /** @class */ (function () {
  134. function NoopObservableMetric() {
  135. }
  136. NoopObservableMetric.prototype.addCallback = function (_callback) { };
  137. NoopObservableMetric.prototype.removeCallback = function (_callback) { };
  138. return NoopObservableMetric;
  139. }());
  140. export { NoopObservableMetric };
  141. var NoopObservableCounterMetric = /** @class */ (function (_super) {
  142. __extends(NoopObservableCounterMetric, _super);
  143. function NoopObservableCounterMetric() {
  144. return _super !== null && _super.apply(this, arguments) || this;
  145. }
  146. return NoopObservableCounterMetric;
  147. }(NoopObservableMetric));
  148. export { NoopObservableCounterMetric };
  149. var NoopObservableGaugeMetric = /** @class */ (function (_super) {
  150. __extends(NoopObservableGaugeMetric, _super);
  151. function NoopObservableGaugeMetric() {
  152. return _super !== null && _super.apply(this, arguments) || this;
  153. }
  154. return NoopObservableGaugeMetric;
  155. }(NoopObservableMetric));
  156. export { NoopObservableGaugeMetric };
  157. var NoopObservableUpDownCounterMetric = /** @class */ (function (_super) {
  158. __extends(NoopObservableUpDownCounterMetric, _super);
  159. function NoopObservableUpDownCounterMetric() {
  160. return _super !== null && _super.apply(this, arguments) || this;
  161. }
  162. return NoopObservableUpDownCounterMetric;
  163. }(NoopObservableMetric));
  164. export { NoopObservableUpDownCounterMetric };
  165. export var NOOP_METER = new NoopMeter();
  166. // Synchronous instruments
  167. export var NOOP_COUNTER_METRIC = new NoopCounterMetric();
  168. export var NOOP_GAUGE_METRIC = new NoopGaugeMetric();
  169. export var NOOP_HISTOGRAM_METRIC = new NoopHistogramMetric();
  170. export var NOOP_UP_DOWN_COUNTER_METRIC = new NoopUpDownCounterMetric();
  171. // Asynchronous instruments
  172. export var NOOP_OBSERVABLE_COUNTER_METRIC = new NoopObservableCounterMetric();
  173. export var NOOP_OBSERVABLE_GAUGE_METRIC = new NoopObservableGaugeMetric();
  174. export var NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC = new NoopObservableUpDownCounterMetric();
  175. /**
  176. * Create a no-op Meter
  177. */
  178. export function createNoopMeter() {
  179. return NOOP_METER;
  180. }
  181. //# sourceMappingURL=NoopMeter.js.map