March 05, 2025
@whatwg-node/promise-helpers@1.2.3
Patch Changes
- #2068
516bf60
Thanks @EmrysMyrddin! - Fix return type of the callback of
iterateAsync. The callback can actually returnnullorundefined, the implementation is
already handling this case.
@whatwg-node/server@0.10.0
Minor Changes
-
#2068
516bf60
Thanks @EmrysMyrddin! - Add new Instruments APIIntroduction of a new API allowing to instrument the graphql pipeline.
This new API differs from already existing Hooks by not having access to input/output of phases.
The goal ofInstrumentsis to run allow running code before, after or around the whole process
of a phase, including plugins hooks executions.The main use case of this new API is observability (monitoring, tracing, etc...).
Basic usage
import Sentry from '@sentry/node' import { createServerAdapter } from '@whatwg-node/server' const server = createServerAdapter( (req, res) => { //... }, { plugins: [ { instruments: { request: ({ request }, wrapped) => Sentry.startSpan({ name: 'Graphql Operation' }, async () => { try { await wrapped() } catch (err) { Sentry.captureException(err) } }) } } ] } )
Multiple instruments plugins
It is possible to have multiple instruments plugins (Prometheus and Sentry for example), they will
be automatically composed by envelop in the same order than the plugin array (first is outermost,
last is inner most).import { createServerAdapter } from '@whatwg-node/server' const server = createServerAdapter( (req, res) => { //... }, { plugins: [useSentry(), useOpentelemetry()] } )
sequenceDiagram Sentry->>Opentelemetry: ; Opentelemetry->>Server Adapter: ; Server Adapter->>Opentelemetry: ; Opentelemetry->>Sentry: ;
Custom instruments ordering
If the default composition ordering doesn't suite your need, you can manually compose instruments.
This allows to have a different execution order of hooks and instruments.import { composeInstruments, createServerAdapter } from '@whatwg-node/server' const { instruments: sentryInstruments, ...sentryPlugin } = useSentry() const { instruments: otelInstruments, ...otelPlugin } = useOpentelemetry() const instruments = composeInstruments([otelInstruments, sentryInstruments]) const server = createServerAdapter( (req, res) => { //... }, { plugins: [{ instruments }, sentryPlugin, otelPlugin] } )
sequenceDiagram Opentelemetry->>Sentry: ; Sentry->>Server Adapter: ; Server Adapter->>Sentry: ; Sentry->>Opentelemetry: ;
Patch Changes
- #2068
516bf60
Thanks @EmrysMyrddin! - dependencies updates:- Updated dependency
@whatwg-node/promise-helpers@^1.2.2↗︎
(from^1.0.0, independencies) - Added dependency
@envelop/instruments@1.0.0↗︎
(todependencies)
- Updated dependency
- Updated dependencies
[516bf60]:- @whatwg-node/promise-helpers@1.2.3