{"_id":"@blabu.com/apollo-opentracing","_rev":"3-08229eb4dc5d5ba19e789cf5484e1740","name":"@blabu.com/apollo-opentracing","dist-tags":{"latest":"1.2.0"},"versions":{"1.2.0":{"name":"@blabu.com/apollo-opentracing","version":"1.2.0","description":"Trace your GraphQL server with Opentracing","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"clean":"rm -rf dist","compile":"tsc","prepare":"npm run clean && npm run compile","test":"jest","semantic-release":"semantic-release","travis-deploy-once":"travis-deploy-once --pro","contributors:add":"all-contributors add","contributors:generate":"all-contributors generate"},"jest":{"transform":{"^.+\\.tsx?$":"ts-jest"},"testRegex":"(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$","moduleFileExtensions":["ts","tsx","js","jsx","json","node"]},"repository":{"type":"git","url":"git+https://github.com/voslartomas/apollo-opentracing.git"},"author":{"name":"Daniel Schmidt","email":"danielmschmidt92@gmail.com"},"license":"MIT","peerDependencies":{"apollo-server-env":"*","graphql":"0.10.x - 14.2.x","opentracing":"*"},"dependencies":{"graphql-extensions":"^0.2.0"},"devDependencies":{"@types/graphql":"14.2.0","@types/jest":"23.3.14","@types/node":"10.14.4","all-contributors-cli":"5.11.0","apollo-server":"2.4.8","apollo-server-env":"2.2.0","express":"4.16.4","graphql":"14.2.1","graphql-tools":"4.0.4","jest":"23.6.0","opentracing":"0.14.3","semantic-release":"15.13.3","supertest":"3.4.2","travis-deploy-once":"5.0.11","ts-jest":"23.1.4","typescript":"3.4.1"},"gitHead":"1226f2d316b4707202287d9fe77fb186b7d3a383","bugs":{"url":"https://github.com/voslartomas/apollo-opentracing/issues"},"homepage":"https://github.com/voslartomas/apollo-opentracing#readme","_id":"@blabu.com/apollo-opentracing@1.2.0","_npmVersion":"6.4.1","_nodeVersion":"10.15.1","_npmUser":{"name":"t.voslar","email":"t.voslar@gmail.com"},"dist":{"integrity":"sha512-cssfjmantT1ldikxb5hbyCG1ikUf59zpdOTY8dwr9rhPFRU/OLkz1Cvo7+sTIYL/dknkWF7HpMo/A8aJwXIOBA==","shasum":"a99899af2887dbce95cf59ee8a68e766d3ada8c8","tarball":"https://registry.npmjs.org/@blabu.com/apollo-opentracing/-/apollo-opentracing-1.2.0.tgz","fileCount":25,"unpackedSize":50783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcpw9ICRA9TVsSAnZWagAAimwP/ilQidDnCPvKvNJT0Dvl\nYRl/snNv22tELCaksDYsXHWGZkvk9FHpBoYjSl2eCp0nwvHgco67R069LL4n\nmaHsux9foUVWNtP47p0fWbODHBeq5arJ8mPOK1Bs/tmUiNWKvl4LBW51Ia82\nb9pidwTnSYYo/JXlw8XTEoNes2IPQ0XhuNUxmXD9neQUKNLd9zslfcxyrGtC\nQqbGnw3ozIYeuDR5XiKZzf17NKF348zfE4lfXsMlr4YkDxvbSXgJBNfgMdH7\npzMrnew2ZQDdUXafp5ZIWSa2uWIbG80CGkHgs2vEFDG6R7C9oFK/cTkPvt09\nep92qm5KP5S8IRj9a5RQl/+GFs9zavkEGs3MTamLInLhiYU40xQo4h0CspIx\na1m/mhurGtq+E7Jd4Ta5v1Tc6/K646aKDXqNUY7NA4NPeTVVgPWwcSW3xiuR\nf+rmVFQZ4xc8X37A4sEb8OXVXk8ZCnQ5JP1yCUM1eR6wZkRkvdQasoLZ4+tH\n+q2RLUftqH34vZE5T4DH0nmdlnyK8gJxwmfIQEFutk6ogfjDgK+KNw5PVX+i\nIEsMuMq77AS1+bb1C4TvroM4XzIpwnuHQo+BuUR5qjrke27D5b92hD2aoJey\nd3rB5a5yUHTYKZOi49KO0CAMk5F/pIYeteWEtdrYjvAJ6KQ0HOG8OwLaqcNY\nE9Rw\r\n=Wu9r\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICpcacCWwPj857rSeOTnR19a7RSMojqfL+HHkOv/dhnPAiEAs1PzoVCJu8vZj1YmpaazNadkgVc+j3Q+cyV1PQsUBCA="}]},"maintainers":[{"name":"poky85","email":"mail@jiripokorny.cz"},{"name":"oldas","email":"mzk@mozektevidi.net"},{"name":"lukaskaras","email":"lukaskaras.lk@gmail.com"},{"name":"t.voslar","email":"t.voslar@gmail.com"},{"name":"tomasstrejcek","email":"tomas.strejcek@ghn.cz"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/apollo-opentracing_1.2.0_1554452295800_0.7809442517787712"},"_hasShrinkwrap":false}},"time":{"created":"2019-04-05T08:18:15.616Z","1.2.0":"2019-04-05T08:18:16.011Z","modified":"2022-04-04T19:19:14.952Z"},"maintainers":[{"email":"cernytomasj@gmail.com","name":"cernytomas"},{"email":"mail@jiripokorny.cz","name":"poky85"},{"email":"lukaskaras.lk@gmail.com","name":"lukaskaras"},{"email":"t.voslar@gmail.com","name":"t.voslar"},{"email":"tomas.strejcek@ghn.cz","name":"tomasstrejcek"}],"description":"Trace your GraphQL server with Opentracing","homepage":"https://github.com/voslartomas/apollo-opentracing#readme","repository":{"type":"git","url":"git+https://github.com/voslartomas/apollo-opentracing.git"},"author":{"name":"Daniel Schmidt","email":"danielmschmidt92@gmail.com"},"bugs":{"url":"https://github.com/voslartomas/apollo-opentracing/issues"},"license":"MIT","readme":"# Apollo Opentracing [![npm version](https://badge.fury.io/js/apollo-opentracing.svg)](https://badge.fury.io/js/apollo-opentracing) [![Build Status](https://travis-ci.com/DanielMSchmidt/apollo-opentracing.svg?branch=master)](https://travis-ci.com/DanielMSchmidt/apollo-opentracing) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) [![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors)\n\nApollo Opentracing allows you to integrate open source baked performance tracing to your Apollo server based on industry standards for tracing.\n\n- 🚀 Request & Field level resolvers are traced out of the box\n- 🔍 Queries and results are logged, to make debugging easier\n- ⚙️ Select which requests you want to trace\n- 🔗 Spans transmitted through the HTTP Headers are picked up\n- 🔧 Use the opentracing compatible tracer you like, e.g.\n  - [jaeger](https://www.jaegertracing.io/)\n  - [zipkin](https://github.com/DanielMSchmidt/zipkin-javascript-opentracing)\n- 🦖 Support from node 6 on\n\n## Installation\n\nRun `npm install --save apollo-opentracing` given that you already setup an opentracing tracer accordingly.\n\n## Setup\n\nWe need two types of tracer (which could be identical if you like):\n\n- server: Only used for the root (the first span we will start)\n- local: Used to start every other span\n\n```diff\nconst { graphqlExpress } = require(\"apollo-server-express\");\nconst {serverTracer, localTracer} = require(\"./tracer\");\n+const OpentracingExtension = require(\"apollo-opentracing\").default;\n\napp.use(\n  \"/graphql\",\n  bodyParser.json(),\n  graphqlExpress({\n    schema,\n+   extensions: [() => new OpentracingExtension({\n+     server: serverTracer,\n+     local: localTracer,\n+   })]\n  })\n)\n```\n\n## Connecting Services\n\n![example image](demo.png)\n\nTo connect other services you need to use the opentracing [inject](http://opentracing.io/documentation/pages/api/cross-process-tracing.html) function of your tracer.\nWe pass the current span down to your resolvers as `info.span`, so you should use it.\n\nYou can also make use of it and add new logs or tags on the fly if you like.\nThis may look something like this:\n\n```js\nmyFieldResolver(source, args, context, info) {\n  const headers = {...};\n\n  const parentSpan = info.span;\n  // please use the same tracer you passed down to the extension\n  const networkSpan = tracer.startSpan(\"NetworkRequest:\" + endpoint, {\n    childOf: parentSpan\n  });\n\n  // Let's transfer the span information to the headers\n  tracer.inject(\n    networkSpan,\n    YourOpentracingImplementation.FORMAT_HTTP_HEADERS,\n    headers\n  );\n\n  return doNetworkRequest(endpoint, headers).then(result => {\n    networkSpan.finish()\n    return result;\n  }, err => {\n    networkSpan.log({\n      error: true,\n      errorMessage: err\n    });\n\n    networkSpan.finish();\n    return err;\n  });\n}\n```\n\n## Selective Tracing\n\nSometimes you don't want to trace everything, so we provide ways to select if you want to start a span right now or not.\n\n### By Request\n\nIf you construct the extension with `shouldTraceRequest` you get the option to opt-in or out on a request basis.\nWhen you don't start the span for the request the field resolvers will also not be used.\n\nThe function is called with the same arguments as the `requestDidStart` function extensions can provide, which is documented [here](https://github.com/apollographql/apollo-server/blob/master/packages/graphql-extensions/src/index.ts#L35).\n\nWhen the request is not traced there will also be no traces of the field resolvers.\n\n### By Field\n\nThere might be certain field resolvers that are not worth the tracing, e.g. when they get a value out of an object and need no further tracing. To control if you want a field resolver to be traced you can pass the `shouldTraceFieldResolver` option to the constructor. The function is called with the same arguments as your field resolver and you can get the name of the field by `info.fieldName`. When you return false no traces will be made of this field resolvers and all underlying ones.\n\n## Contributing\n\nPlease feel free to add issues with new ideas, bugs and anything that might come up.\nLet's make performance measurement to everyone <3\n\n## Contributors\n\nThanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore -->\n| [<img src=\"https://avatars2.githubusercontent.com/u/1337046?v=4\" width=\"100px;\"/><br /><sub><b>Daniel Schmidt</b></sub>](http://danielmschmidt.de/)<br />[💻](https://github.com/DanielMSchmidt/apollo-opentracing/commits?author=DanielMSchmidt \"Code\") [🤔](#ideas-DanielMSchmidt \"Ideas, Planning, & Feedback\") | [<img src=\"https://avatars2.githubusercontent.com/u/3578740?v=4\" width=\"100px;\"/><br /><sub><b>Ciaran Liedeman</b></sub>](https://github.com/cliedeman)<br />[🐛](https://github.com/DanielMSchmidt/apollo-opentracing/issues?q=author%3Acliedeman \"Bug reports\") [💻](https://github.com/DanielMSchmidt/apollo-opentracing/commits?author=cliedeman \"Code\") [⚠️](https://github.com/DanielMSchmidt/apollo-opentracing/commits?author=cliedeman \"Tests\") | [<img src=\"https://avatars3.githubusercontent.com/u/453031?v=4\" width=\"100px;\"/><br /><sub><b>Jens Ulrich Hjuler Pedersen</b></sub>](http://juhp.net)<br />[🐛](https://github.com/DanielMSchmidt/apollo-opentracing/issues?q=author%3AMultiply \"Bug reports\") [🤔](#ideas-Multiply \"Ideas, Planning, & Feedback\") [👀](#review-Multiply \"Reviewed Pull Requests\") | [<img src=\"https://avatars0.githubusercontent.com/u/9115596?v=4\" width=\"100px;\"/><br /><sub><b>Francesca</b></sub>](https://github.com/frances3006)<br />[💻](https://github.com/DanielMSchmidt/apollo-opentracing/commits?author=frances3006 \"Code\") |\n| :---: | :---: | :---: | :---: |\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!\n","readmeFilename":"README.md"}