Skip to content

Commit

Permalink
chore(release): update monorepo packages versions (#2333)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
theguild-bot and github-actions[bot] authored Nov 26, 2024
1 parent 443fc15 commit 40889ca
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 97 deletions.
96 changes: 0 additions & 96 deletions .changeset/cold-seals-play.md

This file was deleted.

99 changes: 99 additions & 0 deletions packages/plugins/prometheus/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,104 @@
# @envelop/prometheus

## 11.1.0

### Minor Changes

- [#2326](https://github.com/n1ru4l/envelop/pull/2326)
[`443fc15`](https://github.com/n1ru4l/envelop/commit/443fc150184b40357d064c900de4105f14164c37)
Thanks [@EmrysMyrddin](https://github.com/EmrysMyrddin)! - Allow to explicitly control which
events and timing should be observe.

Each metric can now be configured to observe events and timings only for certain GraphQL pipeline
phases, or depending on the request context.

## Example: trace only execution and subscription errors

```ts
import { execute, parse, specifiedRules, subscribe, validate } from 'graphql'
import { envelop, useEngine } from '@envelop/core'
import { usePrometheus } from '@envelop/prometheus'

const TRACKED_OPERATION_NAMES = [
// make a list of operation that you want to monitor
]

const getEnveloped = envelop({
plugins: [
useEngine({ parse, validate, specifiedRules, execute, subscribe }),
usePrometheus({
metrics: {
// Here, an array of phases can be provided to enable the metric only on certain phases.
// In this example, only error happening during the execute and subscribe phases will tracked
graphql_envelop_phase_error: ['execute', 'subscribe']
}
})
]
})
```

## Example: Monitor timing only of a set of operations by name

```ts
import { execute, parse, specifiedRules, subscribe, validate } from 'graphql'
import { envelop, useEngine } from '@envelop/core'
import { usePrometheus } from '@envelop/prometheus'

const TRACKED_OPERATION_NAMES = [
// make a list of operation that you want to monitor
]

const getEnveloped = envelop({
plugins: [
useEngine({ parse, validate, specifiedRules, execute, subscribe }),
usePrometheus({
metrics: {
graphql_yoga_http_duration: createHistogram({
registry,
histogram: {
name: 'graphql_envelop_request_duration',
help: 'Time spent on HTTP connection',
labelNames: ['operationName']
},
fillLabelsFn: ({ operationName }, _rawContext) => ({ operationName }),
phases: ['execute', 'subscribe'],

// Here `shouldObserve` control if the request timing should be observed, based on context
shouldObserve: ({ operationName }) => TRACKED_OPERATIONS.includes(operationName)
})
}
})
]
})
```

## Default Behavior Change

A metric is enabled using `true` value in metrics options will observe in every phases available.

Previously, which phase was observe was depending on which other metric were enabled. For example,
this config would only trace validation error:

```ts
usePrometheus({
metrics: {
graphql_envelop_phase_error: true,
graphql_envelop_phase_validate: true
}
})
```

This is no longer the case. If you were relying on this behavior, please use an array of string to
restrict observed phases.

```ts
usePrometheus({
metrics: {
graphql_envelop_phase_error: ['validate']
}
})
```

## 11.0.0

### Major Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/prometheus/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@envelop/prometheus",
"version": "11.0.0",
"version": "11.1.0",
"type": "module",
"repository": {
"type": "git",
Expand Down

0 comments on commit 40889ca

Please sign in to comment.