New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

egg-jaeger

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

egg-jaeger - npm Package Compare versions

Comparing version

to
1.0.5

CHANGELOG.md

6

app.js
'use strict';
const hookSequelize = require('./lib/hookSequelize');
const hooks = require('./lib/hooks');
module.exports = (app) => {
module.exports = app => {
app.beforeStart(async () => {
app.als.enable();
hookSequelize(app);
hooks(app);
});

@@ -10,0 +10,0 @@ // put before other core middlewares

'use strict';
const cluster = require('cluster');
const address = require('address');
const cacheJaeger = Symbol('jaeger_client_tracer');

@@ -7,2 +9,6 @@ const { initTracer, opentracing } = require('jaeger-client');

const WORKER_ID = cluster.worker ? cluster.worker.id : 0;
const IPV4 = address.ip();
const IPV6 = address.ipv6();
module.exports = {

@@ -22,7 +28,12 @@ get als() {

startSpan(name, tags = {}) {
const childOf = als.getFromParent('span');
this.coreLogger.debug('[egg-jaeger] startSpan %s', name);
tags['worker.id'] = WORKER_ID;
tags['process.id'] = process.pid;
tags['local.ipv4'] = IPV4;
tags['local.ipv6'] = IPV6;
const childOf = this.als.getFromParent('span');
const span = this.jaeger.startSpan(name, childOf ? { childOf, tags } : { tags });
als.set('span', span);
this.als.set('span', span);
return span;
},
};
'use strict';
const als = require('async-local-storage');
module.exports = (options, app) => async function jaegerMiddleware(ctx, next) {
als.scope()
const span = app.startSpan(ctx.path);
span.setTag('requestMethod', ctx.method);
als.set('span', span);
try {
await next();
span.finish();
} catch (err) {
span.setTag(app.opentracing.Tags.ERROR, true);
const finishSpan = (span, ctx, err) => {
span.setTag('http.status_code', ctx.response.status);
if (err) {
span.setTag('error', true);
span.log({

@@ -21,5 +13,20 @@ event: 'error',

});
span.finish();
}
ctx.app.coreLogger.debug('[egg-jaeger] finishSpan', span);
span.finish();
};
module.exports = (options, app) => async function jaegerMiddleware(ctx, next) {
app.als.scope();
const span = app.startSpan(ctx.path, {
'http.method': ctx.method,
'http.url': ctx.url,
});
try {
await next();
finishSpan(span, ctx);
} catch (err) {
finishSpan(span, ctx, err);
throw err;
}
};
{
"name": "egg-jaeger",
"version": "1.0.3",
"description": "",
"version": "1.0.5",
"description": "jaeger egg plugin",
"eggPlugin": {
"name": "jaeger",
"optionalDependencies": [
"sequelize"
]
"name": "jaeger"
},
"keywords": [
"egg",
"eggPlugin",
"egg-plugin"
],
"dependencies": {
"async-local-storage": "^2.1.0",
"jaeger-client": "^3.13.0"
},
"devDependencies": {
"@commitlint/cli": "^7.2.1",
"@commitlint/config-conventional": "^7.1.2",
"autod": "^3.0.0",
"autod-egg": "^1.0.0",
"egg": "^2.0.0",
"egg-bin": "^4.3.0",
"egg-ci": "^1.8.0",
"egg-mock": "^3.13.0",
"egg-redis": "^2.2.0",
"eslint": "^4.11.0",
"eslint-config-egg": "^5.1.0",
"husky": "^1.2.0",
"lint-staged": "^8.1.0",
"standard-version": "^4.4.0",
"webstorm-disable-index": "^1.2.0"
},
"engines": {
"node": ">=8.0.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"release": "standard-version",
"test": "npm run lint -- --fix && egg-bin pkgfiles && npm run test-local",
"test-local": "egg-bin test",
"cov": "egg-bin cov",
"lint": "eslint .",
"ci": "egg-bin pkgfiles --check && npm run lint && npm run cov",
"pkgfiles": "egg-bin pkgfiles",
"autod": "autod"
},
"lint-staged": {
"*.js": [
"eslint --fix",
"git add"
]
},
"files": [
"app",
"config",
"app.js",
"lib",
"commitlint.config.js"
],
"ci": {
"version": "8, 9"
},
"repository": {
"type": "git",
"url": "git+https://github.com/sqlwwx/egg-jaeger.git"
},
"bugs": {
"url": "https://github.com/sqlwwx/egg-jaeger/issues"
},
"homepage": "https://github.com/sqlwwx/egg-jaeger#readme",
"author": "sqlwwx <wwx_2012@live.com> (http://wiki.lab.wuweixing.com)",
"license": "MIT",
"dependencies": {
"async-local-storage": "github:sqlwwx/async-local-storage#7a5f7d1",
"jaeger-client": "^3.13.0"
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
}
}

@@ -1,3 +0,63 @@

# links
# egg-jaeger
https://github.com/weidian-lab/jaeger-tracer-node
[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][codecov-image]][codecov-url]
[![David deps][david-image]][david-url]
[![Known Vulnerabilities][snyk-image]][snyk-url]
[![npm download][download-image]][download-url]
[npm-image]: https://img.shields.io/npm/v/egg-jaeger.svg?style=flat-square
[npm-url]: https://npmjs.org/package/egg-jaeger
[travis-image]: https://img.shields.io/travis/sqlwwx/egg-jaeger.svg?style=flat-square
[travis-url]: https://travis-ci.org/sqlwwx/egg-jaeger
[codecov-image]: https://img.shields.io/codecov/c/github/sqlwwx/egg-jaeger.svg?style=flat-square
[codecov-url]: https://codecov.io/github/sqlwwx/egg-jaeger?branch=master
[david-image]: https://img.shields.io/david/sqlwwx/egg-jaeger.svg?style=flat-square
[david-url]: https://david-dm.org/sqlwwx/egg-jaeger
[snyk-image]: https://snyk.io/test/npm/egg-jaeger/badge.svg?style=flat-square
[snyk-url]: https://snyk.io/test/npm/egg-jaeger
[download-image]: https://img.shields.io/npm/dm/egg-jaeger.svg?style=flat-square
[download-url]: https://npmjs.org/package/egg-jaeger
<!--
Description here.
-->
## Install
```bash
$ npm i egg-jaeger --save
```
## Usage
```js
// {app_root}/config/plugin.js
exports.jaeger = {
enable: true,
package: 'egg-jaeger',
};
```
## Configuration
```js
// {app_root}/config/config.default.js
exports.jaeger = {
};
```
see [config/config.default.js](config/config.default.js) for more detail.
## Example
<!-- example here -->
## Questions & Suggestions
Please open an issue [here](https://github.com/sqlwwx/egg-jaeger/issues).
## License
[MIT](LICENSE)