Meter.d.ts 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import { BatchObservableCallback, Counter, Gauge, 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 `Gauge`.
  21. * @param name the name of the metric.
  22. * @param [options] the metric options.
  23. */
  24. createGauge<AttributesTypes extends MetricAttributes = MetricAttributes>(name: string, options?: MetricOptions): Gauge<AttributesTypes>;
  25. /**
  26. * Creates and returns a new `Histogram`.
  27. * @param name the name of the metric.
  28. * @param [options] the metric options.
  29. */
  30. createHistogram<AttributesTypes extends MetricAttributes = MetricAttributes>(name: string, options?: MetricOptions): Histogram<AttributesTypes>;
  31. /**
  32. * Creates a new `Counter` metric. Generally, this kind of metric when the
  33. * value is a quantity, the sum is of primary interest, and the event count
  34. * and value distribution are not of primary interest.
  35. * @param name the name of the metric.
  36. * @param [options] the metric options.
  37. */
  38. createCounter<AttributesTypes extends MetricAttributes = MetricAttributes>(name: string, options?: MetricOptions): Counter<AttributesTypes>;
  39. /**
  40. * Creates a new `UpDownCounter` metric. UpDownCounter is a synchronous
  41. * instrument and very similar to Counter except that Add(increment)
  42. * supports negative increments. It is generally useful for capturing changes
  43. * in an amount of resources used, or any quantity that rises and falls
  44. * during a request.
  45. * Example uses for UpDownCounter:
  46. * <ol>
  47. * <li> count the number of active requests. </li>
  48. * <li> count memory in use by instrumenting new and delete. </li>
  49. * <li> count queue size by instrumenting enqueue and dequeue. </li>
  50. * <li> count semaphore up and down operations. </li>
  51. * </ol>
  52. *
  53. * @param name the name of the metric.
  54. * @param [options] the metric options.
  55. */
  56. createUpDownCounter<AttributesTypes extends MetricAttributes = MetricAttributes>(name: string, options?: MetricOptions): UpDownCounter<AttributesTypes>;
  57. /**
  58. * Creates a new `ObservableGauge` metric.
  59. *
  60. * The callback SHOULD be safe to be invoked concurrently.
  61. *
  62. * @param name the name of the metric.
  63. * @param [options] the metric options.
  64. */
  65. createObservableGauge<AttributesTypes extends MetricAttributes = MetricAttributes>(name: string, options?: MetricOptions): ObservableGauge<AttributesTypes>;
  66. /**
  67. * Creates a new `ObservableCounter` metric.
  68. *
  69. * The callback SHOULD be safe to be invoked concurrently.
  70. *
  71. * @param name the name of the metric.
  72. * @param [options] the metric options.
  73. */
  74. createObservableCounter<AttributesTypes extends MetricAttributes = MetricAttributes>(name: string, options?: MetricOptions): ObservableCounter<AttributesTypes>;
  75. /**
  76. * Creates a new `ObservableUpDownCounter` metric.
  77. *
  78. * The callback SHOULD be safe to be invoked concurrently.
  79. *
  80. * @param name the name of the metric.
  81. * @param [options] the metric options.
  82. */
  83. createObservableUpDownCounter<AttributesTypes extends MetricAttributes = MetricAttributes>(name: string, options?: MetricOptions): ObservableUpDownCounter<AttributesTypes>;
  84. /**
  85. * Sets up a function that will be called whenever a metric collection is
  86. * initiated.
  87. *
  88. * If the function is already in the list of callbacks for this Observable,
  89. * the function is not added a second time.
  90. *
  91. * Only the associated observables can be observed in the callback.
  92. * Measurements of observables that are not associated observed in the
  93. * callback are dropped.
  94. *
  95. * @param callback the batch observable callback
  96. * @param observables the observables associated with this batch observable callback
  97. */
  98. addBatchObservableCallback<AttributesTypes extends MetricAttributes = MetricAttributes>(callback: BatchObservableCallback<AttributesTypes>, observables: Observable<AttributesTypes>[]): void;
  99. /**
  100. * Removes a callback previously registered with {@link Meter.addBatchObservableCallback}.
  101. *
  102. * The callback to be removed is identified using a combination of the callback itself,
  103. * and the set of the observables associated with it.
  104. *
  105. * @param callback the batch observable callback
  106. * @param observables the observables associated with this batch observable callback
  107. */
  108. removeBatchObservableCallback<AttributesTypes extends MetricAttributes = MetricAttributes>(callback: BatchObservableCallback<AttributesTypes>, observables: Observable<AttributesTypes>[]): void;
  109. }
  110. //# sourceMappingURL=Meter.d.ts.map