npm package diff

Package: @forge/runtime

Versions: 6.0.0-next.0-experimental-97e4b11 - 6.0.0-next.1

File: package/out/metrics/metrics.js

Index: package/out/metrics/metrics.js
===================================================================
--- package/out/metrics/metrics.js
+++ package/out/metrics/metrics.js
@@ -1,78 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.createMetricsCollector = exports.MetricsCollector = exports.MetricType = void 0;
-const in_memory_metrics_1 = require("@forge/util/packages/in-memory-metrics");
-const metrics_interface_1 = require("@forge/util/packages/metrics-interface");
-const feature_flag_1 = require("../feature-flag");
-var MetricType;
-(function (MetricType) {
-    MetricType["TimerMetric"] = "timer";
-    MetricType["CounterMetric"] = "counter";
-    MetricType["GaugeMetric"] = "gauge";
-})(MetricType = exports.MetricType || (exports.MetricType = {}));
-function isInMemoryMetrics(metrics) {
-    return metrics.constructor.name === in_memory_metrics_1.InMemoryMetrics.name;
-}
-class MetricsCollector {
-    _metrics;
-    constructor(_metrics) {
-        this._metrics = _metrics;
-    }
-    metrics() {
-        return this._metrics;
-    }
-    collectMetrics() {
-        return MetricsCollector.collect(this._metrics);
-    }
-    static collect(metrics, prefix = undefined) {
-        if (!isInMemoryMetrics(metrics)) {
-            return [];
-        }
-        const addPrefix = (p, value) => {
-            return p ? p + '.' + value : value;
-        };
-        const allMetrics = Array.from(metrics.getChildren().values())
-            .map((v) => [...MetricsCollector.collect(v, addPrefix(prefix, v.getName()))])
-            .reduce((accumulator, value) => accumulator.concat(value), []);
-        const counters = Array.from(metrics.getCounters().values()).map((v) => ({
-            name: addPrefix(prefix, v.getName()),
-            tags: v.getTags(),
-            type: MetricType.CounterMetric,
-            value: v.getCount()
-        }));
-        const gauges = Array.from(metrics.getGauges().values()).map((v) => ({
-            name: addPrefix(prefix, v.getName()),
-            tags: v.getTags(),
-            type: MetricType.GaugeMetric,
-            value: v.getValue()
-        }));
-        const timers = metrics.getTimers().map((v) => ({
-            name: addPrefix(prefix, v.getName()),
-            tags: v.getTags(),
-            type: MetricType.TimerMetric,
-            value: v.getTime()
-        }));
-        allMetrics.push(...timers, ...counters, ...gauges);
-        return allMetrics;
-    }
-    async wrapInMetrics(options, callback) {
-        this._metrics.counter(options.name, options.tags).incr();
-        const timer = this._metrics.timing(options.name, options.tags).measure();
-        try {
-            return await callback();
-        }
-        finally {
-            timer.stop();
-        }
-    }
-}
-exports.MetricsCollector = MetricsCollector;
-const createMetricsCollector = (xenInvocationRequest) => {
-    const shouldReportMetrics = xenInvocationRequest.isFeatureFlagEnabled(feature_flag_1.XEN_RUNTIME_SHOULD_REPORT_METRICS);
-    const metrics = shouldReportMetrics ? new in_memory_metrics_1.InMemoryMetrics() : new metrics_interface_1.NoMetrics();
-    return {
-        collector: new MetricsCollector(metrics),
-        enabled: shouldReportMetrics
-    };
-};
-exports.createMetricsCollector = createMetricsCollector;