Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/luncher/opentracing-connect
integrate opentracing with connect like style middlewares
https://github.com/luncher/opentracing-connect
express jaeger koa2 opentracing tracing
Last synced: about 1 month ago
JSON representation
integrate opentracing with connect like style middlewares
- Host: GitHub
- URL: https://github.com/luncher/opentracing-connect
- Owner: Luncher
- Created: 2017-10-12T09:39:07.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-16T10:54:36.000Z (about 7 years ago)
- Last Synced: 2024-11-28T06:04:46.192Z (about 1 month ago)
- Topics: express, jaeger, koa2, opentracing, tracing
- Language: JavaScript
- Size: 34.2 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# opentracing-connect
[![NPM version][npm-image]][npm-url]
[![Build Status][travis-image]][travis-url]
[![Coverage][codecov-image]][codecov-url]
[![David Status][david-image]][david-url][npm-url]: https://www.npmjs.com/package/opentracing-connect
[npm-image]: https://img.shields.io/npm/v/opentracing-connect.svg?style=flat
[david-url]: https://david-dm.org/Luncher/opentracing-connect
[david-image]: https://david-dm.org/Luncher/opentracing-connect.svg?style=flat
[travis-url]: https://travis-ci.org/Luncher/opentracing-connect
[travis-image]: https://img.shields.io/travis/Luncher/opentracing-connect.svg?style=flat
[codecov-url]: https://codecov.io/gh/Luncher/opentracing-connect
[codecov-image]: https://img.shields.io/codecov/c/github/Luncher/opentracing-connect.svg?style=flat## Quick Start
### Integrated With Express
```javascript
const express = require('express')
const { Tracer, RouterProxy } = require('opentracing-connect')const app = new express()
const serviceName = 'One'
//create and register global tracer
Tracer.createGlobalTracer(serviceName, { logger: console })
//proxy express router
const Router = RouterProxy.create({ router: express.Router(), proxy: { type: "express" } })Router.get('/one', async (request, response, next) => {
//request has trace prop: traceCtx
const result = await doSomething(request.traceCtx.span)
console.log('service one result:')
console.dir(result)
response.json(result)
})```
---
### Integrated With Koa2
```javascript
const Koa = require('koa')
const KoaRouter = require('koa-router')const app = new Koa()
const serviceName = 'Two'
const tracer = Tracer.createGlobalTracer(serviceName, { logger: console })
const Router = RouterProxy.create({ router: KoaRouter(), proxy: { type: "koa2" } })Router.get('/two', async (ctx, next) => {
try {
const userIds = [1, 2]
//ctx has trace prop: traceCtx
const result = await getUserInfo(userIds, { span: ctx.traceCtx.span })
ctx.traceCtx.span.log({'event': 'request_end'})
ctx.body = result
} catch(err) {
console.log(err)
}return
})```
---
### RouterProxy Configure
```javascript
{
//router instance
router: expressRouter,
//proxy type
proxy: {
type: 'express'
},
//add cusmomize tags
customizeTags: function ({ span, tracer}, ...args) {}
}
```## [MIT License](https://opensource.org/licenses/MIT)