March 04, 2025
@envelop/core@5.2.0
Minor Changes
-
#2430
a107c89
Thanks @EmrysMyrddin! - ## NewInstruments
APIIntroducation of a new API allowing to instrument the graphql pipeline.
This new API differs from already existing Hooks by not having access to intup/output of phases.
The goal ofInstruments
is to run allow running code before, after or araound the whole
process of a phase, incuding plugins hooks executions.The main use case of this new API is observability (monitoring, tracing, etc...).
Basic usage
import { envelop } from '@envelop/core' import Sentry from '@sentry/node' const getEnveloped = envelop({ plugins: [ { instruments: { execute: ({ context }, wrapped) => Sentry.startSpan({ name: 'Graphql Operation' }, async () => { try { await wrapped() } catch (err) { Sentry.captureException(err) } }) } } ] })
Mutliple instruments plugins
It is possilbe 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 outtermost,
last is inner most).import { useOpentelemetry } from '@envelop/opentelemetry' import { useSentry } from '@envelop/sentry' const getEnveloped = envelop({ plugins: [useSentry(), useOpentelemetry()] })
sequenceDiagram Sentry->>Opentelemetry: ; Opentelemetry->>Envelop: ; Envelop->>Opentelemetry: ; Opentelemetry->>Sentry: ;
Custom instruments ordering
If the default composition ordering doesn't suite your need, you can mannually compose
instruments. This allows to have a different execution order of hooks and instruments.import { useOpentelemetry } from '@envelop/opentelemetry' import { composeInstruments, useSentry } from '@envelop/sentry' const { instruments: sentryInstruments, ...sentryPlugin } = useSentry() const { instruments: otelInstruments, ...otelPlugin } = useOpentelemetry() const instruments = composeInstruments([otelInstruments, sentryInstruments]) const getEnveloped = envelop({ plugins: [{ instruments }, sentryPlugin, otelPlugin] })
sequenceDiagram Opentelemetry->>Sentry: ; Sentry->>Envelop: ; Envelop->>Sentry: ; Sentry->>Opentelemetry: ;
Patch Changes
- #2430
a107c89
Thanks @EmrysMyrddin! - dependencies updates:- Added dependency
@envelop/instruments@workspace:^
↗︎
(todependencies
)
- Added dependency
- Updated dependencies
[a107c89
]:- @envelop/types@5.2.0
@envelop/apollo-datasources@5.1.0
Patch Changes
@envelop/apollo-federation@6.1.0
Patch Changes
@envelop/apollo-server-errors@7.1.0
Patch Changes
@envelop/apollo-tracing@7.1.0
Patch Changes
- Updated dependencies
[a107c89
,
a107c89
]:- @envelop/core@5.2.0
- @envelop/types@5.2.0
- @envelop/on-resolve@5.1.0
@envelop/auth0@7.1.0
Patch Changes
@envelop/dataloader@7.1.0
Patch Changes
@envelop/depth-limit@5.1.0
Patch Changes
@envelop/disable-introspection@7.1.0
Patch Changes
@envelop/execute-subscription-event@6.1.0
Patch Changes
@envelop/extended-validation@5.1.0
Patch Changes
@envelop/filter-operation-type@7.1.0
Patch Changes
@envelop/fragment-arguments@7.1.0
Patch Changes
@envelop/generic-auth@9.1.0
Patch Changes
@envelop/graphql-jit@9.1.0
Patch Changes
@envelop/graphql-middleware@7.1.0
Patch Changes
@envelop/graphql-modules@7.1.0
Patch Changes
@envelop/immediate-introspection@5.1.0
Patch Changes
@envelop/live-query@8.1.0
Patch Changes
@envelop/newrelic@8.1.0
Patch Changes
@envelop/on-resolve@5.1.0
Patch Changes
@envelop/opentelemetry@7.1.0
Patch Changes
@envelop/operation-field-permissions@7.1.0
Patch Changes
@envelop/parser-cache@8.1.0
Patch Changes
@envelop/persisted-operations@8.1.0
Patch Changes
@envelop/preload-assets@7.1.0
Patch Changes
@envelop/prometheus@12.1.0
Patch Changes
@envelop/rate-limiter@7.1.0
Patch Changes
@envelop/resource-limitations@6.1.0
Patch Changes
@envelop/response-cache@7.1.0
Patch Changes
@envelop/response-cache-cloudflare-kv@3.1.0
Patch Changes
- Updated dependencies []:
- @envelop/response-cache@7.1.0
@envelop/response-cache-redis@4.2.0
Patch Changes
- Updated dependencies []:
- @envelop/response-cache@7.1.0
@envelop/sentry@13.1.0
Patch Changes
@envelop/statsd@6.1.0
Patch Changes
@envelop/validation-cache@8.1.0
Patch Changes
@envelop/testing@8.1.0
Patch Changes
@envelop/types@5.2.0
Minor Changes
-
#2430
a107c89
Thanks @EmrysMyrddin! - ## NewInstruments
APIIntroducation of a new API allowing to instrument the graphql pipeline.
This new API differs from already existing Hooks by not having access to intup/output of phases.
The goal ofInstruments
is to run allow running code before, after or araound the whole
process of a phase, incuding plugins hooks executions.The main use case of this new API is observability (monitoring, tracing, etc...).
Basic usage
import { envelop } from '@envelop/core' import Sentry from '@sentry/node' const getEnveloped = envelop({ plugins: [ { instruments: { execute: ({ context }, wrapped) => Sentry.startSpan({ name: 'Graphql Operation' }, async () => { try { await wrapped() } catch (err) { Sentry.captureException(err) } }) } } ] })
Mutliple instruments plugins
It is possilbe 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 outtermost,
last is inner most).import { useOpentelemetry } from '@envelop/opentelemetry' import { useSentry } from '@envelop/sentry' const getEnveloped = envelop({ plugins: [useSentry(), useOpentelemetry()] })
sequenceDiagram Sentry->>Opentelemetry: ; Opentelemetry->>Envelop: ; Envelop->>Opentelemetry: ; Opentelemetry->>Sentry: ;
Custom instruments ordering
If the default composition ordering doesn't suite your need, you can mannually compose
instruments. This allows to have a different execution order of hooks and instruments.import { useOpentelemetry } from '@envelop/opentelemetry' import { composeInstruments, useSentry } from '@envelop/sentry' const { instruments: sentryInstruments, ...sentryPlugin } = useSentry() const { instruments: otelInstruments, ...otelPlugin } = useOpentelemetry() const instruments = composeInstruments([otelInstruments, sentryInstruments]) const getEnveloped = envelop({ plugins: [{ instruments }, sentryPlugin, otelPlugin] })
sequenceDiagram Opentelemetry->>Sentry: ; Sentry->>Envelop: ; Envelop->>Sentry: ; Sentry->>Opentelemetry: ;