@fluojs/metrics
Advanced tools
@@ -161,2 +161,3 @@ function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; } | ||
| if (!platformShell) { | ||
| this.clearPlatformTelemetry(); | ||
| return; | ||
@@ -199,2 +200,36 @@ } | ||
| } | ||
| clearPlatformTelemetry() { | ||
| this.clearGaugeStatuses({ | ||
| env: this.labels?.env ?? 'unknown', | ||
| gauge: this.healthGauge, | ||
| instance: this.labels?.instance ?? 'local', | ||
| lastStatuses: this.lastHealthStatuses, | ||
| operation: 'health', | ||
| statuses: HEALTH_STATUSES | ||
| }); | ||
| this.clearGaugeStatuses({ | ||
| env: this.labels?.env ?? 'unknown', | ||
| gauge: this.readinessGauge, | ||
| instance: this.labels?.instance ?? 'local', | ||
| lastStatuses: this.lastReadinessStatuses, | ||
| operation: 'readiness', | ||
| statuses: READINESS_STATUSES | ||
| }); | ||
| } | ||
| clearGaugeStatuses({ | ||
| env, | ||
| gauge, | ||
| instance, | ||
| lastStatuses, | ||
| operation, | ||
| statuses | ||
| }) { | ||
| for (const componentKey of lastStatuses.keys()) { | ||
| const [componentId, componentKind] = this.fromComponentKey(componentKey); | ||
| for (const status of statuses) { | ||
| gauge.remove(componentId, componentKind, operation, status, env, instance); | ||
| } | ||
| } | ||
| lastStatuses.clear(); | ||
| } | ||
| syncGaugeStatuses({ | ||
@@ -201,0 +236,0 @@ currentStatuses, |
+4
-4
@@ -11,3 +11,3 @@ { | ||
| ], | ||
| "version": "1.0.0-beta.1", | ||
| "version": "1.0.0-beta.2", | ||
| "private": false, | ||
@@ -40,5 +40,5 @@ "license": "MIT", | ||
| "prom-client": "^15.1.3", | ||
| "@fluojs/di": "^1.0.0-beta.1", | ||
| "@fluojs/runtime": "^1.0.0-beta.1", | ||
| "@fluojs/http": "^1.0.0-beta.1" | ||
| "@fluojs/di": "^1.0.0-beta.2", | ||
| "@fluojs/http": "^1.0.0-beta.1", | ||
| "@fluojs/runtime": "^1.0.0-beta.2" | ||
| }, | ||
@@ -45,0 +45,0 @@ "devDependencies": { |
+5
-1
@@ -148,2 +148,3 @@ # @fluojs/metrics | ||
| - `PLATFORM_SHELL` 등록 자체가 빠진 경우에는 스크레이프가 계속 성공하고 플랫폼 텔레메트리 시리즈만 생략됩니다. | ||
| - 이전 스크레이프에서 플랫폼 텔레메트리를 노출한 뒤 `PLATFORM_SHELL`을 사용할 수 없게 되면, stale `fluo_component_ready` 및 `fluo_component_health` 시리즈를 제거한 뒤 메트릭을 반환합니다. | ||
| - 그 외의 `PLATFORM_SHELL` resolve 실패는 조용히 삼키지 않고 스크레이프 실패로 그대로 드러납니다. | ||
@@ -166,3 +167,5 @@ | ||
| - `METER_PROVIDER` (Token) | ||
| - 카운터, 게이지, 히스토그램 및 레지스트리 접근을 위한 Prometheus 기반 헬퍼 | ||
| - `PrometheusMeterProvider` | ||
| - `HttpMetricsMiddleware` 및 HTTP path-label 옵션 타입 | ||
| - `prom-client`의 `Registry` | ||
@@ -177,2 +180,3 @@ ### 운영 기본값 | ||
| - 플랫폼 텔레메트리는 `PLATFORM_SHELL`이 실제로 누락된 경우에만 생략되며, 그 외 resolve 실패는 스크레이프를 실패시킵니다. | ||
| - 이전에 노출된 플랫폼 텔레메트리 시리즈는 `PLATFORM_SHELL`을 사용할 수 없게 된 스크레이프에서 제거됩니다. | ||
@@ -179,0 +183,0 @@ ## 관련 패키지 |
+5
-1
@@ -129,2 +129,3 @@ # @fluojs/metrics | ||
| - If `PLATFORM_SHELL` is not registered, the scrape still succeeds and omits the platform telemetry series. | ||
| - If `PLATFORM_SHELL` becomes unavailable after a previous successful scrape, stale `fluo_component_ready` and `fluo_component_health` series are removed before metrics are returned. | ||
| - If resolving `PLATFORM_SHELL` fails for any other reason, the scrape surfaces that failure instead of swallowing it. | ||
@@ -147,3 +148,5 @@ | ||
| - `METER_PROVIDER` | ||
| - Prometheus-backed helpers for counters, gauges, histograms, and registry access | ||
| - `PrometheusMeterProvider` | ||
| - `HttpMetricsMiddleware` and HTTP path-label option types | ||
| - `Registry` from `prom-client` | ||
@@ -158,2 +161,3 @@ ### Operational defaults | ||
| - Platform telemetry is omitted only when `PLATFORM_SHELL` is genuinely missing; other resolution failures fail the scrape. | ||
| - Stale platform telemetry series are removed when `PLATFORM_SHELL` becomes unavailable after a prior successful scrape. | ||
@@ -160,0 +164,0 @@ ## Related Packages |
54490
3.34%795
4.61%171
2.4%Updated