feat: add open telemetry instrumentation (#2786)
This commit adds some useful automatic instrumentation for when users are using `--unstable-otel`: - Fresh renames the span for incoming HTTP requests to `$METHOD $ROUTE` and the `http.route` attribute is added. - Fresh creates a span around FS route handlers, showing whether they returned a response or data. - Fresh creates a span around async components, showing how long they took to execute. - Fresh adds a span around preact rendering, showing how long rendering takes. - Fresh adds a span around static file serving, showing how long it took and whether there were requests without a cache bust key. We can improve this in the future with more telemetry, such as metrics.
This commit is contained in:
@@ -40,13 +40,15 @@
|
||||
"exclude": ["**/*_test.*", "src/__OLD/**", "*.todo"]
|
||||
},
|
||||
"imports": {
|
||||
"fresh": "jsr:@fresh/core@^2.0.0-alpha.22",
|
||||
"preact": "npm:preact@^10.24.1",
|
||||
"fresh": "jsr:@fresh/core@^2.0.0-alpha.25",
|
||||
"preact": "npm:preact@^10.25.1",
|
||||
"preact-render-to-string": "npm:preact-render-to-string@^6.5.11",
|
||||
"$ga4": "https://raw.githubusercontent.com/denoland/ga4/main/mod.ts",
|
||||
"@luca/esbuild-deno-loader": "jsr:@luca/esbuild-deno-loader@^0.11.0",
|
||||
"@opentelemetry/api": "npm:@opentelemetry/api@^1.9.0",
|
||||
"@preact/signals": "npm:@preact/signals@^1.2.3",
|
||||
"esbuild": "npm:esbuild@0.23.1",
|
||||
"esbuild-wasm": "npm:esbuild-wasm@0.23.1",
|
||||
"@luca/esbuild-deno-loader": "jsr:@luca/esbuild-deno-loader@^0.11.0",
|
||||
"@std/crypto": "jsr:@std/crypto@1",
|
||||
"@std/datetime": "jsr:@std/datetime@^0.225.2",
|
||||
"@std/encoding": "jsr:@std/encoding@1",
|
||||
@@ -66,7 +68,7 @@
|
||||
"@std/expect": "jsr:@std/expect@1"
|
||||
},
|
||||
"compilerOptions": {
|
||||
"lib": ["dom", "dom.asynciterable", "deno.ns"],
|
||||
"lib": ["dom", "dom.asynciterable", "deno.ns", "deno.unstable"],
|
||||
"jsx": "precompile",
|
||||
"jsxImportSource": "preact",
|
||||
"jsxPrecompileSkipElements": ["a", "img", "source", "body", "html", "head"]
|
||||
|
||||
+14
-6
@@ -1,3 +1,8 @@
|
||||
import * as path from "@std/path";
|
||||
import { type ComponentType, h } from "preact";
|
||||
import { renderToString } from "preact-render-to-string";
|
||||
import { trace } from "@opentelemetry/api";
|
||||
|
||||
import { DENO_DEPLOYMENT_ID } from "./runtime/build_id.ts";
|
||||
import * as colors from "@std/fmt/colors";
|
||||
import { type MiddlewareFn, runMiddlewares } from "./middlewares/mod.ts";
|
||||
@@ -14,10 +19,7 @@ import {
|
||||
type ResolvedFreshConfig,
|
||||
} from "./config.ts";
|
||||
import { type BuildCache, ProdBuildCache } from "./build_cache.ts";
|
||||
import * as path from "@std/path";
|
||||
import { type ComponentType, h } from "preact";
|
||||
import type { ServerIslandRegistry } from "./context.ts";
|
||||
import { renderToString } from "preact-render-to-string";
|
||||
import { FinishSetup, ForgotBuild } from "./finish_setup.tsx";
|
||||
import { HttpError } from "./error.ts";
|
||||
|
||||
@@ -140,8 +142,8 @@ export class App<State> {
|
||||
|
||||
// Special case when user calls one of these:
|
||||
// - `app.mountApp("/", otherApp)`
|
||||
// - `app.mountApp("*", otherApp)`
|
||||
const isSelf = path === "*" || path === "/";
|
||||
// - `app.mountApp("/*", otherApp)`
|
||||
const isSelf = path === "/*" || path === "/";
|
||||
if (isSelf && middlewares.length > 0) {
|
||||
this.#router._middlewares.push(...middlewares);
|
||||
}
|
||||
@@ -205,7 +207,7 @@ export class App<State> {
|
||||
? DEFAULT_NOT_ALLOWED_METHOD
|
||||
: DEFAULT_NOT_FOUND;
|
||||
|
||||
const { params, handlers } = matched;
|
||||
const { params, handlers, pattern } = matched;
|
||||
const ctx = new FreshReqContext<State>(
|
||||
req,
|
||||
url,
|
||||
@@ -217,6 +219,12 @@ export class App<State> {
|
||||
this.#buildCache!,
|
||||
);
|
||||
|
||||
const span = trace.getActiveSpan();
|
||||
if (span && pattern) {
|
||||
span.updateName(`${method} ${pattern}`);
|
||||
span.setAttribute("http.route", pattern);
|
||||
}
|
||||
|
||||
try {
|
||||
if (handlers.length === 1 && handlers[0].length === 1) {
|
||||
return handlers[0][0](ctx);
|
||||
|
||||
+27
-8
@@ -6,6 +6,7 @@ import {
|
||||
type VNode,
|
||||
} from "preact";
|
||||
import { renderToString } from "preact-render-to-string";
|
||||
import { SpanStatusCode } from "@opentelemetry/api";
|
||||
import type { ResolvedFreshConfig } from "./config.ts";
|
||||
import type { BuildCache } from "./build_cache.ts";
|
||||
import {
|
||||
@@ -15,6 +16,7 @@ import {
|
||||
} from "./runtime/server/preact_hooks.tsx";
|
||||
import { DEV_ERROR_OVERLAY_URL } from "./constants.ts";
|
||||
import { BUILD_ID } from "./runtime/build_id.ts";
|
||||
import { tracer } from "./otel.ts";
|
||||
|
||||
export interface Island {
|
||||
file: string | URL;
|
||||
@@ -184,14 +186,31 @@ export class FreshReqContext<State>
|
||||
headers.set("X-Fresh-Id", partialId);
|
||||
}
|
||||
|
||||
const html = preactRender(
|
||||
vnode,
|
||||
this,
|
||||
this.#islandRegistry,
|
||||
this.#buildCache,
|
||||
partialId,
|
||||
headers,
|
||||
);
|
||||
const html = tracer.startActiveSpan("render", (span) => {
|
||||
span.setAttribute("fresh.span_type", "render");
|
||||
try {
|
||||
return preactRender(
|
||||
vnode,
|
||||
this,
|
||||
this.#islandRegistry,
|
||||
this.#buildCache,
|
||||
partialId,
|
||||
headers,
|
||||
);
|
||||
} catch (err) {
|
||||
if (err instanceof Error) {
|
||||
span.recordException(err);
|
||||
} else {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: String(err),
|
||||
});
|
||||
}
|
||||
throw err;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
});
|
||||
return new Response(html, responseInit);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ export class Builder implements FreshBuilder {
|
||||
const devApp = new App<T>(app.config)
|
||||
.use(liveReload())
|
||||
.use(devErrorOverlay())
|
||||
.mountApp("*", app);
|
||||
.mountApp("/*", app);
|
||||
|
||||
devApp.config.mode = "development";
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import * as semver from "@std/semver";
|
||||
import * as colors from "@std/fmt/colors";
|
||||
import * as path from "@std/path";
|
||||
import { CURRENT_FRESH_VERSION } from "../otel.ts";
|
||||
|
||||
export interface CheckFile {
|
||||
last_checked: string;
|
||||
@@ -48,10 +49,8 @@ async function fetchLatestVersion() {
|
||||
throw new Error(`Could not fetch latest version.`);
|
||||
}
|
||||
|
||||
async function readCurrentVersion() {
|
||||
return (await import("../../deno.json", {
|
||||
with: { type: "json" },
|
||||
})).default.version;
|
||||
function readCurrentVersion() {
|
||||
return CURRENT_FRESH_VERSION;
|
||||
}
|
||||
|
||||
export async function updateCheck(
|
||||
|
||||
@@ -4,6 +4,7 @@ import type { MiddlewareFn } from "./mod.ts";
|
||||
import { ASSET_CACHE_BUST_KEY } from "../runtime/shared_internal.tsx";
|
||||
import { BUILD_ID } from "../runtime/build_id.ts";
|
||||
import { getBuildCache } from "../context.ts";
|
||||
import { tracer } from "../otel.ts";
|
||||
|
||||
/**
|
||||
* Fresh middleware to enable file-system based routing.
|
||||
@@ -25,6 +26,7 @@ export function staticFiles<T>(): MiddlewareFn<T> {
|
||||
}
|
||||
|
||||
// Fast path bail out
|
||||
const startTime = performance.now() + performance.timeOrigin;
|
||||
const file = await buildCache.readFile(pathname);
|
||||
if (pathname === "/" || file === null) {
|
||||
// Optimization: Prevent long responses for favicon.ico requests
|
||||
@@ -39,60 +41,74 @@ export function staticFiles<T>(): MiddlewareFn<T> {
|
||||
return new Response("Method Not Allowed", { status: 405 });
|
||||
}
|
||||
|
||||
const cacheKey = url.searchParams.get(ASSET_CACHE_BUST_KEY);
|
||||
if (cacheKey !== null && BUILD_ID !== cacheKey) {
|
||||
url.searchParams.delete(ASSET_CACHE_BUST_KEY);
|
||||
const location = url.pathname + url.search;
|
||||
file.close();
|
||||
return new Response(null, {
|
||||
status: 307,
|
||||
headers: {
|
||||
location,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const ext = path.extname(pathname);
|
||||
const etag = file.hash;
|
||||
|
||||
const contentType = getContentType(ext);
|
||||
const headers = new Headers({
|
||||
"Content-Type": contentType ?? "text/plain",
|
||||
vary: "If-None-Match",
|
||||
const span = tracer.startSpan("static file", {
|
||||
attributes: { "fresh.span_type": "static_file" },
|
||||
startTime,
|
||||
});
|
||||
|
||||
const ifNoneMatch = req.headers.get("If-None-Match");
|
||||
if (
|
||||
ifNoneMatch !== null &&
|
||||
(ifNoneMatch === etag || ifNoneMatch === `W/"${etag}"`)
|
||||
) {
|
||||
file.close();
|
||||
return new Response(null, { status: 304, headers });
|
||||
} else if (etag !== null) {
|
||||
headers.set("Etag", `W/"${etag}"`);
|
||||
}
|
||||
try {
|
||||
const cacheKey = url.searchParams.get(ASSET_CACHE_BUST_KEY);
|
||||
if (cacheKey !== null && BUILD_ID !== cacheKey) {
|
||||
url.searchParams.delete(ASSET_CACHE_BUST_KEY);
|
||||
const location = url.pathname + url.search;
|
||||
file.close();
|
||||
span.setAttribute("fresh.cache", "invalid_bust_key");
|
||||
span.setAttribute("fresh.cache_key", cacheKey);
|
||||
return new Response(null, {
|
||||
status: 307,
|
||||
headers: {
|
||||
location,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
ctx.config.mode !== "development" &&
|
||||
(BUILD_ID === cacheKey ||
|
||||
url.pathname.startsWith(
|
||||
`${ctx.config.basePath}/_fresh/js/${BUILD_ID}/`,
|
||||
))
|
||||
) {
|
||||
headers.append("Cache-Control", "public, max-age=31536000, immutable");
|
||||
} else {
|
||||
headers.append(
|
||||
"Cache-Control",
|
||||
"no-cache, no-store, max-age=0, must-revalidate",
|
||||
);
|
||||
}
|
||||
const ext = path.extname(pathname);
|
||||
const etag = file.hash;
|
||||
|
||||
headers.set("Content-Length", String(file.size));
|
||||
if (req.method === "HEAD") {
|
||||
file.close();
|
||||
return new Response(null, { status: 200, headers });
|
||||
}
|
||||
const contentType = getContentType(ext);
|
||||
const headers = new Headers({
|
||||
"Content-Type": contentType ?? "text/plain",
|
||||
vary: "If-None-Match",
|
||||
});
|
||||
|
||||
return new Response(file.readable, { headers });
|
||||
const ifNoneMatch = req.headers.get("If-None-Match");
|
||||
if (
|
||||
ifNoneMatch !== null &&
|
||||
(ifNoneMatch === etag || ifNoneMatch === `W/"${etag}"`)
|
||||
) {
|
||||
file.close();
|
||||
span.setAttribute("fresh.cache", "not_modified");
|
||||
return new Response(null, { status: 304, headers });
|
||||
} else if (etag !== null) {
|
||||
headers.set("Etag", `W/"${etag}"`);
|
||||
}
|
||||
|
||||
if (
|
||||
ctx.config.mode !== "development" &&
|
||||
(BUILD_ID === cacheKey ||
|
||||
url.pathname.startsWith(
|
||||
`${ctx.config.basePath}/_fresh/js/${BUILD_ID}/`,
|
||||
))
|
||||
) {
|
||||
span.setAttribute("fresh.cache", "immutable");
|
||||
headers.append("Cache-Control", "public, max-age=31536000, immutable");
|
||||
} else {
|
||||
span.setAttribute("fresh.cache", "no_cache");
|
||||
headers.append(
|
||||
"Cache-Control",
|
||||
"no-cache, no-store, max-age=0, must-revalidate",
|
||||
);
|
||||
}
|
||||
|
||||
headers.set("Content-Length", String(file.size));
|
||||
if (req.method === "HEAD") {
|
||||
file.close();
|
||||
return new Response(null, { status: 200, headers });
|
||||
}
|
||||
|
||||
return new Response(file.readable, { headers });
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import { trace } from "@opentelemetry/api";
|
||||
import denoJson from "../deno.json" with { type: "json" };
|
||||
|
||||
export const CURRENT_FRESH_VERSION = denoJson.version;
|
||||
|
||||
export const tracer = trace.getTracer("fresh", CURRENT_FRESH_VERSION);
|
||||
@@ -251,7 +251,7 @@ export async function fsRoutes<State>(
|
||||
errorComponents.push(mod.component);
|
||||
}
|
||||
let parent = mod.path.slice(0, -"_error".length);
|
||||
parent = parent === "/" ? "*" : parent + "*";
|
||||
parent = parent + "*";
|
||||
|
||||
// Add error route as its own route
|
||||
if (!specialPaths.has(mod.path)) {
|
||||
|
||||
@@ -3,6 +3,8 @@ import type { MiddlewareFn } from "../../middlewares/mod.ts";
|
||||
import type { HandlerFn, PageResponse } from "../../handlers.ts";
|
||||
import type { FreshReqContext, PageProps } from "../../context.ts";
|
||||
import { HttpError } from "../../error.ts";
|
||||
import { tracer } from "../../otel.ts";
|
||||
import { SpanStatusCode } from "@opentelemetry/api";
|
||||
|
||||
export type AsyncAnyComponent<P> = {
|
||||
(
|
||||
@@ -31,7 +33,30 @@ export function renderMiddleware<State>(
|
||||
return async (ctx) => {
|
||||
let result: PageResponse<unknown> | undefined;
|
||||
if (handler !== undefined) {
|
||||
const res = await handler(ctx);
|
||||
const res = await tracer.startActiveSpan("handler", {
|
||||
attributes: { "fresh.span_type": "fs_routes/handler" },
|
||||
}, async (span) => {
|
||||
try {
|
||||
const res = await handler(ctx);
|
||||
span.setAttribute(
|
||||
"fresh.handler_response",
|
||||
res instanceof Response ? "http" : "data",
|
||||
);
|
||||
return res;
|
||||
} catch (err) {
|
||||
if (err instanceof Error) {
|
||||
span.recordException(err);
|
||||
} else {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: String(err),
|
||||
});
|
||||
}
|
||||
throw err;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
});
|
||||
|
||||
if (res instanceof Response) {
|
||||
return res;
|
||||
@@ -56,7 +81,32 @@ export function renderMiddleware<State>(
|
||||
const fn = components[i];
|
||||
|
||||
if (isAsyncAnyComponent(fn)) {
|
||||
const result = (await fn(props)) as VNode | Response;
|
||||
const result = await tracer.startActiveSpan(
|
||||
"invoke async component",
|
||||
async (span) => {
|
||||
span.setAttribute("fresh.span_type", "fs_routes/async_component");
|
||||
try {
|
||||
const result = (await fn(props)) as VNode | Response;
|
||||
span.setAttribute(
|
||||
"fresh.component_response",
|
||||
result instanceof Response ? "http" : "jsx",
|
||||
);
|
||||
return result;
|
||||
} catch (err) {
|
||||
if (err instanceof Error) {
|
||||
span.recordException(err);
|
||||
} else {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: String(err),
|
||||
});
|
||||
}
|
||||
throw err;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
},
|
||||
);
|
||||
if (result instanceof Response) {
|
||||
return result;
|
||||
}
|
||||
|
||||
+10
-10
@@ -11,6 +11,7 @@ export interface RouteResult<T> {
|
||||
handlers: T[][];
|
||||
methodMatch: boolean;
|
||||
patternMatch: boolean;
|
||||
pattern: string | null;
|
||||
}
|
||||
|
||||
export interface Router<T> {
|
||||
@@ -28,7 +29,7 @@ export interface Router<T> {
|
||||
export const IS_PATTERN = /[*:{}+?()]/;
|
||||
|
||||
export function mergePaths(a: string, b: string) {
|
||||
if (a === "" || a === "/" || a === "*") return b;
|
||||
if (a === "" || a === "/" || a === "/*") return b;
|
||||
if (b === "/") return a;
|
||||
if (a.endsWith("/")) {
|
||||
return a.slice(0, -1) + b;
|
||||
@@ -48,7 +49,7 @@ export class UrlPatternRouter<T> implements Router<T> {
|
||||
|
||||
add(method: Method | "ALL", pathname: string | URLPattern, handlers: T[]) {
|
||||
if (
|
||||
typeof pathname === "string" && pathname !== "*" &&
|
||||
typeof pathname === "string" && pathname !== "/*" &&
|
||||
IS_PATTERN.test(pathname)
|
||||
) {
|
||||
this._routes.push({
|
||||
@@ -71,6 +72,7 @@ export class UrlPatternRouter<T> implements Router<T> {
|
||||
handlers: [],
|
||||
methodMatch: false,
|
||||
patternMatch: false,
|
||||
pattern: null,
|
||||
};
|
||||
|
||||
if (this._middlewares.length > 0) {
|
||||
@@ -84,16 +86,15 @@ export class UrlPatternRouter<T> implements Router<T> {
|
||||
// to be either wildcard `*` match or an exact pathname match.
|
||||
if (
|
||||
typeof route.path === "string" &&
|
||||
(route.path === "*" || route.path === url.pathname)
|
||||
(route.path === "/*" || route.path === url.pathname)
|
||||
) {
|
||||
if (route.method !== "ALL") {
|
||||
result.patternMatch = true;
|
||||
}
|
||||
if (route.method !== "ALL") result.patternMatch = true;
|
||||
result.pattern = route.path;
|
||||
|
||||
if (route.method === "ALL" || route.method === method) {
|
||||
result.handlers.push(route.handlers);
|
||||
|
||||
if (route.path === "*" && route.method === "ALL") {
|
||||
if (route.path === "/*" && route.method === "ALL") {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -104,9 +105,8 @@ export class UrlPatternRouter<T> implements Router<T> {
|
||||
} else if (route.path instanceof URLPattern) {
|
||||
const match = route.path.exec(url);
|
||||
if (match !== null) {
|
||||
if (route.method !== "ALL") {
|
||||
result.patternMatch = true;
|
||||
}
|
||||
if (route.method !== "ALL") result.patternMatch = true;
|
||||
result.pattern = route.path.pathname;
|
||||
|
||||
if (route.method === "ALL" || route.method === method) {
|
||||
result.handlers.push(route.handlers);
|
||||
|
||||
+10
-3
@@ -30,6 +30,7 @@ Deno.test("UrlPatternRouter - GET get first match", () => {
|
||||
params: {},
|
||||
handlers: [[A]],
|
||||
methodMatch: true,
|
||||
pattern: "/",
|
||||
patternMatch: true,
|
||||
});
|
||||
});
|
||||
@@ -39,8 +40,8 @@ Deno.test("UrlPatternRouter - GET get matches with middlewares", () => {
|
||||
const A = () => {};
|
||||
const B = () => {};
|
||||
const C = () => {};
|
||||
router.add("ALL", "*", [A]);
|
||||
router.add("ALL", "*", [B]);
|
||||
router.add("ALL", "/*", [A]);
|
||||
router.add("ALL", "/*", [B]);
|
||||
router.add("GET", "/", [C]);
|
||||
|
||||
const res = router.match("GET", new URL("/", "http://localhost"));
|
||||
@@ -48,6 +49,7 @@ Deno.test("UrlPatternRouter - GET get matches with middlewares", () => {
|
||||
params: {},
|
||||
handlers: [[A], [B], [C]],
|
||||
methodMatch: true,
|
||||
pattern: "/",
|
||||
patternMatch: true,
|
||||
});
|
||||
});
|
||||
@@ -62,6 +64,7 @@ Deno.test("UrlPatternRouter - GET extract params", () => {
|
||||
params: { foo: "a", bar: "b" },
|
||||
handlers: [[A]],
|
||||
methodMatch: true,
|
||||
pattern: "/:foo/:bar/c",
|
||||
patternMatch: true,
|
||||
});
|
||||
|
||||
@@ -71,6 +74,7 @@ Deno.test("UrlPatternRouter - GET extract params", () => {
|
||||
params: { foo: "a a", bar: "b" },
|
||||
handlers: [[A]],
|
||||
methodMatch: true,
|
||||
pattern: "/:foo/:bar/c",
|
||||
patternMatch: true,
|
||||
});
|
||||
});
|
||||
@@ -85,6 +89,7 @@ Deno.test("UrlPatternRouter - Wrong method match", () => {
|
||||
params: {},
|
||||
handlers: [],
|
||||
methodMatch: false,
|
||||
pattern: "/foo",
|
||||
patternMatch: true,
|
||||
});
|
||||
});
|
||||
@@ -101,6 +106,7 @@ Deno.test("UrlPatternRouter - wrong + correct method", () => {
|
||||
params: {},
|
||||
handlers: [[B]],
|
||||
methodMatch: true,
|
||||
pattern: "/foo",
|
||||
patternMatch: true,
|
||||
});
|
||||
});
|
||||
@@ -117,6 +123,7 @@ Deno.test("UrlPatternRouter - convert patterns automatically", () => {
|
||||
},
|
||||
handlers: [[A]],
|
||||
methodMatch: true,
|
||||
pattern: "/books/:id",
|
||||
patternMatch: true,
|
||||
});
|
||||
});
|
||||
@@ -173,7 +180,7 @@ Deno.test("pathToPattern", async (t) => {
|
||||
Deno.test("mergePaths", () => {
|
||||
expect(mergePaths("", "")).toEqual("");
|
||||
expect(mergePaths("/", "/foo")).toEqual("/foo");
|
||||
expect(mergePaths("*", "/foo")).toEqual("/foo");
|
||||
expect(mergePaths("/*", "/foo")).toEqual("/foo");
|
||||
expect(mergePaths("/foo/bar", "/baz")).toEqual("/foo/bar/baz");
|
||||
expect(mergePaths("/foo/bar/", "/baz")).toEqual("/foo/bar/baz");
|
||||
expect(mergePaths("/foo/bar", "baz")).toEqual("/foo/bar/baz");
|
||||
|
||||
@@ -8,8 +8,7 @@ async function getLatestVersion() {
|
||||
return Deno.env.get("LATEST_VERSION") ?? "99.99.999";
|
||||
}
|
||||
|
||||
// deno-lint-ignore require-await
|
||||
async function getCurrentVersion() {
|
||||
function getCurrentVersion() {
|
||||
return Deno.env.get("CURRENT_VERSION")!;
|
||||
}
|
||||
|
||||
|
||||
@@ -1437,6 +1437,7 @@ Deno.test({
|
||||
|
||||
Deno.test({
|
||||
name: "partials - opt out of partial navigation",
|
||||
ignore: true, // TODO: test is flaky
|
||||
fn: async () => {
|
||||
const app = testApp()
|
||||
.get("/partial", (ctx) => {
|
||||
@@ -1504,6 +1505,7 @@ Deno.test({
|
||||
|
||||
Deno.test({
|
||||
name: "partials - opt out of partial navigation #2",
|
||||
ignore: true, // TODO: test is flaky
|
||||
fn: async () => {
|
||||
const app = testApp()
|
||||
.get("/partial", (ctx) => {
|
||||
@@ -2599,7 +2601,7 @@ Deno.test({
|
||||
</Doc>,
|
||||
);
|
||||
})
|
||||
.get("*", (ctx) => {
|
||||
.get("/*", (ctx) => {
|
||||
return ctx.render(
|
||||
<Doc>
|
||||
<Partial name="foo">
|
||||
|
||||
@@ -43,7 +43,6 @@ export function PartialsSection() {
|
||||
<div class="flex flex-col gap-4 md:sticky md:top-4">
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
alt="Arrows transferring data down "
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="icon icon-tabler icon-tabler-arrows-transfer-down text-fresh"
|
||||
width="4rem"
|
||||
@@ -55,6 +54,7 @@ export function PartialsSection() {
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<title>Arrows transferring data down</title>
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||
<path d="M17 3v6" />
|
||||
<path d="M10 18l-3 3l-3 -3" />
|
||||
|
||||
@@ -31,8 +31,8 @@ export function RenderingSection() {
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
role="img"
|
||||
alt="Preact icon"
|
||||
>
|
||||
<title>Preact icon</title>
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||
<path d="M12 12v.01" />
|
||||
<path d="M19.071 4.929c-1.562 -1.562 -6 .337 -9.9 4.243c-3.905 3.905 -5.804 8.337 -4.242 9.9c1.562 1.561 6 -.338 9.9 -4.244c3.905 -3.905 5.804 -8.337 4.242 -9.9" />
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
"@std/media-types": "jsr:@std/media-types@1",
|
||||
"@std/path": "jsr:@std/path@1",
|
||||
"@std/semver": "jsr:@std/semver@1",
|
||||
"@opentelemetry/api": "npm:@opentelemetry/api@^1.9.0",
|
||||
"autoprefixer": "npm:autoprefixer@10.4.17",
|
||||
"cssnano": "npm:cssnano@6.0.3",
|
||||
"esbuild": "npm:esbuild@0.23.1",
|
||||
|
||||
@@ -103,8 +103,8 @@ function LemonDrop() {
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
role="img"
|
||||
class="mt-8"
|
||||
alt="Fresh logo"
|
||||
>
|
||||
<title>Fresh logo</title>
|
||||
<circle cx="18" cy={dropY.value} r="4" fill="white"></circle>
|
||||
<path
|
||||
d="M11.9 96.3v24H7v-24h4.9Zm7.5 10.2v4h-8.8v-4h8.8Zm1-10.2v4h-9.8v-4h9.8ZM23.2 96.3H31c1.6 0 3 .3 4.1.9 1.1.5 2 1.3 2.6 2.4a8 8 0 0 1 1 4c0 1.3-.2 2.4-.6 3.3-.3 1-.8 1.7-1.5 2.3-.7.6-1.4 1-2.3 1.5l-1.5.8h-6.3v-4h4.3a3 3 0 0 0 1.7-.4c.4-.3.7-.7 1-1.2a5 5 0 0 0 .3-2c0-.7-.1-1.3-.3-1.9-.2-.5-.5-1-1-1.2-.3-.3-.9-.5-1.5-.5h-3v20h-4.8v-24Zm11 24-4.4-10.7h5l4.6 10.5v.2h-5.2ZM55.9 116.3v4H45.4v-4h10.5Zm-9-20v24H42v-24H47Zm7.6 9.8v3.8h-9.1v-3.8h9Zm1.4-9.8v4H45.4v-4h10.5ZM69 114c0-.4 0-.8-.2-1.1 0-.4-.2-.7-.5-1l-1-1-1.9-.8-2.6-1.2-2.2-1.5a6.5 6.5 0 0 1-1.7-2 6 6 0 0 1-.5-2.7c0-1 .1-2 .5-2.7a6 6 0 0 1 1.6-2.2c.7-.5 1.5-1 2.4-1.3a9.5 9.5 0 0 1 7.1.5c1.2.6 2 1.5 2.7 2.6.6 1 1 2.4 1 3.8h-5a5 5 0 0 0-.2-1.8c-.2-.5-.5-1-1-1.2-.4-.3-1-.5-1.6-.5-.6 0-1.1.2-1.5.4-.4.2-.7.6-1 1l-.2 1.4c0 .4.1.8.3 1.1l.8.8a21.3 21.3 0 0 0 2.8 1.4l2.9 1.4a9 9 0 0 1 2 1.8c.7.6 1 1.3 1.4 2a7.9 7.9 0 0 1-.1 5.5c-.4.8-.9 1.5-1.5 2.1a7 7 0 0 1-2.5 1.4c-2 .5-1 1.8-3 1.8s-1.3-1.5-3.2-1.8c-1-.3-2-.8-2.7-1.4a6.7 6.7 0 0 1-1.8-2.5c-.4-1-.6-2.2-.6-3.5h4.9c0 .7 0 1.3.2 1.8.1.5.3 1 .6 1.3.3.2.7.5 1.1.6.5.2 1 .2 1.5.2.7 0 1.2 0 1.6-.3.4-.3.6-.6.8-1 .2-.4.3-.9.3-1.4ZM90.5 106v4h-10v-4h10Zm-8.6-9.7v24h-4.8v-24h4.8Zm12.1 0v24h-4.8v-24H94Z"
|
||||
|
||||
@@ -96,9 +96,9 @@ function LemonTop() {
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
role="img"
|
||||
class="mt-8 w-full h-auto max-w-32 lg:max-w-36"
|
||||
alt="Fresh logo"
|
||||
id="lemon-top"
|
||||
>
|
||||
<title>Fresh logo</title>
|
||||
<circle cx="18" cy={dropY.value} r="4" fill="#fff"></circle>
|
||||
<path
|
||||
d="M11.9 96.3v24H7v-24h4.9Zm7.5 10.2v4h-8.8v-4h8.8Zm1-10.2v4h-9.8v-4h9.8ZM23.2 96.3H31c1.6 0 3 .3 4.1.9 1.1.5 2 1.3 2.6 2.4a8 8 0 0 1 1 4c0 1.3-.2 2.4-.6 3.3-.3 1-.8 1.7-1.5 2.3-.7.6-1.4 1-2.3 1.5l-1.5.8h-6.3v-4h4.3a3 3 0 0 0 1.7-.4c.4-.3.7-.7 1-1.2a5 5 0 0 0 .3-2c0-.7-.1-1.3-.3-1.9-.2-.5-.5-1-1-1.2-.3-.3-.9-.5-1.5-.5h-3v20h-4.8v-24Zm11 24-4.4-10.7h5l4.6 10.5v.2h-5.2ZM55.9 116.3v4H45.4v-4h10.5Zm-9-20v24H42v-24H47Zm7.6 9.8v3.8h-9.1v-3.8h9Zm1.4-9.8v4H45.4v-4h10.5ZM69 114c0-.4 0-.8-.2-1.1 0-.4-.2-.7-.5-1l-1-1-1.9-.8-2.6-1.2-2.2-1.5a6.5 6.5 0 0 1-1.7-2 6 6 0 0 1-.5-2.7c0-1 .1-2 .5-2.7a6 6 0 0 1 1.6-2.2c.7-.5 1.5-1 2.4-1.3a9.5 9.5 0 0 1 7.1.5c1.2.6 2 1.5 2.7 2.6.6 1 1 2.4 1 3.8h-5a5 5 0 0 0-.2-1.8c-.2-.5-.5-1-1-1.2-.4-.3-1-.5-1.6-.5-.6 0-1.1.2-1.5.4-.4.2-.7.6-1 1l-.2 1.4c0 .4.1.8.3 1.1l.8.8a21.3 21.3 0 0 0 2.8 1.4l2.9 1.4a9 9 0 0 1 2 1.8c.7.6 1 1.3 1.4 2a7.9 7.9 0 0 1-.1 5.5c-.4.8-.9 1.5-1.5 2.1a7 7 0 0 1-2.5 1.4c-2 .5-1 1.8-3 1.8s-1.3-1.5-3.2-1.8c-1-.3-2-.8-2.7-1.4a6.7 6.7 0 0 1-1.8-2.5c-.4-1-.6-2.2-.6-3.5h4.9c0 .7 0 1.3.2 1.8.1.5.3 1 .6 1.3.3.2.7.5 1.1.6.5.2 1 .2 1.5.2.7 0 1.2 0 1.6-.3.4-.3.6-.6.8-1 .2-.4.3-.9.3-1.4ZM90.5 106v4h-10v-4h10Zm-8.6-9.7v24h-4.8v-24h4.8Zm12.1 0v24h-4.8v-24H94Z"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import "./telemetry.ts";
|
||||
import { App, fsRoutes, staticFiles, trailingSlashes } from "fresh";
|
||||
|
||||
export const app = new App({ root: import.meta.url })
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ export default define.page(function App({ Component, state, url }) {
|
||||
href={asset("/fonts/FixelVariable.woff2")}
|
||||
as="font"
|
||||
type="font/woff2"
|
||||
crossorigin="true"
|
||||
crossorigin="anonymous"
|
||||
/>
|
||||
<link rel="stylesheet" href={asset("/styles.css")} />
|
||||
{url.pathname === "/"
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import { register } from "jsr:@deno/otel";
|
||||
|
||||
if (Deno.telemetry) register();
|
||||
Reference in New Issue
Block a user