UNPKG

4.41 kBJavaScriptView Raw
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 */
17Object.defineProperty(exports, "__esModule", { value: true });
18exports.createNoopMeter = exports.NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC = exports.NOOP_OBSERVABLE_GAUGE_METRIC = exports.NOOP_OBSERVABLE_COUNTER_METRIC = exports.NOOP_UP_DOWN_COUNTER_METRIC = exports.NOOP_HISTOGRAM_METRIC = exports.NOOP_COUNTER_METRIC = exports.NOOP_METER = exports.NoopObservableUpDownCounterMetric = exports.NoopObservableGaugeMetric = exports.NoopObservableCounterMetric = exports.NoopObservableMetric = exports.NoopHistogramMetric = exports.NoopUpDownCounterMetric = exports.NoopCounterMetric = exports.NoopMetric = exports.NoopMeter = void 0;
19/**
20 * NoopMeter is a noop implementation of the {@link Meter} interface. It reuses
21 * constant NoopMetrics for all of its methods.
22 */
23class NoopMeter {
24 constructor() { }
25 /**
26 * @see {@link Meter.createHistogram}
27 */
28 createHistogram(_name, _options) {
29 return exports.NOOP_HISTOGRAM_METRIC;
30 }
31 /**
32 * @see {@link Meter.createCounter}
33 */
34 createCounter(_name, _options) {
35 return exports.NOOP_COUNTER_METRIC;
36 }
37 /**
38 * @see {@link Meter.createUpDownCounter}
39 */
40 createUpDownCounter(_name, _options) {
41 return exports.NOOP_UP_DOWN_COUNTER_METRIC;
42 }
43 /**
44 * @see {@link Meter.createObservableGauge}
45 */
46 createObservableGauge(_name, _options) {
47 return exports.NOOP_OBSERVABLE_GAUGE_METRIC;
48 }
49 /**
50 * @see {@link Meter.createObservableCounter}
51 */
52 createObservableCounter(_name, _options) {
53 return exports.NOOP_OBSERVABLE_COUNTER_METRIC;
54 }
55 /**
56 * @see {@link Meter.createObservableUpDownCounter}
57 */
58 createObservableUpDownCounter(_name, _options) {
59 return exports.NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC;
60 }
61 /**
62 * @see {@link Meter.addBatchObservableCallback}
63 */
64 addBatchObservableCallback(_callback, _observables) { }
65 /**
66 * @see {@link Meter.removeBatchObservableCallback}
67 */
68 removeBatchObservableCallback(_callback) { }
69}
70exports.NoopMeter = NoopMeter;
71class NoopMetric {
72}
73exports.NoopMetric = NoopMetric;
74class NoopCounterMetric extends NoopMetric {
75 add(_value, _attributes) { }
76}
77exports.NoopCounterMetric = NoopCounterMetric;
78class NoopUpDownCounterMetric extends NoopMetric {
79 add(_value, _attributes) { }
80}
81exports.NoopUpDownCounterMetric = NoopUpDownCounterMetric;
82class NoopHistogramMetric extends NoopMetric {
83 record(_value, _attributes) { }
84}
85exports.NoopHistogramMetric = NoopHistogramMetric;
86class NoopObservableMetric {
87 addCallback(_callback) { }
88 removeCallback(_callback) { }
89}
90exports.NoopObservableMetric = NoopObservableMetric;
91class NoopObservableCounterMetric extends NoopObservableMetric {
92}
93exports.NoopObservableCounterMetric = NoopObservableCounterMetric;
94class NoopObservableGaugeMetric extends NoopObservableMetric {
95}
96exports.NoopObservableGaugeMetric = NoopObservableGaugeMetric;
97class NoopObservableUpDownCounterMetric extends NoopObservableMetric {
98}
99exports.NoopObservableUpDownCounterMetric = NoopObservableUpDownCounterMetric;
100exports.NOOP_METER = new NoopMeter();
101// Synchronous instruments
102exports.NOOP_COUNTER_METRIC = new NoopCounterMetric();
103exports.NOOP_HISTOGRAM_METRIC = new NoopHistogramMetric();
104exports.NOOP_UP_DOWN_COUNTER_METRIC = new NoopUpDownCounterMetric();
105// Asynchronous instruments
106exports.NOOP_OBSERVABLE_COUNTER_METRIC = new NoopObservableCounterMetric();
107exports.NOOP_OBSERVABLE_GAUGE_METRIC = new NoopObservableGaugeMetric();
108exports.NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC = new NoopObservableUpDownCounterMetric();
109/**
110 * Create a no-op Meter
111 */
112function createNoopMeter() {
113 return exports.NOOP_METER;
114}
115exports.createNoopMeter = createNoopMeter;
116//# sourceMappingURL=NoopMeter.js.map
\No newline at end of file