{"id":20419396,"url":"https://github.com/risingstack/opentracing-auto","last_synced_at":"2025-05-07T15:45:20.750Z","repository":{"id":54935313,"uuid":"102042411","full_name":"RisingStack/opentracing-auto","owner":"RisingStack","description":"Out of the box distributed tracing for Node.js applications with OpenTracing.","archived":false,"fork":false,"pushed_at":"2021-04-22T08:03:08.000Z","size":345,"stargazers_count":133,"open_issues_count":9,"forks_count":32,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-15T21:23:48.232Z","etag":null,"topics":["distributed-tracing","instrumentation","node","nodejs","opentracing"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RisingStack.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-31T20:32:06.000Z","updated_at":"2025-01-21T20:48:15.000Z","dependencies_parsed_at":"2022-08-14T07:00:44.976Z","dependency_job_id":null,"html_url":"https://github.com/RisingStack/opentracing-auto","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RisingStack%2Fopentracing-auto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RisingStack%2Fopentracing-auto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RisingStack%2Fopentracing-auto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RisingStack%2Fopentracing-auto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RisingStack","download_url":"https://codeload.github.com/RisingStack/opentracing-auto/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252908663,"owners_count":21823465,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["distributed-tracing","instrumentation","node","nodejs","opentracing"],"created_at":"2024-11-15T06:36:47.936Z","updated_at":"2025-05-07T15:45:20.707Z","avatar_url":"https://github.com/RisingStack.png","language":"JavaScript","readme":"# opentracing-auto\n\n[![Build Status](https://travis-ci.org/RisingStack/opentracing-auto.svg?branch=master)](https://travis-ci.org/RisingStack/opentracing-auto)  \n\nOut of the box distributed tracing for [Node.js](https://nodejs.org) applications with OpenTracing.\nSupport multiple Tracers.\n\n**WARNING: experimental library, do not use in production yet**\n\n## Technologies\n\n- [async_hooks](https://github.com/nodejs/node/blob/master/doc/api/async_hooks.md)\n- [OpenTracing](http://opentracing.io/)\n\n**Requirements**\n\n- Node.js, \u003e= v8\n\n## Getting started\n\n```sh\nnpm install @risingstack/opentracing-auto\n```\n\n```js\n// must be in the first two lines of your application\nconst Instrument = require('@risingstack/opentracing-auto')\nconst { Tracer } = require('opentracing') // or any OpenTracing compatible tracer like jaeger-client\nconst tracer1 = new Tracer()\nconst tracer2 = new Tracer()\n\nconst instrument = new Instrument({\n  tracers: [tracer1, tracer2]\n})\n\n// rest of your code\nconst express = require('express')\n// ...\n```\n\nThis package depends\non [require-in-the-middle](https://github.com/opbeat/require-in-the-middle)\nand [shimmer](https://www.npmjs.com/package/shimmer) to monkeypatch tracing\ninformation onto the modules [listed below](#Instrumentations). Therefore it is\ncrucial that you require() supported modules after creating the tracing\ninstrument.\n\nIf you are using node 8.5+'s experimental module support, you will need to\nmanually hook supported modules:\n\n```js\nimport Instrument from '@risingstack/opentracing-auto';\nimport jaeger from 'jaeger-client';\nimport UDPSender from 'jaeger-client/dist/src/reporters/udp_sender';\nimport http from 'http';\n\nconst instrument = new Instrument({\n  tracers: [\n    new jaeger.Tracer(\n      'my-service-name',\n      new jaeger.RemoteReporter(new UDPSender.default({ host: 'my-jaeger-host' })),\n      new jaeger.RateLimitingSampler(1),\n      {}\n    ),\n  ],\n});\n\ninstrument.hookModule(http, 'http');\n```\n\n## API\n\n### new Instrument({ tracers: [tracer1, tracer2] })\n\nInstrument modules.\n\n- `tracers`: Array of OpenTracing compatible tracers\n  - **required**\n- `httpTimings`: Adds HTTP timings (DNS lookup, Connect, TLS, Time to first byte, Content transfer)\n  - *default: false*\n\n### instrument.unpatch()\n\nUnpatch instrumentations\n\n## Instrumentations\n\n- [http, https](https://nodejs.org/api/http.html)\n- [express](https://expressjs.com/)\n- [restify](http://restify.com/)\n- [mongodb-core](https://www.npmjs.com/package/mongodb-core)\n- [pg](https://www.npmjs.com/package/pg)\n- [mysql](https://www.npmjs.com/package/mysql)\n- [redis](https://www.npmjs.com/package/redis)\n\n## Example\n\nThe example require a running MongoDB and Jaeger.\n\n**To start Jaeger and visit it's dashboard:**\n\n```sh\ndocker run -d -p5775:5775/udp -p6831:6831/udp -p6832:6832/udp -p5778:5778 -p16686:16686 -p14268:14268 jaegertracing/all-in-one:latest \u0026\u0026 open http://localhost:16686\n```\n\n```sh\nnpm run example\ncurl http://localhost:3000\nopen http://localhost:16686\n```\n\n![Jaeger Node.js tracing](images/distributed_tracing.png)\n\n## HTTP timings\n\nYou can enable it with the `httpTimings: true`\n\n![HTTP timings](images/http_timings.png)\n\n## Debug\n\nStart your application with the `DEBUG=opentracing-auto*` environment variable.\n\n## Feature ideas\n\n- More database instrumentation: Redis etc.\n- More messaging layer instrumentation: HTTP/2, GRPC, RabbitMQ, Kafka etc.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frisingstack%2Fopentracing-auto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frisingstack%2Fopentracing-auto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frisingstack%2Fopentracing-auto/lists"}