This plugin enables you add more granular tracing spans in your Google Cloud traces. Without any complex setup it is possible to instrument on a field by field basis and further enables you when integrating Cloud Trace with BigQuery to analyse usage of fields.
Prerequisites:
- Google Cloud Trace Agent
yarn add @google-cloud/trace-agent
- Apollo Server with Koa/Express
By default the trace-agent will instrument the /graphql endpoint
To get started with this plugin:
- Install the plugin
yarn add apollo-server-plugin-cloud-trace
- Integrate the plugin with your Apollo Server
import { apolloGCloudTracePlugin } from 'apollo-server-plugin-cloud-trace';
import * as GTrace from '@google-cloud/trace-agent';
const cloudTrace = GTrace.start({
serviceContext: {
service: 'my-service',
version: '1.0',
},
});
const server = new ApolloServer({
typeDefs,
resolvers,
plugins: [
apolloGCloudTracePlugin({
tracer: cloudTrace,
}),
],
});
$0
PluginOptions$0.tracer
$0.prefix
(optional, default'GQL'
)$0.addFieldValues
(optional, defaultfalse
)$0.addFieldArguments
(optional, defaultfalse
)
tracer
Instance of the GCloud Tracerprefix
Prefix used in the traces for all GraphQL spansaddFieldValues
Configures whether or not the result of field resolvers are added to tracesaddFieldArguments
Configures whether or not parameters of a field resolver are added to traces