Skip to content

Commit

Permalink
feat(instrumentation-grpc): monitor error events with events.errorMon…
Browse files Browse the repository at this point in the history
…itor

Related: open-telemetry#225
  • Loading branch information
cjihrig committed Jan 24, 2025
1 parent f927e82 commit ab7dd28
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ All notable changes to experimental packages in this project will be documented

* feat(instrumentation): re-export initialize function from import-in-the-middle [#5123](https://github.com/open-telemetry/opentelemetry-js/pull/5123)
* feat(sdk-node): lower diagnostic level [#5360](https://github.com/open-telemetry/opentelemetry-js/pull/5360) @cjihrig
* feat(instrumentation-grpc): monitor error events with events.errorMonitor [#5369](https://github.com/open-telemetry/opentelemetry-js/pull/5369) @cjihrig

### :bug: (Bug Fix)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
* error event should be processed.
*/

import { errorMonitor } from 'node:events';

import type {
ClientReadableStream,
handleBidiStreamingCall,
Expand Down Expand Up @@ -86,7 +88,7 @@ function serverStreamAndBidiHandler<RequestType, ResponseType>(
endSpan();
});

call.on('error', (err: ServiceError) => {
call.on(errorMonitor, (err: ServiceError) => {
if (call[CALL_SPAN_ENDED]) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ export const runTests = (
bidiStream.write(element);
});

assert.strictEqual(bidiStream.listenerCount('error'), 0);
bidiStream.on('error', (err: ServiceError) => {
reject(err);
});
Expand Down

0 comments on commit ab7dd28

Please sign in to comment.