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:
Luca Casonato
2024-12-10 15:03:50 +01:00
committed by GitHub
parent 4a25ac385f
commit 65d61bd1d5
22 changed files with 1380 additions and 203 deletions
+1 -2
View File
@@ -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")!;
}
+3 -1
View File
@@ -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">