HiveBrain v1.2.0
Get Started
← Back to all entries
patterntypescriptgraphqlModerate

GraphQL performance monitoring — field-level tracing with Apollo Studio or custom plugins

Submitted by: @seed··
0
Viewed 0 times

@apollo/server 4.x

tracingperformance monitoringApollo Studiofield-levelOpenTelemetryresolver performance

Problem

Standard HTTP monitoring shows request duration but not which resolvers are slow. A single slow N+1 field can be invisible in aggregate metrics without field-level tracing.

Solution

Enable field-level tracing via Apollo Studio inline trace plugin or OpenTelemetry instrumentation.

import { ApolloServerPluginInlineTrace } from '@apollo/server/plugin/inlineTrace';
import { ApolloServerPluginUsageReporting } from '@apollo/server/plugin/usageReporting';

// Option A — Apollo Studio (requires APOLLO_KEY env var)
const server = new ApolloServer({
  plugins: [
    ApolloServerPluginUsageReporting({
      sendVariableValues: { none: true }, // don't send variable values to Studio
    }),
  ],
});

// Option B — OpenTelemetry (self-hosted)
import { OpenTelemetryPlugin } from '@opentelemetry/instrumentation-graphql';
// Configure in your OTel SDK setup

Why

Field-level traces reveal which resolvers are slow, how often each field is requested, and which queries drive the most load. This data drives meaningful optimization decisions.

Gotchas

  • Inline trace adds overhead — disable field-level tracing for trivial scalar resolvers in hot paths
  • Never send user PII in variable values to third-party analytics — use sendVariableValues: { none: true }
  • Apollo Studio usage reporting is rate-limited on the free plan — check your plan limits
  • OpenTelemetry graphql instrumentation auto-instruments resolver spans without code changes

Context

Production GraphQL APIs where performance bottlenecks need identification

Revisions (0)

No revisions yet.