{"name":"@opentelemetry/instrumentation-graphql","version":"0.43.0","description":"OpenTelemetry instrumentation for `graphql` gql query language and runtime for GraphQL","main":"build/src/index.js","types":"build/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/open-telemetry/opentelemetry-js-contrib.git"},"scripts":{"clean":"rimraf build/*","compile":"tsc -p .","lint":"eslint . --ext .ts","lint:fix":"eslint . --ext .ts --fix","lint:readme":"node ../../../scripts/lint-readme.js","precompile":"tsc --version && lerna run version:update --scope @opentelemetry/instrumentation-graphql --include-dependencies","prewatch":"npm run precompile","prepublishOnly":"npm run compile","test":"nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'","test-all-versions":"tav","tdd":"npm run test -- --watch-extensions ts --watch","version:update":"node ../../../scripts/version-update.js","watch":"tsc -w"},"keywords":["graphql","metrics","nodejs","opentelemetry","stats","tracing"],"author":{"name":"OpenTelemetry Authors"},"license":"Apache-2.0","engines":{"node":">=14"},"publishConfig":{"access":"public"},"peerDependencies":{"@opentelemetry/api":"^1.3.0"},"devDependencies":{"@opentelemetry/api":"^1.3.0","@opentelemetry/sdk-trace-base":"^1.8.0","@opentelemetry/semantic-conventions":"^1.27.0","@types/mocha":"8.2.3","@types/node":"18.6.5","graphql":"^16.5.0","mocha":"7.2.0","nyc":"15.1.0","rimraf":"5.0.10","test-all-versions":"6.1.0","ts-mocha":"10.0.0","typescript":"4.4.4"},"dependencies":{"@opentelemetry/instrumentation":"^0.53.0"},"homepage":"https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-graphql#readme","gitHead":"9dc58afed8134f95908331bcff35c5d9ec46fe9a","bugs":{"url":"https://github.com/open-telemetry/opentelemetry-js-contrib/issues"},"_id":"@opentelemetry/instrumentation-graphql@0.43.0","_nodeVersion":"18.20.4","_npmVersion":"lerna/6.6.2/node@v18.20.4+x64 (linux)","dist":{"integrity":"sha512-aI3YMmC2McGd8KW5du1a2gBA0iOMOGLqg4s9YjzwbjFwjlmMNFSK1P3AIg374GWg823RPUGfVTIgZ/juk9CVOA==","shasum":"71bb94ea775c70dbd388c739b397ec1418f3f170","tarball":"http://registry-npm.ywwl.com/@opentelemetry/instrumentation-graphql/download/@opentelemetry/instrumentation-graphql-0.43.0.tgz","fileCount":30,"unpackedSize":126139,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@opentelemetry%2finstrumentation-graphql@0.43.0","provenance":{"predicateType":"https://slsa.dev/provenance/v0.2"}},"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDwJNr+FM9kbMiJjV/mswSvz3OlKc+A+8OSAbvsbol/rAiBpJQPy0gkt+hdqjoTKzhuCtJO0sf/dnMR9gNHn5mLj5Q=="}],"size":29487,"noattachment":false,"key":"/@opentelemetry/instrumentation-graphql/-/@opentelemetry/instrumentation-graphql-0.43.0.tgz"},"_npmUser":{"name":"dyladan","email":"dyladan@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/instrumentation-graphql_0.43.0_1725282654358_0.5600116146943217"},"_hasShrinkwrap":false,"readme":"# OpenTelemetry Instrumentation GraphQL\n\n:bangbang: You could be a component owner for this package, and help maintain the quality its users deserve! Check out [open issues](https://github.com/open-telemetry/opentelemetry-js-contrib/labels/pkg%3Ainstrumentation-graphql) on how to help.\n\n[![NPM Published Version][npm-img]][npm-url]\n[![Apache License][license-image]][license-image]\n\nThis module provides automatic instrumentation and tracing for GraphQL in Node.js applications, which may be loaded using the [`@opentelemetry/sdk-trace-node`](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-sdk-trace-node) package and is included in the [`@opentelemetry/auto-instrumentations-node`](https://www.npmjs.com/package/@opentelemetry/auto-instrumentations-node) bundle.\n\nIf total installation size is not constrained, it is recommended to use the [`@opentelemetry/auto-instrumentations-node`](https://www.npmjs.com/package/@opentelemetry/auto-instrumentations-node) bundle with [@opentelemetry/sdk-node](`https://www.npmjs.com/package/@opentelemetry/sdk-node`) for the most seamless instrumentation experience.\n\nCompatible with OpenTelemetry JS API and SDK `1.0+`.\n\n*Note*: graphql plugin instruments graphql directly. it should work with any package that wraps the graphql package (e.g apollo).\n\n## Installation\n\n```shell script\nnpm install @opentelemetry/instrumentation-graphql\n```\n\n### Supported Versions\n\n- [`graphql`](https://www.npmjs.com/package/graphql) versions `>=14.0.0 <17`\n\n## Usage\n\n```js\n'use strict';\n\nconst { GraphQLInstrumentation } = require('@opentelemetry/instrumentation-graphql');\nconst { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');\nconst { registerInstrumentations } = require('@opentelemetry/instrumentation');\n\nconst provider = new NodeTracerProvider();\nprovider.register();\n\nregisterInstrumentations({\n  instrumentations: [\n    new GraphQLInstrumentation({\n      // optional params\n      // allowValues: true,\n      // depth: 2,\n      // mergeItems: true,\n      // ignoreTrivialResolveSpans: true,\n      // ignoreResolveSpans: true,\n    }),\n  ],\n});\n\n```\n\n## Optional Parameters\n\n|    Param    |   type  | Default Value |                                                                        Description                                                                        |\n|:-----------:|:-------:|:-------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------:|\n|  mergeItems | boolean |     false     |                    Whether to merge list items into a single element. example: `users.*.name` instead of `users.0.name`, `users.1.name`                   |\n|    depth    |  number |       -1      |                       The maximum depth of fields/resolvers to instrument. When set to 0 it will not instrument fields and resolvers. When set to -1 it will instrument all fields and resolvers. |\n| allowValues | boolean |     false     | When set to true it will not remove attributes values from schema source.   By default all values that can be sensitive are removed and replaced with \"*\" |\n| ignoreTrivialResolveSpans | boolean | false | Don't create spans for the execution of the default resolver on object properties. |\n| ignoreResolveSpans | boolean | false | Don't create spans for resolvers, regardless if they are trivial or not. |\n| responseHook | GraphQLInstrumentationExecutionResponseHook |     undefined     | Hook that allows adding custom span attributes based on the data returned from \"execute\" GraphQL action. |\n\n## Verbosity\n\nThe instrumentation by default will create a span for each invocation of a resolver.\n\nA resolver is run by graphql for each field in the query response, which can be a lot of spans for objects with many properties, or when lists are involved.\n\nThere are few config options which can be used to reduce the verbosity of the instrumentations.\n\nThey are all disabled by default. User can opt in to any combination of them to control the amount of spans.\n\n### ignoreTrivialResolveSpans\n\nWhen a resolver function is not defined on the schema for a field, graphql will use the default resolver which just looks for a property with that name on the object. If the property is not a function, it's not very interesting to trace.\n\n### ignoreResolveSpans\n\nThe performance overhead for complex schemas with a lot of resolvers can be high due to the large number of spans created. When ignoreResolveSpans is set to true, no spans for resolvers will be created.\n\nIf you are using `@apollo/server` as your graphql server, you might want to\nenable this option because all resolvers are [currently considered non-trivial](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1686).\n\n### depth\n\nThe depth is the number of nesting levels of the field, and the following is a query with a depth of 3:\n\n```json\n{\n  a {\n    b {\n      c\n    }\n  }\n}\n```\n\nYou can limit the instrumentation to stop recording \"resolve\" spans after a specific depth is reached.\n\n- `-1` means no limit.\n- `0` means don't record any \"resolve\" spans.\n- `2` for the example above will record a span for resolving \"a\" and \"b\" but not \"c\".\n\n### mergeItems\n\nWhen resolving a field to a list, graphql will execute a resolver for every field in the query on every object in the list.\n\nWhen setting mergeItems to `true` it will only record a span for the first invocation of a resolver on each field in the list, marking it's path as \"foo.*.bar\" instead of \"foo.0.bar\", \"foo.1.bar\".\n\nNotice that all span data only reflects the invocation on the first element. That includes timing, events and status.\n\nDownstream spans in the context of all resolvers will be child of the first span.\n\n## Examples\n\nCan be found [here](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/examples/graphql)\n\n## Semantic Conventions\n\nThis package does not currently generate any attributes from semantic conventions.\n\n## Useful links\n\n- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>\n- For more about OpenTelemetry JavaScript: <https://github.com/open-telemetry/opentelemetry-js>\n- For help or feedback on this project, join us in [GitHub Discussions][discussions-url]\n\n## License\n\nApache 2.0 - See [LICENSE][license-url] for more information.\n\n[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions\n[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/LICENSE\n[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat\n[npm-url]: https://www.npmjs.com/package/@opentelemetry/instrumentation-graphql\n[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Finstrumentation-graphql.svg\n","publish_time":1725282654583,"maintainers":[{"name":"pichlermarc","email":"marc.pichler@dynatrace.com"},{"name":"bogdandrutu","email":"bogdandrutu@gmail.com"},{"name":"dyladan","email":"dyladan@gmail.com"}],"_cnpm_publish_time":1725282654583,"dist-tags":{"latest":"0.73.0"}}