Skip to content

Commit

Permalink
feat: add open telemetry instrumentation (#2786)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lucacasonato authored Dec 10, 2024
1 parent 4a25ac3 commit 65d61bd
Show file tree
Hide file tree
Showing 22 changed files with 1,379 additions and 202 deletions.
10 changes: 6 additions & 4 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:[email protected]",
"esbuild-wasm": "npm:[email protected]",
"@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",
Expand All @@ -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"]
Expand Down
Loading

0 comments on commit 65d61bd

Please sign in to comment.