{"_id":"traceparent","_rev":"6-8e4f62e90e08de3fea2e929090250144","name":"traceparent","description":"Context management helper for the w3c traceparent header format","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"traceparent","version":"1.0.0","keywords":["elastic","apm","trace","context","w3c","traceparent"],"author":{"url":"https://github.com/qard","name":"Stephen Belanger","email":"stephen.belanger@elastic.co"},"license":"MIT","_id":"traceparent@1.0.0","maintainers":[{"name":"qard","email":"admin@stephenbelanger.com"}],"homepage":"https://github.com/elastic/node-traceparent#readme","bugs":{"url":"https://github.com/elastic/node-traceparent/issues"},"dist":{"shasum":"9b14445cdfe5c19f023f1c04d249c3d8e003a5ce","tarball":"https://registry.npmjs.org/traceparent/-/traceparent-1.0.0.tgz","fileCount":4,"integrity":"sha512-b/hAbgx57pANQ6cg2eBguY3oxD6FGVLI1CC2qoi01RmHR7AYpQHPXTig9FkzbWohEsVuHENZHP09aXuw3/LM+w==","signatures":[{"sig":"MEQCIDD26Ky90OcPGkafHXm2+pzJkmfQ7tkG4wjkauGDMdTFAiAMac0EULVIZNc01VFhgnn0wbCriss4uHvimTkH60j99w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9002,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcbHaaCRA9TVsSAnZWagAAtsoP/2W33dj+EM9qtAReUnEY\nJ4wfnwyOuV+9OK5H1NYJR0dARI2/tDdtZn48HJcMLwftNNT6/O/ZpnbE6s72\noAmz8/Z6Y4Wax4vYApy/MHbsCgqyzdsFo9++ih8j4wxMaRWEpAwswWnAqPo2\nzfaHeNG7mMJQEaP5xsi0deR85hqWpRwKs+3206GCF6dMbGxgsRVxhCCEI6jp\nXUx4KzxJ9efbERepXoh1sNBjLwdLcpuEOs23jCq6mZs4VrXXLz+EP99K9Nqg\ne5hIhpNYaNRBQ7HTNcUbfS283PIGvE/WlMWXO6lKuJVsUz4Gr6GlpE7cjCvp\nqiWJCCgrykj2Ll5eHyVcTmMheSYLe1BosPkjYbTmueT76ZpsFnwmwhgMZaW6\nkP5zqjM8rSXryDsAG5A23IJaRjjsJRttdmcMACJFf7EsNijkusJoxK4CCBH1\n3cEng1P+2rBy0+vOwidT7qeWuUqtUSbl0udC4g5CkCZ3aRwpNMceX5k87TF7\nbUXUkpWq1xGOI7ByonEx9yEAi673uWxSv+DRYMUOdruhErJGNB5M0Rw8JZMu\nkt3kX3HE+Iazky2agbR0kwVQ54Hl+KEY58eic6ql0zVHu3aK054VNqMlW5wH\n3QHvPXvaWESS84FL9oIJQNZ8Aicl9//uE7r79PHWcLUUGCbwdM0EOGVd1v/S\n+ZeW\r\n=Rpr7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","gitHead":"4044b158eefe5faefca3fe0e95f56f06a710f7de","scripts":{"test":"tape test.js"},"_npmUser":{"name":"qard","email":"admin@stephenbelanger.com"},"repository":{"url":"git+https://github.com/elastic/node-traceparent.git","type":"git"},"_npmVersion":"6.4.1","description":"Context management helper for the w3c traceparent header format","directories":{},"_nodeVersion":"10.14.2","dependencies":{"random-poly-fill":"^1.0.1"},"_hasShrinkwrap":false,"devDependencies":{"tape":"^4.9.2"},"_npmOperationalInternal":{"tmp":"tmp/traceparent_1.0.0_1550612121182_0.4992021053086717","host":"s3://npm-registry-packages"}}},"time":{"created":"2019-02-19T21:35:21.181Z","modified":"2024-06-28T18:07:05.572Z","1.0.0":"2019-02-19T21:35:21.395Z"},"maintainers":[{"email":"trentm@gmail.com","name":"trentm"},{"email":"w@tson.dk","name":"watson"},{"email":"admin@stephenbelanger.com","name":"qard"}],"author":{"url":"https://github.com/qard","name":"Stephen Belanger","email":"stephen.belanger@elastic.co"},"repository":{"url":"git+https://github.com/elastic/node-traceparent.git","type":"git"},"keywords":["elastic","apm","trace","context","w3c","traceparent"],"license":"MIT","homepage":"https://github.com/elastic/node-traceparent#readme","bugs":{"url":"https://github.com/elastic/node-traceparent/issues"},"readme":"# traceparent\n\n[![npm](https://img.shields.io/npm/v/traceparent.svg)](https://www.npmjs.com/package/traceparent)\n[![Build status](https://travis-ci.org/elastic/node-traceparent.svg?branch=master)](https://travis-ci.org/elastic/node-traceparent)\n[![codecov](https://img.shields.io/codecov/c/github/elastic/node-traceparent.svg)](https://codecov.io/gh/elastic/node-traceparent)\n[![Standard - JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)\n\nThis is a basic implementation of the traceparent header part of the W3C trace context spec.\n\n## Installation\n\n```\nnpm install traceparent\n```\n\n## Example Usage\n\n```js\nconst crypto = require('crypto')\nconst TraceParent = require('traceparent')\n\nconst version = Buffer.alloc(1).toString('hex')\nconst traceId = crypto.randomBytes(16).toString('hex')\nconst id = crypto.randomBytes(8).toString('hex')\nconst flags = '01'\n\nconst header = `${version}-${traceId}-${id}-${flags}`\n\nconst parent = TraceParent.fromString(header)\n```\n\n## API\n\n### `new TraceParent(buffer)`\n\nConstruct a new `TraceParent` instance from an existing buffer. The contents are binary data that corresponds to the structure of the [W3C traceparent header][traceparent] format, with separators removed.\n\n### `TraceParent.fromString(header)`\n\nReconstruct a `TraceParent` instance from a formatted [W3C traceparent header][traceparent] string.\n\n### `TraceParent.startOrResume(parent, settings)`\n\nResume from a parent context, if given, or start a new context. Accepts another `TraceParent` instance, a [W3C traceparent header][traceparent] string, or a `Span` or `Transaction` instance from [elastic-apm-node](http://npmjs.org/package/elastic-apm-node).\n\nRequires a `settings` object with a `transactionSampleRate` value from 0.0 to 1.0 to generate a sampling decision for the context. This will only be applied when starting a _new_ context. When continuing an existing context, the sampling decision will be propagated into all child contexts.\n\n### `traceParent.recorded`\n\nReturns `true` if this `TraceParent` is sampled.\n\n### `traceParent.traceId`\n\nThe `traceId` property will propagate through all children in the tree to link them all together.\n\n### `traceParent.id`\n\nThe `id` property is used to uniquely identify a given `TraceParent` instance within the tree.\n\n### `traceParent.parentId`\n\nThe `parentId` property links this context to its direct parent in the tree.\n\n### `traceParent.flags`\n\nThe `flags` property is used to store metadata such as the sampling decision.\n\n### `traceParent.version`\n\nThe `version` property corresponds to the version segment of the [W3C traceparent header][traceparent].\n\n### `traceParent.child()`\n\nCreate a new `TraceParent` instance that is a child of this one.\n\n### `traceParent.toString()`\n\nFormats the `TraceParent` instance as a [W3C traceparent header][traceparent].\n\n### `traceParent.ensureParentId()`\n\nReturn the parent ID, if there is none, generate one. This is useful in browser instrumentation to produce a starting span around a browser request which was not instrumented prior to page load.\n\n## License\n\n[MIT](LICENSE)\n\n[traceparent]: https://github.com/w3c/trace-context/blob/master/spec/20-http_header_format.md\n","readmeFilename":"README.md"}