{"id":21031492,"url":"https://github.com/slaveofcode/express-tracify","last_synced_at":"2026-04-27T09:31:14.084Z","repository":{"id":92795007,"uuid":"307916785","full_name":"slaveofcode/express-tracify","owner":"slaveofcode","description":"Middleware \u0026 utility to support tracing with jaeger \u0026 opentracing on ExpressJs","archived":false,"fork":false,"pushed_at":"2020-12-11T10:17:54.000Z","size":582,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-29T02:37:17.333Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/slaveofcode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-10-28T05:35:18.000Z","updated_at":"2020-12-11T10:17:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"e005018c-a2f9-40cb-8b6b-27c2fc01dfdc","html_url":"https://github.com/slaveofcode/express-tracify","commit_stats":{"total_commits":44,"total_committers":1,"mean_commits":44.0,"dds":0.0,"last_synced_commit":"5c1b901e197d6870cd4ae2fbc2722d2cdc2d533f"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/slaveofcode/express-tracify","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slaveofcode%2Fexpress-tracify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slaveofcode%2Fexpress-tracify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slaveofcode%2Fexpress-tracify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slaveofcode%2Fexpress-tracify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slaveofcode","download_url":"https://codeload.github.com/slaveofcode/express-tracify/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slaveofcode%2Fexpress-tracify/sbom","scorecard":{"id":831227,"data":{"date":"2025-08-11","repo":{"name":"github.com/slaveofcode/express-tracify","commit":"5c1b901e197d6870cd4ae2fbc2722d2cdc2d533f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"40 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc","Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j","Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-44c6-4v22-4mhx","Warn: Project is vulnerable to: GHSA-4x5v-gmq8-25ch","Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg","Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T17:51:01.081Z","repository_id":92795007,"created_at":"2025-08-23T17:51:01.081Z","updated_at":"2025-08-23T17:51:01.081Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32331305,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-19T12:28:58.678Z","updated_at":"2026-04-27T09:31:14.054Z","avatar_url":"https://github.com/slaveofcode.png","language":"TypeScript","readme":"# Express Tracify\nLibrary to support tracing with jaeger \u0026amp; opentracing on NodeJs with ExpressJs. This library is divided into 3 parts:\n\n1. Initialization\n2. Middlewares (start \u0026 finish span, error capture)\n3. Manual trace function\n\n### Installation\n\n#### NPM\n\n```\n$ npm i express-tracify\n```\n\n#### Init \u0026 Middleware Configuration\n\nThe example code below is using configuration via a direct parameter on the `Init` function, however, you can also use *Environment Variables* to set them. \n\nThis library using [jaeger-client-node](https://github.com/jaegertracing/jaeger-client-node) and [opentracing](https://github.com/opentracing/opentracing-javascript) on the implementation, so the parameter for *config* or *options* is also the same.\n\n\n```js\nconst Express = require('express')\nconst { Init, Middleware, ErrMiddlewareWrapper } = require('@usetada/express-tracify')\n\n// part 1: initialization\nInit({\n  tracer: {\n    config: {\n      serviceName: 'SVC 1',\n      sampler: {\n        type: 'const',\n        param: 1,\n      },\n    },\n    options: {}\n  }\n})\n\nconst app = Express()\n\n// part 2: middleware to create default request (auto start \u0026 finish span) \napp.use(Middleware())\n\n// You ExpressJs HTTP handlers\n\n// part 2: middleware to wrap error handler\napp.use(ErrMiddlewareWrapper((err, req, res, next) =\u003e {\n  return res.status(500).json({\n    error: true,\n    message: 'Something Wrong!',\n  })\n}))\n\n```\n\n### Trace Function\nFunction tracing is also possible by wrapping your function handler with `WrapHandler`\n\n```js\nconst { WrapHandler } = require('@usetada/express-tracify')\n\nconst Home = WrapHandler(function (req, res) {\n  res.json({\n    page: 'Home',\n  })\n}, 'Home Handler')\n\napp.get('/', Home)\n```\n\nThis example will automatically add a new span with the name *Home Handler*.\n\n### Traceable Sub-function\nThe advantage of wrapping your function handler with `WrapHandler` is you can also create another function tracing by using **traceFn**, but this function only available when your handler is not using *fat-arrow* style, because it will use the injected *(this)* context.\n\nFollowing the previous example\n\n```js\nconst getFromDB = () =\u003e {\n  // some process to trace\n}\n\n// part 3: manual trace on function\nconst Home = WrapHandler(async function (req, res) {\n  const TgetFromDB = this.traceFn(getFromDB, 'getFromDB') // set span Name 'getFromDB' \n\n  const data = await TgetFromDB()\n\n  res.json({\n    page: 'Home',\n    data,\n  })\n}, 'Home Handler')\n```\n\nYou'll notice the `getFromDB` function is using fat-arrow, it's impossible to call *(this)* in the context, by changing it to a non-fat-arrow function, you can call the `traceFn` from inside the function.\n\n```js\nfunction addLog() {\n  // some logging\n}\n\nfunction getFromDB {\n  // \"this\" is refers to TraceWrapper class\n  // so calling .traceFn again in here is automatically\n  // create new span, as a child of \"getFromDB\" span\n  const TaddLog = this.traceFn(addLog)\n\n  TaddLog('getting from DB')\n  // some process to trace\n}\n\nconst Home = WrapHandler(async function (req, res) {\n  const TgetFromDB = this.traceFn(getFromDB) // span name 'getFromDB'\n\n  const data = await TgetFromDB()\n\n  res.json({\n    page: 'Home',\n    data,\n  })\n}, 'Home Handler')\n```\n\nby using *named function* **function getFromDB()** you don't have to set a custom span name like before, the function **getFromDB** itself now has a name, gathering from the constructor, and `traceFn` will use that name if the second parameter is not given.\n\nIf the function wrapped by `traceFn` is calling \"this\" again inside the operation, it will refer to the **TraceWrapper** class, which has the `traceFn` that can be used to do tracing deeply on more sub-functions.\n\n### Prevent **\"this\"** context override\nAs you can see in the previous example, this library overrides the context of the current **\"this\"** object. If you working with a Class object where the operation is happening on the method calls, that would be a problem.\n\nTo handle that, you can insert additional context on the third parameter, and then you can use the tracer injected on the class method where stored on `$__tracer`.\n\n```js\nclass Person {\n  name;\n  \n  constructor(name) {\n    this.name = name\n  }\n\n  sayName() {\n    // use .traceFn via this.$__tracer.traceFn here\n    console.log(`Hi ${this.name}`)\n  }\n}\n\nWrapHandler(handler() {\n  const p = new Person('aditya')\n\n  const sayPersonName = this.traceFn(p.sayName, 'Person: sayName', { context: p })\n\n  sayPersonName() // Hi aditya\n})\n```\n\n### Apis\n\n#### TracerWrapper\nBase class for tracing functions\n\n#### .traceFn(fn, operationName, opts?: {context: Object })\nWill return new traced function that ready to execute.\n- `fn`: **Function** handler or function to trace (required)\n- `operationName`: **String** Custom operation name, if not supplied will use `[TheFunction].name` value, or empty (\"\")\n- `opts`: **Object** Options to pass\n  - `context` **Object** the custom context to pass on `function.apply` calls\n\n#### .traceFnExec(fn, operationName, opts)\nSame as `.traceFn` but will immediatelly execute the given function on `fn` param.\n\n\n#### .traceFns(fns)\nWill return multiple traced functions, the order is based on the given functions parameter\n- `fns`: **Array** array of parameter of `.traceFn`, the shorthand for creating multiple traced functions.\n\ne.g.\n```\nconst [tracedFn1, tracedFn2] = this.traceFns([\n  [() =\u003e {}, 'function 1'],\n  [() =\u003e {}, 'function 2', { context: this }]\n])\n```\n\n#### .getSpan()\nWill return the current span object in the current context\n\n#### .createChildSpan(operationName, options)\nCreate new child span, based on the current span context\n- `operationName`: **String** Operation name of new child span\n- `options`: **Object** options to be assigned on `tracer.startSpan` execution (optional)\n\n#### .setOperationName(name)\nSet custom operation name on the current span context\n- `name`: **String** the name of operation\n\n#### .setTag(key, val)\nSet opentracing Tag\n- `key`: **String** Key name, refers to Opentracing.Tags\n- `val`: **Any** value of the key tag\n\n#### .log(keyValuePairs, timestamp?: number)\nSet logging value\n- `keyValuePairs`: **Object{key: string, val: Any}** Key-Value pair of logging event\n- `timestamp`: **Number** The timestamp in milliseconds since the Unix epoch (optional)\n\n#### .setTagPriority(priorityNumber = 1)\nAn alias for setting tag priority on `Tags.SAMPLING_PRIORITY`, by default 1 (priority)\n- `priorityNumber`: **Number** the value of sampling priority **1** means always captured\n\n#### .setTagError(errMsg)\nShorthand for easily create tag error and set sampling priority to 1\n- `errMsg`: **String | Error** error message as a string or error object\n\n#### .setBaggageItem(key, value)\nSet baggage item on the current trace context\n- `key`: **String** key or the name of baggage item\n- `value`: **String** the value of baggage item\n\n#### .getBaggageItem(key)\nGet baggage item on the current trace context\n- `key`: **String** key or the name of baggage item\n\n### Examples\nYou can take a look at [example](https://github.com/slaveofcode/express-tracify/tree/main/example) folder to see full implementations\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslaveofcode%2Fexpress-tracify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslaveofcode%2Fexpress-tracify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslaveofcode%2Fexpress-tracify/lists"}