Skip to content

Commit

Permalink
[prometheus] fix documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
EmrysMyrddin committed Sep 5, 2024
1 parent d644d85 commit c197edd
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions website/src/pages/docs/features/monitoring.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ npm i prom-client @graphql-yoga/plugin-prometheus
You can then add the plugin to your GraphQL server:

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

const getEnveloped = envelop({
const yoga = createYoga({
plugins: [
useEngine({ parse, validate, specifiedRules, execute, subscribe }),
// ... other plugins ...
schema: mySchema, // Provide your GraphQL schema
usePrometheus({
endpoint: '/metrics', // optional, default is `/metrics`, you can disable it by setting it to `false` if registry is configured in "push" mode
// Optional, see default values below
Expand All @@ -58,6 +56,11 @@ const getEnveloped = envelop({
})
]
})

const server = createServer(yoga)
server.listen(4000, () => {
console.log(`Server is running on http://localhost:4000/${server.graphqlEndpoint}`)
})
```

<Callout type="warning">
Expand Down

0 comments on commit c197edd

Please sign in to comment.