@truefoundry/trueforge 0.179.1 → 0.179.2

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/main.js CHANGED
@@ -15013,14 +15013,15 @@ function serverTlsServeOptions(options) {
15013
15013
  cert: Buffer.from(read(TLS_CERT_FILE)),
15014
15014
  ca: Buffer.from(read(TLS_CA_FILE)),
15015
15015
  requestCert: true,
15016
- // Do not reject at handshake so /healthz probes without a cert still connect.
15016
+ // Do not reject at handshake so /healthz probes and /metrics scrapes without a cert still connect.
15017
15017
  rejectUnauthorized: false
15018
15018
  }
15019
15019
  };
15020
15020
  }
15021
+ var CLIENT_CERT_EXEMPT_PATHS = /* @__PURE__ */ new Set(["/healthz", "/metrics"]);
15021
15022
  function createClientCertificateMiddleware(logger2) {
15022
15023
  return async (c, next) => {
15023
- if (c.req.path === "/healthz") {
15024
+ if (CLIENT_CERT_EXEMPT_PATHS.has(c.req.path)) {
15024
15025
  await next();
15025
15026
  return;
15026
15027
  }
@@ -19492,6 +19493,25 @@ function createSettingsRouter(deps) {
19492
19493
 
19493
19494
  // src/app.ts
19494
19495
  init_config();
19496
+
19497
+ // src/http/prometheus.ts
19498
+ import { prometheus } from "@hono/prometheus";
19499
+ var DURATION_BUCKETS_SECONDS = [0.01, 0.05, 0.1, 0.2, 0.5, 1, 2.5, 5, 10, 30, 60, 120, 300];
19500
+ var requestDuration = {
19501
+ help: "Duration of HTTP requests in seconds",
19502
+ buckets: DURATION_BUCKETS_SECONDS
19503
+ };
19504
+ function createHttpMetrics() {
19505
+ const { printMetrics, registerMetrics } = prometheus({
19506
+ collectDefaultMetrics: true,
19507
+ metricOptions: {
19508
+ requestDuration
19509
+ }
19510
+ });
19511
+ return { middleware: registerMetrics, handler: printMetrics };
19512
+ }
19513
+
19514
+ // src/app.ts
19495
19515
  init_schedule();
19496
19516
 
19497
19517
  // src/zodErrorResponse.ts
@@ -19630,6 +19650,8 @@ function createServerApp(deps) {
19630
19650
  activeTurns: deps.activeTurns,
19631
19651
  turnSkillsResolverStore: deps.turnSkillsResolverStore
19632
19652
  };
19653
+ const httpMetrics = createHttpMetrics();
19654
+ app.use("/api/*", httpMetrics.middleware);
19633
19655
  if (config_default.ACCESS_LOGS) {
19634
19656
  app.use("*", createAccessLogMiddleware(deps.logger));
19635
19657
  }
@@ -19638,6 +19660,7 @@ function createServerApp(deps) {
19638
19660
  }
19639
19661
  app.use("*", createRequestBodyLimitMiddleware(config_default.MAX_REQUEST_BODY_BYTES));
19640
19662
  app.get("/healthz", (c) => c.json({ status: "ok", version: PACKAGE_VERSION }));
19663
+ app.get("/metrics", httpMetrics.handler);
19641
19664
  app.route(
19642
19665
  "/api/v1/auth",
19643
19666
  createAuthRouter({
@@ -20590,7 +20613,7 @@ import { every } from "hono/combine";
20590
20613
  import { compress } from "hono/compress";
20591
20614
  import { existsSync as existsSync6, readFileSync as readFileSync5 } from "fs";
20592
20615
  import path3 from "path";
20593
- var SERVER_PATH_PREFIXES = ["/api", "/healthz"];
20616
+ var SERVER_PATH_PREFIXES = ["/api", "/healthz", "/metrics"];
20594
20617
  var HASHED_ASSET_PREFIX = "/assets/";
20595
20618
  var IMMUTABLE_CACHE_CONTROL = "public, max-age=31536000, immutable";
20596
20619
  var REVALIDATE_CACHE_CONTROL = "no-cache";