@kb-labs/rest-api-app 2.107.0 → 2.110.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -650,7 +650,7 @@ var restDomainOperationMetrics = new OperationMetricsTracker();
650
650
  var requestCounter = 0;
651
651
  function shouldSampleRequest(route) {
652
652
  requestCounter = (requestCounter + 1) % 100;
653
- if (route === "/api/v1/metrics") {
653
+ if (route === "/metrics" || route === "/api/v1/metrics") {
654
654
  return requestCounter === 0;
655
655
  }
656
656
  if (route === "/api/v1/health" || route === "/api/v1/ready" || route === "/api/v1/observability/health" || route === "/api/v1/observability/describe") {
@@ -1451,7 +1451,7 @@ function buildRestObservabilityDescribe(basePath) {
1451
1451
  description: "State broker and cache-backed storage"
1452
1452
  }
1453
1453
  ],
1454
- metricsEndpoint: `${basePath}/metrics`,
1454
+ metricsEndpoint: "/metrics",
1455
1455
  healthEndpoint: `${basePath}/observability/health`,
1456
1456
  logsSource: "rest",
1457
1457
  capabilities: ["httpMetrics", "eventLoopMetrics", "operationMetrics", "logCorrelation"],
@@ -1495,7 +1495,7 @@ function buildRestObservabilityHealth(basePath, healthSnapshot, readiness, metri
1495
1495
  observedAt: healthSnapshot.ts,
1496
1496
  status: healthSnapshot.status === "healthy" ? "healthy" : healthSnapshot.status === "degraded" ? "degraded" : "unhealthy",
1497
1497
  uptimeSec: healthSnapshot.uptimeSec,
1498
- metricsEndpoint: `${basePath}/metrics`,
1498
+ metricsEndpoint: "/metrics",
1499
1499
  logsSource: "rest",
1500
1500
  capabilities: ["httpMetrics", "eventLoopMetrics", "operationMetrics", "logCorrelation"],
1501
1501
  checks,
@@ -1877,8 +1877,9 @@ function formatNumber(value, fractionDigits = 2) {
1877
1877
  return Number.isFinite(value) ? value.toFixed(fractionDigits) : "0";
1878
1878
  }
1879
1879
  function registerMetricsRoutes(server, config) {
1880
- const basePath = config.basePath;
1881
- server.get(`${basePath}/metrics`, async (_request, reply) => {
1880
+ const basePath = normalizeBasePath(config.basePath);
1881
+ const metricsPaths = resolvePaths(basePath, "/metrics");
1882
+ const handler = async (_request, reply) => {
1882
1883
  const metrics = metricsCollector.getMetrics();
1883
1884
  updateProcessUptime(metrics.timestamps.startTime);
1884
1885
  const promMetrics = await getPrometheusMetrics();
@@ -1928,7 +1929,10 @@ function registerMetricsRoutes(server, config) {
1928
1929
  }
1929
1930
  reply.header("Content-Type", "text/plain; version=0.0.4; charset=utf-8");
1930
1931
  return promMetrics + "\n" + customLines.join("\n");
1931
- });
1932
+ };
1933
+ for (const path3 of metricsPaths) {
1934
+ server.get(path3, handler);
1935
+ }
1932
1936
  server.get(`${basePath}/metrics/headers/debug`, {
1933
1937
  schema: {
1934
1938
  querystring: {