Skip to content

Commit

Permalink
Fix uncaught "resource closed" in http server instrumentation (#3)
Browse files Browse the repository at this point in the history
* Try fixing uncaught 'resource closed'

* Log another potential error site

* Revert "Log another potential error site"

This reverts commit 2d352f5.

* Improve how we report response stream errors

* Add --allow-sys to bundle-opentelemetry.ts

* Use specific versions of the bundle toolchain

* does this help?

* how about that

* why am i struggling with submodules
  • Loading branch information
danopia authored May 11, 2024
1 parent 2a3d69f commit 49ca25d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 6 additions & 6 deletions hack/bundle-opentelemetry.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env -S deno run --allow-run --allow-read --allow-write=. --allow-env
#!/usr/bin/env -S deno run --allow-run --allow-read --allow-write=. --allow-env --allow-sys --allow-ffi

// pass --refresh-yarn to force rerunning yarn on the opentelemetry packages

import { rollup, Plugin } from 'npm:rollup';
import { nodeResolve } from 'npm:@rollup/plugin-node-resolve';
import commonjs from 'npm:@rollup/plugin-commonjs';
import sourcemaps from 'npm:rollup-plugin-sourcemaps';
import cleanup from 'npm:rollup-plugin-cleanup';
import { rollup, Plugin } from 'npm:rollup@4.17.2';
import { nodeResolve } from 'npm:@rollup/plugin-node-resolve@15.2.3';
import commonjs from 'npm:@rollup/plugin-commonjs@25.0.7';
import sourcemaps from 'npm:rollup-plugin-sourcemaps@0.6.3';
import cleanup from 'npm:rollup-plugin-cleanup@3.2.1';
import dts from 'npm:[email protected]';
// import { terser } from "npm:rollup-plugin-terser";

Expand Down
3 changes: 3 additions & 0 deletions instrumentation/http-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ export function httpTracer(inner: Deno.ServeHandler, opts?: {
const respSnoop = snoopStream(resp.body);
respSnoop.finalSize.then(size => {
serverSpan.setAttribute(SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED, size);
}).catch(err => {
// NOTE: err can be "resource closed" when the client walks away mid-response.
serverSpan.recordException(err);
}).finally(() => {
inflightMetric.add(-1, reqMetricAttrs);
serverSpan.end();
Expand Down

0 comments on commit 49ca25d

Please sign in to comment.