# apollo-server-plugin-cloud-trace

> Plugin to integrate Google Cloud Trace with Apollo Server

Latest version **0.0.3** (published 2020-06-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install apollo-server-plugin-cloud-trace
pnpm add apollo-server-plugin-cloud-trace
yarn add apollo-server-plugin-cloud-trace
bun add apollo-server-plugin-cloud-trace
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2020-06-15 |
| First published | 2020-06-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 6.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Maintainers | cjanietz |

## Links

- npm: https://www.npmjs.com/package/apollo-server-plugin-cloud-trace
- Repository: https://github.com/cjanietz/apollo-server-plugin-cloud-trace
- npm.io page: https://npm.io/package/apollo-server-plugin-cloud-trace

## Dependencies (2)

- [lodash.isobjectlike](https://npm.io/package/lodash.isobjectlike.md) ^4.0.0
- [apollo-server-plugin-base](https://npm.io/package/apollo-server-plugin-base.md) ^0.9.0

## Recent versions

- 0.0.3 (latest) — 2020-06-15
- 0.0.2 — 2020-06-15
- 0.0.1 — 2020-06-14

## README

# apollo-server-plugin-cloud-trace

## Description

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.

## Getting started

Prerequisites:

-   Google Cloud Trace Agent

```shell script
yarn add @google-cloud/trace-agent
```

-   Apollo Server with Koa/Express<br>
    By default the trace-agent will instrument the /graphql endpoint

To get started with this plugin:

-   Install the plugin

```shell script
yarn add apollo-server-plugin-cloud-trace
```

-   Integrate the plugin with your Apollo Server

```js
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,
        }),
    ],
});
```

## Configuration

-   `$0` **PluginOptions**
    -   `$0.tracer`
    -   `$0.prefix` (optional, default `'GQL'`)
    -   `$0.addFieldValues` (optional, default `false`)
    -   `$0.addFieldArguments` (optional, default `false`)
-   `tracer` Instance of the GCloud Tracer
-   `prefix` Prefix used in the traces for all GraphQL spans
-   `addFieldValues` Configures whether or not the result of field resolvers are added to traces
-   `addFieldArguments` Configures whether or not parameters of a field resolver are added to traces

---
_Source: https://npm.io/package/apollo-server-plugin-cloud-trace · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
