Apollo Server
v4GraphQL query observability via an Apollo Server plugin.
Wraps every GraphQL request with timing, error tracking, and shipping. Each operation maps to a log entry in the dashboard.
Each GraphQL operation is logged as a separate entry. Introspection queries can be skipped via skipRoutes.
Install
bash
npm install auto-api-observeQuick Start
The minimal setup — import, configure, and you're observing.
apollo-quick-start.js
import { ApolloServer } from '@apollo/server';
import { apolloObservabilityPlugin } from 'auto-api-observe';
const server = new ApolloServer({
typeDefs,
resolvers,
plugins: [
apolloObservabilityPlugin({ apiKey: process.env.APILENS_KEY }),
],
});Full Example
All available options with custom fields and real-world usage.
apollo-full.js
import { ApolloServer } from '@apollo/server';
import { startStandaloneServer } from '@apollo/server/standalone';
import { apolloObservabilityPlugin } from 'auto-api-observe';
const server = new ApolloServer({
typeDefs,
resolvers,
plugins: [
apolloObservabilityPlugin({
apiKey: process.env.APILENS_KEY,
slowThreshold: 300,
tags: { service: 'graphql-api' },
}),
],
});
const { url } = await startStandaloneServer(server, { listen: { port: 4000 } });
console.log('Server ready at', url);What's Tracked Automatically
- Operation name mapped to route (e.g. POST /graphql:GetUser)
- Resolver errors tracked as hasErrors flag
- DB calls per query
- Total query execution time
Options Reference
| Option | Type | Default |
|---|---|---|
| apiKey | string | — |
| slowThreshold | number | 1000 |
| tags | Record | {} |
Custom Fields
Attach any business context to the current request via AsyncLocalStorage — scoped per request, works the same on every framework.
const { addField } = require('auto-api-observe');
// In any route handler:
addField('userId', req.user.id);
addField('plan', req.user.plan);
addField('country', req.headers['cf-ipcountry']);
// Sensitive keys are auto-redacted before shipping:
addField('authorization', token); // → "[REDACTED]"
addField('password', pass); // → "[REDACTED]"Ready to observe your Apollo Server app?
Sign up free — get your API key in under 30 seconds. No credit card required.
Get your free API key