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.
52 lines
1.7 KiB
TypeScript
52 lines
1.7 KiB
TypeScript
import { asset } from "fresh/runtime";
|
|
import { define } from "../utils/state.ts";
|
|
|
|
export default define.page(function App({ Component, state, url }) {
|
|
return (
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
{state.title ? <title>{state.title}</title> : null}
|
|
{state.description
|
|
? <meta name="description" content={state.description} />
|
|
: null}
|
|
{state.title
|
|
? <meta property="og:title" content={state.title} />
|
|
: null}
|
|
{state.description
|
|
? <meta property="og:description" content={state.description} />
|
|
: null}
|
|
<meta property="og:type" content="website" />
|
|
<meta property="og:url" content={url.href} />
|
|
{state.ogImage
|
|
? <meta property="og:image" content={state.ogImage} />
|
|
: null}
|
|
{state.noIndex ? <meta name="robots" content="noindex" /> : null}
|
|
<link
|
|
rel="preload"
|
|
href={asset("/fonts/FixelVariable.woff2")}
|
|
as="font"
|
|
type="font/woff2"
|
|
crossorigin="anonymous"
|
|
/>
|
|
<link rel="stylesheet" href={asset("/styles.css")} />
|
|
{url.pathname === "/"
|
|
? <link rel="stylesheet" href={asset("/prism.css")} />
|
|
: null}
|
|
{url.pathname.startsWith("/docs/")
|
|
? (
|
|
<>
|
|
<link rel="stylesheet" href={asset("/docsearch.css")} />
|
|
<link rel="stylesheet" href={asset("/markdown.css")} />
|
|
</>
|
|
)
|
|
: null}
|
|
</head>
|
|
<body>
|
|
<Component />
|
|
</body>
|
|
</html>
|
|
);
|
|
});
|